https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118715
Christophe Lyon <clyon at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2025-02-04 Status|UNCONFIRMED |ASSIGNED CC| |clyon at gcc dot gnu.org --- Comment #6 from Christophe Lyon <clyon at gcc dot gnu.org> --- >From the linker side, I think the problem is that the first time using_thumb_only() is called, it returns false, so elf32_arm_create_dynamic_sections does not update htab->plt_header_size and htab->plt_entry_size. Under gdb I noticed that the first call returns false, the next ones correctly return true. >From gdb, I started the linker with the following args (grabbed from -Wl,-debug etc...) -plugin XXX/liblto_plugin.so -plugin-opt=XXX/lto-wrapper -plugin-opt=-fresolution=pr118715.exe.lto.res --sysroot=XXX --build-id -shared -X -o pr118715.exe.lto -e _start -L YYY pr118715.exe.lto-pr118715.o and COLLECT_GCC_OPTIONS="'-O2' '-Wall' '-Wextra' '-fPIC' '-ffreestanding' '-nostdlib' '-mthumb' '-mcpu=cortex-m4' '-e' '_start' '-shared' '-o' 'pr118715.exe.lto' '-save-temps' '-flto' '-mfloat-abi=hard' '-mlibarch=armv7e-m+fp' '-march=armv7e-m+fp' '-dumpdir' 'pr118715.exe.lto.'" So some initialization is not properly taking place and the -mcpu=cortex-m4 option is not taken into account by the (LTO) linker soon enough