Page MenuHomePhabricator

Add debugger rendezvous DT_DEBUG .dynamic entry
ClosedPublic

Authored by emaste on Dec 24 2015, 11:19 AM.

Details

Summary

The runtime linker may store a pointer to a data structure used by debuggers. This allows gdb and lldb to debug lld-linked binaries.

I can combine it as an else case in the existing if (Config->EMachine == EM_MIPS) block if that's preferred.

Diff Detail

Repository
rL LLVM

Event Timeline

emaste updated this revision to Diff 43611.Dec 24 2015, 11:19 AM
emaste retitled this revision from to Add debugger rendezvous DT_DEBUG .dynamic entry.
emaste updated this object.
emaste added reviewers: ruiu, rafael.
emaste added subscribers: llvm-commits, davide.
emaste updated this revision to Diff 43612.Dec 24 2015, 11:48 AM
  • add test
  • add DT_DEBUG only to executables (use the presence of an entrypoint as a proxy for this)
rafael edited edge metadata.Dec 24 2015, 1:17 PM
rafael added a subscriber: rafael.

Why is mips special?

Why is mips special?

MIPS's .dyanamic section is read-only. Instead of using DT_DEBUG for the pointer to dyld information it uses a separate tag DT_MIPS_RLD_MAP which points to storage in the read-write .rld_map section, which in turn points to the dyld information.

I added the support for DT_MIPS_RLD_MAP in D1890 which has some more background.

That is pretty horrible. Any chance we could start producing a rw dynamic
section on MIPS too? With that we could at least hope for one day dropping
the MIPS specific field.

That is pretty horrible. Any chance we could start producing a rw dynamic
section on MIPS too? With that we could at least hope for one day dropping
the MIPS specific field.

DT_MIPS_RLD_MAP is specified in the ABI and a migration would be a long process, but it shouldn't hurt anything to emit DT_DEBUG in MIPS binaries too. GNU ld did so until relatively recently. I'm happy to go ahead with or without the Config->EMachine != EM_MIPS.

I would much prefer without. Thanks.

emaste updated this revision to Diff 43628.Dec 25 2015, 4:59 AM
emaste edited edge metadata.

Drop MIPS special-case; DT_DEBUG is not currently used on MIPS but it doesn't hurt anything to leave the entry there either.

davide added inline comments.Dec 26 2015, 7:40 AM
test/ELF/dt_tags.s
1 ↗(On Diff #43628)

Is this really required now?

Ignore my previous comment, I missed the triple bit. This looks fine to me.

emaste added inline comments.Dec 26 2015, 11:26 AM
test/ELF/dt_tags.s
1 ↗(On Diff #43628)

I think it is, based on the -triple below, but I'm not an expert in the way the tests are set up. Most other tests have it, or e.g. REQUIRES: x86,ppc for tests that use both x86 & ppc triples.

grimar added a subscriber: grimar.Dec 26 2015, 1:20 PM

@ruiu or @rafael, ok with this version?

emaste planned changes to this revision.Dec 27 2015, 7:27 AM

Other tests need updating for this change - I'll upload a new version next week.

emaste updated this revision to Diff 43741.Dec 29 2015, 9:42 AM

Update existing tests for growth in .dynamic section

emaste added inline comments.Dec 29 2015, 9:44 AM
test/ELF/dt_tags.s
10 ↗(On Diff #43741)

Note that this is also implicitly tested in dynamic-relocs.s

14 ↗(On Diff #43741)

However I believe this is not tested elsewhere

ruiu accepted this revision.Jan 5 2016, 9:19 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 5 2016, 9:19 AM
This revision was automatically updated to reflect the committed changes.