
Dear =?UTF-8?q?Andreas=20Bie=C3=9Fmann?=,
In message 1344848523-20359-1-git-send-email-andreas.devel@googlemail.com you wrote:
This patch fixes following warning: ---8<--- dlmalloc.c: In function 'malloc_bin_reloc': dlmalloc.c:1493: warning: dereferencing pointer 'p' does break strict-aliasing rules dlmalloc.c:1493: warning: dereferencing pointer 'p' does break strict-aliasing rules dlmalloc.c:1490: note: initialized from here dlmalloc.c:1493: note: initialized from here
...
+typedef unsigned long __attribute__((__may_alias__)) ulong_aliased; void malloc_bin_reloc (void) {
- unsigned long *p = (unsigned long *)(&av_[2]);
- ulong_aliased *p = (ulong_aliased *)(&av_[2]);
I dislike this typedef, especially as it's used only a single time. But even so - why cannot we avoid the __may_alias__ thing alltogether?
You wrote in http://article.gmane.org/gmane.comp.boot-loaders.u-boot/137770 that Simon's patch breaks avr32 boards at runtime.
The implementation is indeed broken. I wonder if it ever worked:
mbinptr *p = &av_[2]; int i;
for (i = 2; i < ARRAY_SIZE(av_); ++i) *p = (mbinptr)((ulong)*p + gd->reloc_off);
i. e. this has the offset 2 added twice, so it is missing the first two real entries, env writing beyond the end of the array.
Can you please test this code instead:
mbinptr *p = &av_; int i;
for (i = 2; i < ARRAY_SIZE(av_); ++i) *p = (mbinptr)((ulong)*p + gd->reloc_off);
?
Best regards,
Wolfgang Denk