> Sorry, I think we might have our wires crossed :-) It's the address > returned by malloc that needs to be 8 byte aligned rather than the > number of bytes returned. Yes I understand this.. But isn't malloc (unix) using padding ?
> The problem is, some instructions, for example LDRD, require an 8 > byte aligned base address. If we use malloc to allocate a structure > that starts with an 8 byte type that the compiler might use LDRD to > load and malloc returns a 4 byte (but not 8) aligned address, then it > will probably abort. I have been testing with mallocs , and the addresses returned seems to be 8 byte aligned. I guess gcc has the answer. > In fact, I fell foul of something similar in the dynamic linker > when porting GCC 8/10; I had to ensure that the library data segments > retained the original alignment that the compiler/linker gave them to > prevent LDRD from aborting. > I suspect that newer versions (than 4.7) of GCC will expect malloc'ed > memory to be 8 byte aligned and pad structures accordingly. > Unfortunately, we're a bit behind there, and I think it is something we > need to look at. OK The reason for all this is , malloc fails for me , so I decided to roll my own. In that I wanted to make sure that the mem and addresses are the same as expected from malloc. Michael _______________________________________________ GCCSDK mailing list gcc@gccsdk.riscos.info Bugzilla: http://www.riscos.info/bugzilla/index.cgi List Info: http://www.riscos.info/mailman/listinfo/gcc Main Page: http://www.riscos.info/index.php/GCCSDK