[cfe-dev] Static linking a program

Peter Smith via cfe-dev cfe-dev at lists.llvm.org
Fri Jul 6 07:11:19 PDT 2018


On 5 July 2018 at 21:35, Wink Saville <wink at saville.com> wrote:
> I submitted bug 38074: https://bugs.llvm.org/show_bug.cgi?id=38074

Thanks for raising the bug. I can confirm it is ifunc related. The
__mempcpy function that is being called from _dl_get_origin() should
have been directed to one of the specific implementations by the
__mempcpy_ifunc() resolver that is run as part of __libc_start_main.
The ifunc resolver is being run for the executables linked by gold and
LLD but for LLD the .got entry for the function doesn't appear to have
been updated so the call to _dl_get_origin() erroneously ends up in
the __mempcy_ifunc() resolver again.

This is likely to break all static linking with LLD and recent
versions of glibc as _dl_get_origin is part of the startup code so it
is difficult to avoid. Older versions of glibc have fewer ifuncs so we
are less likely to see the problem although it is theoretically
possible given the right inputs. Dynamic linking will be ok as the
linker that links libc.so.6 is most likely gold or ld.bfd.

Peter



More information about the cfe-dev mailing list