https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102115
Bug ID: 102115 Summary: symbol address eliminated by the xtensa size optimization Product: gcc Version: 12.0 URL: https://github.com/earlephilhower/newlib-xtensa/issues /19#issuecomment-903203750 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: me at jhdtl dot ru Target Milestone: --- Host: x86_64-w64-mingw32 Target: xtensa-lx106-elf Build: x86_64-linux-gnu Created attachment 51370 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51370&action=edit Missing symbol example .\x86_64-w64-mingw32.xtensa-lx106-elf-1757bed.210826\xtensa-lx106-elf\bin\xtensa-lx106-elf-gcc.exe -v Using built-in specs. COLLECT_GCC=C:\Users\maxim\Documents\gist\a433474aa40ab0f6433f9240455fd624\x86_64-w64-mingw32.xtensa-lx106-elf-1757bed.210826\xtensa-lx106-elf\bin\xtensa-lx106-elf-gcc.exe COLLECT_LTO_WRAPPER=c:/users/maxim/documents/gist/a433474aa40ab0f6433f9240455fd624/x86_64-w64-mingw32.xtensa-lx106-elf-1757bed.210826/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/12.0.0/lto-wrapper.exe Target: xtensa-lx106-elf Configured with: /home/jhdtl/dev/esp-quick-toolchain/repo/gcc-gnu/configure --prefix=/home/jhdtl/dev/esp-quick-toolchain/xtensa-lx106-elf.win64 --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --target=xtensa-lx106-elf --disable-shared --with-newlib --enable-threads=no --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --disable-bootstrap --enable-languages=c,c++ --enable-lto --enable-static=yes --disable-libstdcxx-verbose Thread model: single Supported LTO compression algorithms: zlib gcc version 12.0.0 20210825 (experimental) (GCC) After the 64a54505ec8249178b9767d1420354f8eb55de50, using -Os on x86_64-w64-mingw32 *may* result in missing function symbol in the example test.ii attached if the symbol's address can be compressed into small number accepted by the movi + slli. >From the URL, adding the suggested fprintf to the 'xtensa_emit_move_sequence' and running with the following command: $ xtensa-lx106-elf-g++.exe -Os -save-temps -mlongcalls -mtext-section-literals -falign-functions=4 -ffunction-sections -fdata-sections -Wall -Werror=return-type -free -fipa-pta -fno-rtti -std=gnu++17 -S -o test.S test.cpp Prints when the optimization happens: [xtensa_emit_move_sequence @ function()] '513540096[0x1e9c0000]' => '1959[0x7a7] << 18' [xtensa_emit_move_sequence @ function()] '513540096[0x1e9c0000]' => '1959[0x7a7] << 18' [xtensa_emit_move_sequence @ function()] '513540096[0x1e9c0000]' => '1959[0x7a7] << 18' Which will not be the expected function address at runtime, and will also remove the symbol from the resulting object: test.S:_Z8functionv: movi a5, 0x7a7 slli a5, a5, 18 l32r a4, .LC209 l32r a2, .LC426 mov.n a3, a5 s32i.n a5, sp, 20 call0 _Z8three132PFvPFvPFvvEES0_ES2_S0_