[PATCH v3 2/5] Make libc symbols hidden in static PIE
Szabolcs Nagy
szabolcs.nagy@arm.com
Fri Jan 15 14:27:38 GMT 2021
The 01/15/2021 05:43, H.J. Lu wrote:
> On Fri, Jan 15, 2021 at 3:25 AM Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> > options:
> >
> > (1) fix extern hidden pie calls on i686 (by making
> > them the same as default vis pie calls so ifuncs
> > work).
> >
> > (2) annotate ifuncs (avoid hidden for them, ifuncs
> > cannot appear in early start code anyway because
> > of IRELATIVE): this can be difficult to maintain.
> >
> > (3) annotate early object accesses to be hidden so
> > RELATIVE relocs are avoided. (most targets want
> > all objects to be hidden, but this solves bug
> > 27072 without causing problems on i686)
> >
> > (4) make pie always use copy relocations on i686.
> > (and then no hidden annotation is needed, object
> > access is always local in pie).
...
> > > --- a/elf/dl-reloc-static-pie.c
> > > +++ b/elf/dl-reloc-static-pie.c
> > > @@ -17,6 +17,7 @@
> > > <https://www.gnu.org/licenses/>. */
> > >
> > > #if ENABLE_STATIC_PIE
> > > +#pragma GCC visibility push(hidden)
> >
> > yes, this is option (3). you will also need it in _dl_aux_init
> > and __libc_init_secure and __tunables_init.
>
> I will try it.
the naive way does not seem to work:
_dl_support.c has _dl_aux_init as well as _dl_non_dynamic_init,
the former needs hidden the latter does not and calls rawmemchr
which is ifunc on i686.
i think the easiest fix is to move those two functions into
separate files. (ideally we would have a small set of files
that are involved in the start code before self relocation)
now i realized that there is another option:
(5) remove all ifuncs from i686 libc.
i assume there are not many users who care about i686 performance.
More information about the Libc-alpha
mailing list