[PATCH v3 5/5] csu: Move static pie self relocation later [BZ #27072]
Szabolcs Nagy
szabolcs.nagy@arm.com
Thu Jan 14 17:05:50 GMT 2021
The 01/14/2021 08:01, H.J. Lu wrote:
> On Thu, Jan 14, 2021 at 7:52 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > On Thu, Jan 14, 2021 at 7:49 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > On Tue, Jan 12, 2021 at 2:55 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > (gdb)
> > > 223 DL_SYSDEP_OSCHECK (__libc_fatal);
> > > (gdb)
> > >
> > > Program received signal SIGSEGV, Segmentation fault.
> > > 0xefec0550 in ?? ()
> > > (gdb)
> > >
> > (gdb) si
> > uname () at ../sysdeps/unix/syscall-template.S:120
> > 120 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
> > (gdb) si
> > 0xf7fba3a2 120 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
> > (gdb) si
> > 0xf7fba3a6 120 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
> > (gdb) si
> > 0xf7fba3ab 120 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
> > (gdb) si
> > 0xefec0550 in ?? ()
> > (gdb) disass uname
> > Dump of assembler code for function uname:
> > 0xf7fba3a0 <+0>: mov %ebx,%edx
> > 0xf7fba3a2 <+2>: mov 0x4(%esp),%ebx
> > 0xf7fba3a6 <+6>: mov $0x7a,%eax
> > 0xf7fba3ab <+11>: call *%gs:0x10 <<<<<<<<<<<< This may not be setup yet.
> > 0xf7fba3b2 <+18>: mov %edx,%ebx
> > 0xf7fba3b4 <+20>: cmp $0xfffff001,%eax
> > 0xf7fba3b9 <+25>: jae 0xf7f9efd0 <__syscall_error>
> > 0xf7fba3bf <+31>: ret
> > End of assembler dump.
> > (gdb)
>
> GL(dl_sysinfo) points to the wrong address. This may affect all
> variables accessed
> in _dl_aux_init.
so is GL(dl_sysinfo_*) accessed via a GOT entry which
require relocations or is this some other problem?
it's not clear to me from this description, but
the hidden visibility was added to avoid the GOT problem,
without that it won't work, unless i686 has some
magic to avoid GOT access for extern objects in PIE
(which i thought it might have because of copy relocs).
the solution is to ensure object symbols are hidden
but functions aren't (so functions use the normal PIC
call abi on i686 which is compatible with PIE ifunc)
and hope that there are no extern function address
computations in the early start code.
but i don't see an easy way to do that (other than
maintaining manual annotations either on object or
function declarations).
More information about the Libc-alpha
mailing list