public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/1] gold: Avoid duplicate PLT stub symbols on PowerPC
@ 2017-06-18 21:58 James Clarke
  2017-06-18 21:58 ` [PATCH 1/1] " James Clarke
  0 siblings, 1 reply; 7+ messages in thread
From: James Clarke @ 2017-06-18 21:58 UTC (permalink / raw)
  To: binutils; +Cc: James Clarke

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-20  5:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-18 21:58 [PATCH 0/1] gold: Avoid duplicate PLT stub symbols on PowerPC James Clarke
2017-06-18 21:58 ` [PATCH 1/1] " James Clarke
2017-06-19  3:04   ` Alan Modra
2017-06-19  3:14     ` Alan Modra
2017-06-19 11:08       ` James Clarke
2017-06-20  0:29         ` Alan Modra
2017-06-20  5:12           ` James Clarke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).