bebbo / binutils-gdb

Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
3 stars 3 forks source link

--gc-sections breaks executable #19

Closed githubaf closed 2 years ago

githubaf commented 2 years ago

I experimented with -ffunction-sections, -fdata-sections and --gc-sections.

Please find an example attached. When compiled for linux, everything works as expected. When compiling for Amiga with --gc-sections, the executable crashes. (Tested with vamos and with WinUAE) When compiling without --gc-sections, it works again.

# works on Linux
gcc -Wall --pedantic -g -O0 -ffunction-sections -fdata-sections test_main.c test_2.c -o test_linux -Wl,--gc-sections,-Map=Linker.map,--print-gc-sections
./test_linux

# crashes when compiled for Amiga
m68k-amigaos-gcc -Wall --pedantic -noixemul -g -O0 -ffunction-sections -fdata-sections test_main.c test_2.c -o test -Wl,--gc-sections,-Map=Linker.map,--print-gc-sections
vamos test

af_GarbageCollectorTest.zip

bebbo commented 2 years ago

the recent changes are live - these also contain a new implemention for --gc-sections