This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0/1] gold: Avoid duplicate PLT stub symbols on PowerPC

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/ error: invalid STB_LOCAL symbol in external symbols
> /usr/bin/ error: linker defined: multiple definition of '00000001.plt_call.puts+8000'
> /usr/bin/ 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/ | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]