https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78529
--- Comment #21 from amker at gcc dot gnu.org --- (In reply to Jakub Jelinek from comment #20) > Unless you do something very nasty in the spec files (in which case you > should just avoid those tests), the user specified objects should always > appear before stuff coming from -lc unless -lc is specified first on the > command line. The link command is like: /.../collect2 -plugin /.../liblto_plugin.so "-plugin-opt=/.../lto-wrapper" "-plugin-opt=-fresolution=strcat-chk.res" "-plugin-opt=-pass-through=-lgcc" "-plugin-opt=-pass-through=-lc" "-plugin-opt=-pass-through=-lrdimon" "-plugin-opt=-pass-through=-lgcc" -flto -Ttext-segment 0x80000000 -EL -X -maarch64elf -o a.exe /.../crti.o /.../crtbegin.o /.../../../../../aarch64-none-elf/lib/crt0.o -L/... -L/.../../lib/gcc -L/.../../../../../aarch64-none-elf/lib strcat-chk.o strcat-chk-lib.o main.o --allow-multiple-definition -lm -Map a.map -lgcc /.../../../../../aarch64-none-elf/lib/cpu-init/rdimon-aem-el3.o --start-group -lc -lrdimon --end-group -lgcc /.../crtend.o /.../crtn.o libraries goes after object files in this case. With link map file as: Archive member included to satisfy reference by file (symbol) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-atexit.o) /.../../../../../aarch64-none-elf/lib/crt0.o (atexit) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-exit.o) /.../../../../../aarch64-none-elf/lib/crt0.o (exit) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-fini.o) /.../../../../../aarch64-none-elf/lib/crt0.o (__libc_fini_array) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-impure.o) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-exit.o) (_global_impure_ptr) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-init.o) /.../../../../../aarch64-none-elf/lib/crt0.o (__libc_init_array) /.../../../../../aarch64-none-elf/lib/libc.a(lib_a-memset.o) /.../../../../../aarch64-none-elf/lib/crt0.o (memset) It looks like library version memset is pulled in because of crt0.o and zeroing out BSS section. Shouldn't linker first parse all imports/exports of under provided compilation units, then search for undefined symbols in libraries?