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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> To be clear, the error I'm seeing with the example is this:
> 
>  /usr/libexec/gcc/arm-3ds-none-eabi/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008018
>  /usr/libexec/gcc/arm-3ds-none-eabi/ld: /tmp/ccPp7lyA.ltrans0.ltrans.o: in function `f':
>  /home/gabriel/tmp/t1.c:3: undefined reference to `malloc'
>  collect2: error: ld returned 1 exit status

I would start by adding -Wl,-y,malloc to last gcc command line (the link step
with '-o main') to see how linker sees references to malloc. You can do that
both with and without -flto to compare successful/failing scenarios.

If you have both BFD and Gold linker, try both (-fuse-ld=gold or =bfd).

You can also pass -Wl,-v to see the linker command line and compare it with
non-LTO compilation (or even native compilation).

Does it work if you pass -fno-builtin-malloc to compilation of t.c?

It looks like without the option, GCC LTO plugin does not see malloc as an
undefined symbol in t.o, the linker does not unpack malloc from libc, and when
LTO plugin passes a new object file that references malloc, it's too late.

I believe linkers had some hacks to help this case (rescanning libc for new
references from LTO object files), but I'm not exactly sure, it's been a while
since I looked at a related area.

Alexander



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux