This is the mail archive of the
mailing list for the binutils project.
[RFC][MIPS] What to do about DT_MIPS_RLD_MAP and PIE
- From: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: "macro at codesourcery dot com" <macro at codesourcery dot com>, "Joseph Myers (joseph at codesourcery dot com)" <joseph at codesourcery dot com>, Richard Sandiford <rdsandiford at googlemail dot com>, "Moore, Catherine (Catherine_Moore at mentor dot com)" <Catherine_Moore at mentor dot com>, Nikola Veljkovic <Nikola dot Veljkovic at imgtec dot com>
- Date: Wed, 22 Oct 2014 16:20:11 +0000
- Subject: [RFC][MIPS] What to do about DT_MIPS_RLD_MAP and PIE
- Authentication-results: sourceware.org; auth=none
Referring back to a 2013 thread about PIE and DT_MIPS_RLD_MAP:
As far as I can tell this thread went dormant and no changes were
made in either binutils or glibc relating to position independent
executables and the debug pointer for shared libraries.
The specific reason for being interested in PIE is that Android
executables are all PIE. There are out-of-tree binutils patches
to allow Android to use the DT_DEBUG entry along with a writable
dynamic segment instead of DT_MIPS_RLD_MAP. I'd like to find a
way to fix this in FSF sources such that Android no longer needs
patches to binutils. Both options of using DT_MIPS_RLD_MAP or
DT_DEBUG are probably OK for Android but we need to determine
the least problematic solution.
Currently binutils will not emit a DT_MIPS_RLD_MAP entry for PIE
as the condition for emitting this is '!shared' rather than
'executable'. If binutils were to start emitting DT_MIPS_RLD_MAP
for PIE then ld.so (and GDB) would need to calculate the real
address of the debug pointer by adding the base of the executable
to the offset in the DT_MIPS_RLD_MAP entry. This is possible
but will result in new PIE binaries crashing ld.so as the value
of DT_MIPS_RLD_MAP is dereferenced directly.
Realistically I don't think there is any way to avoid this crash
if we start emiting DT_MIPS_RLD_MAP for PIE. So we either have
to take that as a known issue (and do the work in ld.so
and gdb/gdbserver to account for PIE) OR we choose to define
the ABI for MIPS PIE to use DT_DEBUG instead of DT_MIPS_RLD_MAP
and allow the dynamic section to be writable for PIE (and only
PIE). The dynamic linker logic would be to fill out
DT_MIPS_RLD_MAP if it is present and iff not then fill out
DT_DEBUG if it is present. GDB probably wouldn't need any
changes but I didn't check in detail.
There's work to do either way but which one is 'better'?