[PATCH] csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied IRELATIVE relocations [BZ #27164]
Fāng-ruì Sòng
maskray@google.com
Tue Jul 13 23:57:55 GMT 2021
On Tue, Jul 13, 2021 at 4:48 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Jul 13, 2021 at 4:31 PM Fāng-ruì Sòng <maskray@google.com> wrote:
> >
> > On Tue, Jul 13, 2021 at 4:21 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Tue, Jul 13, 2021 at 4:07 PM Fangrui Song via Libc-alpha
> > > <libc-alpha@sourceware.org> wrote:
> > > >
> > > > On 2021-07-13, Siddhesh Poyarekar wrote:
> > > > >On 7/13/21 1:36 PM, Fangrui Song via Libc-alpha wrote:
> > > > >>A toolchain project can do some workaround for a libc if this choice
> > > > >>makes a large community happy. However, I think it is important not to
> > > > >>take it granted. It is inadequate to just dismiss toolchain developers'
> > > > >>reasonable complaints. The libc should actively fix the issues so that
> > > > >>the toolchain will not need to bear unneeded code in the future.
> > > > >>
> > > > >>I actually have contributed quite a few lld/ELF patches to work around
> > > > >>glibc. For this one I just feel it is not right to just patch lld/ELF
> > > > >>without fixing glibc.
> > > > >
> > > > >What's the utility of having the __rela_iplt{_start,_end} symbols in
> > > > >all binaries other than, maybe, simplifying the static linker
> > > > >implementation? How does it improve things for the generated
> > > > >application code in the end? AFAICT it is doing the opposite by
> > > > >requiring application startup to add a conditional to work around the
> > > > >presence of a redundant symbol.
> > > > >
> > > > >Siddhesh
> > > >
> > > > Please see the sentence from the first message
> > > > "In addition, this enables a future simplification to GNU ld: we can
> > > > drop a linker script difference between -no-pie and -pie."
> > >
> > > Did you mean non-PIE static and PIE static? Neither PIE nor PDE
> > > define __rela_iplt{_start,_end}.
> > >
> > > > This is the only difference other than image base difference.
> > >
> > > There are many differences between non-PIE static and PIE static.
> > > Non-PIE static doesn't have DT_XXX sections.
> >
> > % diff -U1 =(ld.bfd --verbose) =(ld.bfd -pie --verbose)
> > --- /tmp/zshEtZMxJ 2021-07-13 16:30:50.228732445 -0700
> > +++ /tmp/zshNM1wJL 2021-07-13 16:30:50.232732450 -0700
> > @@ -12,3 +12,3 @@
> > ==================================================
> > -/* Script for -z combreloc -z separate-code */
> > +/* Script for -pie -z combreloc -z separate-code */
> > /* Copyright (C) 2014-2020 Free Software Foundation, Inc.
> > @@ -24,3 +24,3 @@
> > {
> > - PROVIDE (__executable_start = SEGMENT_START("text-segment",
> > 0x400000)); . = SEGMENT_START("text-segment", 0x400000) +
> > SIZEOF_HEADERS;
> > + PROVIDE (__executable_start = SEGMENT_START("text-segment", 0)); .
> > = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS;
> > .interp : { *(.interp) }
> > @@ -55,5 +55,3 @@
> > *(.rela.plt)
> > - PROVIDE_HIDDEN (__rela_iplt_start = .);
> > *(.rela.iplt)
> > - PROVIDE_HIDDEN (__rela_iplt_end = .);
> > }
>
> Here is the deal:
>
> 1. ld uses the same linker script for both PDE static and PDE. We need
> __rela_iplt{_start,_end} for PDE static. That is why there are
>
> PROVIDE_HIDDEN (__rela_iplt_start = .);
> *(.rela.iplt)
> PROVIDE_HIDDEN (__rela_iplt_end = .);
>
> Since PDE is linked against libc.so which doesn't reference
> __rela_iplt{_start,_end}, these symbols are not defined for PDE.
>
> 2. ld uses the same linker script for both PIE static and PIE. There is
> no need for __rela_iplt{_start,_end}.
>
> Are you suggesting to use the same linker scripts for PDE, PDE static,
> PIE and PIE static?
Because of the image base difference, PDE/PIE linker scripts cannot be
entirely identical,
but symbol differences should be reduced.
BTW: diff -u =(ld.bfd -pie --verbose) =(ld.bfd -shared --verbose) has
some PROVIDE_HIDDEN differences.
Since these symbols are PROVIDE style, these differences are
artificial and should be reduced as well.
More information about the Libc-alpha
mailing list