Symbol lookup failure with copy relocations

There's a report in of a symbol lookup issue during
expression parsing. The sample code has a global variable 'a' in a
shared library that's also accessed by the main executable. When I
first saw the PR I thought it might be caused by incorrect debug data;
both LLDB and GDB show the same behaviour, and FreeBSD does have a
rather old version of the GNU toolchain.

I finally had a chance to look at it in detail yesterday. What's
happening is that the symbol actually ends up located in the main
executable, which gains a copy relocation (R_X86_64_COPY). The
runtime linker copies the data from the shared library into the
executable, and the space in the shared library is unused from then
on. The shared library's debug data refers to this now-unused copy,
which is what LLDB finds during expression parsing.

I guess we'll have to build a list of copy relocations while
processing the main executable, and then apply them during subsequent
shared library parsing.

I'm not sure how or if this is done on OS X. Does the same issue exist there?

I just checked with the local linker experts and no, we do not have this issue on MacOSX.