[cfe-dev] Static linking a program
Peter Smith via cfe-dev
cfe-dev at lists.llvm.org
Thu Jul 5 02:11:44 PDT 2018
On 4 July 2018 at 23:20, Wink Saville via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Executive summary: In _dl_get_origin lld is linking a call to mempcpy which
> I'd call "thunking code" as it returns in rax the address of the code
> that should be called instead of the address of the next available
> address of the
> destination buffer. And specifically, since rax is pointing at code, when a zero
> is stored to try to terminate the string we seg fault.
> I'd be glad to file a bug if you like.
I think that would be the best idea. As Rui suggested earlier it would
be helpful to add -Wl,--reproduce=repro.tar so that all the libraries
are included. My suspicion here is that this is related to a newer
version of libc.a as I can't reproduce a crash on my Ubuntu 16.04
machine. Looking at an annotate of some of the glibc source it looks
like indirect functions (ifunc) have been used with __mempcpy have
been added relatively recently. The ifunc resolution mechanism is not
particularly well documented so it is possible that there is a case
that LLD isn't handling as expected.
Unfortunately I can't tell much from the disassembly of the final
image about what the linker has got wrong. We really need to see the
input objects and how LLD and Gold differ in the resolution of symbols
and relocations to work that out.
Sorry I can't be of much more help here.
More information about the cfe-dev