Actually I just wanted to try out link time garbage collection (--gc-section), but...see yourself:
The gc only works if I compile stuff with -ffunction-sections and/or -fdata-sections and I also found out that it's better to KEEP() the SLSTART section 😀 in this case. Furthermore, the output format must be set to elf (why, because the linker even can producee binaries directly, without objcopy. anyways). But it turned out that the last step fucks up the binary, slightly, but effective.
When I link an ELF compiled project with gcc option -Xlinker --oformat=elf32-sh, then the binary will crash(in yabause).
Now comes the funny thing: the same project compiled with COFF "features" unused stuff, malloc and co. and I remembered that for COFF you have to define a dummy function __main() to prevent linking malloc. I did and now comes the funny thing: it crashes, just like the elf version.
Okay, I compared elf compiled versions, one with --oformat=elf32-sh and one without. The map files are almost perfectly identical(checked with WinMerge), every single object is in the same place for both binaries. Only sometimes the size of linked stuff is a little bit smaller, without effect to location.
Fine, then I compared the binaries with WinHex and I get 63 bytes different.
What can be the reason why the elf version crashs? All I want is to use some fancy compile and link flags, why do I have to get such a headache for this?
The gc only works if I compile stuff with -ffunction-sections and/or -fdata-sections and I also found out that it's better to KEEP() the SLSTART section 😀 in this case. Furthermore, the output format must be set to elf (why, because the linker even can producee binaries directly, without objcopy. anyways). But it turned out that the last step fucks up the binary, slightly, but effective.
When I link an ELF compiled project with gcc option -Xlinker --oformat=elf32-sh, then the binary will crash(in yabause).
Now comes the funny thing: the same project compiled with COFF "features" unused stuff, malloc and co. and I remembered that for COFF you have to define a dummy function __main() to prevent linking malloc. I did and now comes the funny thing: it crashes, just like the elf version.
Okay, I compared elf compiled versions, one with --oformat=elf32-sh and one without. The map files are almost perfectly identical(checked with WinMerge), every single object is in the same place for both binaries. Only sometimes the size of linked stuff is a little bit smaller, without effect to location.
Fine, then I compared the binaries with WinHex and I get 63 bytes different.
What can be the reason why the elf version crashs? All I want is to use some fancy compile and link flags, why do I have to get such a headache for this?