This is the mail archive of the
mailing list for the binutils project.
RE: [MIPS] Check info->executable to create DT_MIPS_RLD_MAP
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Chao-Ying Fu <Chao-Ying dot Fu at imgtec dot com>
- Cc: 'David Daney' <ddaney dot cavm at gmail dot com>, 'Richard Sandiford' <rdsandiford at googlemail dot com>, <binutils at sourceware dot org>
- Date: Mon, 24 Jun 2013 15:56:23 +0100
- Subject: RE: [MIPS] Check info->executable to create DT_MIPS_RLD_MAP
- References: <81D57523CB07B24881D63DE650C6ED82018D72B7 at BADAG02 dot ba dot imgtec dot org> <51C4ED0A dot 9010401 at gmail dot com> <81D57523CB07B24881D63DE650C6ED82018D7324 at BADAG02 dot ba dot imgtec dot org> <alpine dot LFD dot 2 dot 03 dot 1306220138240 dot 29828 at linux-mips dot org>
I failed to cc the binutils list with my reply for some reason, so here
it is again, with a further note.
On Sat, 22 Jun 2013, Maciej W. Rozycki wrote:
> On Sat, 22 Jun 2013, Chao-Ying Fu wrote:
> > David Daney wrote:
> > > > When using "-pie", LD doesn't create the DT_MIPS_RLD_MAP entry,
> > > > because LD checks "!info->shared" and the "-pie" flag sets
> > > "info->shared" to true.
> > > > Note that LD checks "info->executable" to create DT_DEBUG, and
> > > > creating DT_MIPS_RLD_MAP should be similar to creating DT_DEBUG.
> > > > Ex:
> > > > /* SGI object has the equivalence of DT_DEBUG in the
> > > > DT_MIPS_RLD_MAP entry. This must come first because glibc
> > > > only fills in DT_MIPS_RLD_MAP (not DT_DEBUG) and
> > > some tools
> > > > may only look at the first one they see. */
> > > > if (!info->shared
> > > > && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info,
> > > DT_MIPS_RLD_MAP, 0))
> > > > return FALSE;
> > > >
> > >
> > > Probably you want info->executable here too.
> > >
> > > I have tried simple programs with -pie and they seem to work as is.
> > > What failures are you seeing? Does the libgcc unwinder use this?
> David, just as the comments say -- these tags are used by debuggers and
> both GDB (in the native mode) and gdbserver make use of them. The
> comments also explain why DT_DEBUG is not sufficient (on the
> MIPS/Linux/glibc target) and getting DT_MIPS_RLD_MAP right is important.
> > I hit an issue in gdbserver that fails to return a shared-library list,
> > because gdbserver tries to find the DT_MIPS_RLD_MAP entry from
> > a program that is built with -pie.
> Chao-ying, your consideration appears right to me, please offer a patch.
Please make sure ld.so handles it correctly first though as I suspect it
may segfault. The thing is in a PIE the segment containing the word
pointed to by DT_MIPS_RLD_MAP may get mapped to an arbitrary memory area
and it does not immediately appear to me that ld.so relocates the value of
the DT_MIPS_RLD_MAP tag by the base address, which it has to if it wants
to use it (it may be enough to add l->l_addr to the value retrieved in
ELF_MACHINE_DEBUG_SETUP). But perhaps I'm missing something here.