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
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.
af_GarbageCollectorTest.zip