[PATCH 0/1] gold: Avoid duplicate PLT stub symbols on PowerPC
James Clarke
jrtc27@jrtc27.com
Sun Jun 18 21:58:00 GMT 2017
If two objects are compiled with -fPIC or -fPIE and call the same
function, two different PLT stubs are created, one for each object, but
the same stub symbol name is used for both. For example:
> (sid_powerpc-dchroot)jrtc27@redpanda:~$ cat test.c
> #include <stdio.h>
>
> extern void f(void);
>
> int main(int argc, char **argv) {
> printf("Main\n");
> f();
> return 0;
> }
> (sid_powerpc-dchroot)jrtc27@redpanda:~$ cat f.c
> #include <stdio.h>
>
> void f(void) {
> printf("f\n");
> }
> (sid_powerpc-dchroot)jrtc27@redpanda:~$ gcc -pie -fPIE -fuse-ld=gold -o test test.c f.c
> /usr/bin/ld.gold: error: invalid STB_LOCAL symbol in external symbols
> /usr/bin/ld.gold: error: linker defined: multiple definition of '00000001.plt_call.puts+8000'
> /usr/bin/ld.gold: command line: previous definition here
> collect2: error: ld returned 1 exit status
It seems BFD just ignores the issue, and will only add the symbol the
first time. I first wrote a patch to do that, but it struck me that this
might be nicer, as from what I can tell there is no guarantee that the
PLT stubs for the same symbol are next to each other so you cannot
easily tell the symbol for any of the subsequent PLT stubs. If you would
rather stick to mirroring BFD in this respect (even though the names
themselves are already different), however, I can submit that instead.
James Clarke (1):
gold: Avoid duplicate PLT stub symbols on PowerPC
gold/powerpc.cc | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
--
2.13.1
More information about the Binutils
mailing list