diff mbox

sparc-linux-user: Fix missing symbols in .rel/.rela.plt sections

Message ID 1325967416-1760-1-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno Jan. 7, 2012, 8:16 p.m. UTC
Fix .rel.plt sections in the output to not only include .rel.plt
sections from the input but also the .rel.iplt sections and to define
the hidden symbols __rel_iplt_start and __rel_iplt_end around
.rel.iplt as otherwise we get undefined references to these when
linking statically to a multiarch enabled libc (using STT_GNU_IFUNC).

Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 sparc.ld |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

Comments

Blue Swirl Jan. 7, 2012, 8:36 p.m. UTC | #1
On Sat, Jan 7, 2012 at 20:16, Aurelien Jarno <aurelien@aurel32.net> wrote:
> Fix .rel.plt sections in the output to not only include .rel.plt
> sections from the input but also the .rel.iplt sections and to define
> the hidden symbols __rel_iplt_start and __rel_iplt_end around
> .rel.iplt as otherwise we get undefined references to these when
> linking statically to a multiarch enabled libc (using STT_GNU_IFUNC).
>
> Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  sparc.ld |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/sparc.ld b/sparc.ld
> index 56efe34..e52c3d2 100644
> --- a/sparc.ld
> +++ b/sparc.ld
> @@ -37,8 +37,20 @@ SECTIONS
>   .rela.fini     : { *(.rela.fini)      }
>   .rel.bss       : { *(.rel.bss)                }
>   .rela.bss      : { *(.rela.bss)               }
> -  .rel.plt       : { *(.rel.plt)                }
> -  .rela.plt      : { *(.rela.plt)               }
> +  .rel.plt      :
> +  {
> +    *(.rel.plt)
> +    PROVIDE_HIDDEN (__rel_iplt_start = .);
> +    *(.rel.iplt)
> +    PROVIDE_HIDDEN (__rel_iplt_end = .);
> +  }
> +  .rela.plt       :
> +  {
> +    *(.rela.plt)
> +    PROVIDE_HIDDEN (__rela_iplt_start = .);
> +    *(.rela.iplt)
> +    PROVIDE_HIDDEN (__rela_iplt_end = .);
> +  }

PROVIDE_HIDDEN etc. were removed by
8733f6093c2b77502e7228503fc22024e51599b8 in order to support BSDs with
older binutils (2.15). Maybe the ld scripts should be generated from a
source file for example with CPP, so these lines could be tweaked.

Doesn't guest base make the whole ld script thing useless? It's not
implemented for Sparc though.

>   .init          : { *(.init)   } =0x47ff041f
>   .text      :
>   {
> --
> 1.7.7.3
>
>
Aurelien Jarno Jan. 7, 2012, 9:01 p.m. UTC | #2
On Sat, Jan 07, 2012 at 08:36:12PM +0000, Blue Swirl wrote:
> On Sat, Jan 7, 2012 at 20:16, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > Fix .rel.plt sections in the output to not only include .rel.plt
> > sections from the input but also the .rel.iplt sections and to define
> > the hidden symbols __rel_iplt_start and __rel_iplt_end around
> > .rel.iplt as otherwise we get undefined references to these when
> > linking statically to a multiarch enabled libc (using STT_GNU_IFUNC).
> >
> > Blue Swirl <blauwirbel@gmail.com>
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > ---
> >  sparc.ld |   16 ++++++++++++++--
> >  1 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/sparc.ld b/sparc.ld
> > index 56efe34..e52c3d2 100644
> > --- a/sparc.ld
> > +++ b/sparc.ld
> > @@ -37,8 +37,20 @@ SECTIONS
> >   .rela.fini     : { *(.rela.fini)      }
> >   .rel.bss       : { *(.rel.bss)                }
> >   .rela.bss      : { *(.rela.bss)               }
> > -  .rel.plt       : { *(.rel.plt)                }
> > -  .rela.plt      : { *(.rela.plt)               }
> > +  .rel.plt      :
> > +  {
> > +    *(.rel.plt)
> > +    PROVIDE_HIDDEN (__rel_iplt_start = .);
> > +    *(.rel.iplt)
> > +    PROVIDE_HIDDEN (__rel_iplt_end = .);
> > +  }
> > +  .rela.plt       :
> > +  {
> > +    *(.rela.plt)
> > +    PROVIDE_HIDDEN (__rela_iplt_start = .);
> > +    *(.rela.iplt)
> > +    PROVIDE_HIDDEN (__rela_iplt_end = .);
> > +  }
> 
> PROVIDE_HIDDEN etc. were removed by
> 8733f6093c2b77502e7228503fc22024e51599b8 in order to support BSDs with
> older binutils (2.15). Maybe the ld scripts should be generated from a
> source file for example with CPP, so these lines could be tweaked.
> 

It seems this patch was in my local tree for too long, and it seems I
should have updated it before sending it...

Other architectures are now using PROVIDE instead of PROVIDE_HIDDEN for 
__rel{a,}_iplt_{start,end}, so I guess the same can be done for sparc and
ppc. I am going to do a test build to check that, and I'll come with a
new patch if it works.
diff mbox

Patch

diff --git a/sparc.ld b/sparc.ld
index 56efe34..e52c3d2 100644
--- a/sparc.ld
+++ b/sparc.ld
@@ -37,8 +37,20 @@  SECTIONS
   .rela.fini     : { *(.rela.fini)      }
   .rel.bss       : { *(.rel.bss)                }
   .rela.bss      : { *(.rela.bss)               }
-  .rel.plt       : { *(.rel.plt)                }
-  .rela.plt      : { *(.rela.plt)               }
+  .rel.plt      :
+  {
+    *(.rel.plt)
+    PROVIDE_HIDDEN (__rel_iplt_start = .);
+    *(.rel.iplt)
+    PROVIDE_HIDDEN (__rel_iplt_end = .);
+  }
+  .rela.plt       :
+  {
+    *(.rela.plt)
+    PROVIDE_HIDDEN (__rela_iplt_start = .);
+    *(.rela.iplt)
+    PROVIDE_HIDDEN (__rela_iplt_end = .);
+  }
   .init          : { *(.init)   } =0x47ff041f
   .text      :
   {