ARM cross-compiler with newlib, LTO, undefined reference to libc symbols

Alexander Monakov amonakov@ispras.ru
Sat May 29 11:19:29 GMT 2021


> With the arm cross compiler:
> /usr/libexec/gcc/arm-none-eabi/ld: /tmp/ccupVhtJ.ltrans0.ltrans.o: reference to malloc
> /usr/libexec/gcc/arm-none-eabi/ld: /tmp/ccupVhtJ.ltrans0.ltrans.o: in function `f':
> /home/gabriel/tmp/t1.c:3: undefined reference to `malloc'
> collect2: error: ld returned 1 exit status
> 
> So it's just not finding the symbol?

It's how static linking works: the defining object is not unpacked from libc.a
unless the linker previously saw a reference to it. The linker would need to
(re)scan libc.a after being handed this ltrans unit from the LTO plugin.

Can you show output with '-Wl,-v,-t', with and without LTO?

Alexander


More information about the Gcc-help mailing list