This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Using DW_TAG_imported_unit for eliminating discarded section DWARF info
- From: Tom Tromey <tromey at redhat dot com>
- To: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- Cc: <gdb at sourceware dot org>
- Date: Mon, 13 Jan 2014 10:50:54 -0700
- Subject: Re: Using DW_TAG_imported_unit for eliminating discarded section DWARF info
- Authentication-results: sourceware.org; auth=none
- References: <20140109120818 dot GB15654 at atmel dot com>
>>>>> "Senthil" == Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> writes:
Senthil> The DWARF 4 standard (section E.3.3) suggests using
Senthil> DW_TAG_imported_unit (together with section groups) to
Senthil> generate per function DWARF information in a way that's
Senthil> suitable for the linker to discard unused functions. My
Senthil> understanding of the standard is that there is one CU
Senthil> containing a DW_TAG_imported_unit generated for each
Senthil> subprogram, with the DW_AT_import attribute pointing to the
Senthil> "main" CU that contains file level declarations and
Senthil> definitions.
Yeah, I agree, DWARF says that is possible.
Senthil> However, I don't see gdb supporting usage of the tag for this
Senthil> purpose - I only see it being used for referring *to* other
Senthil> units from a DW_TAG_compile_unit, not the other way
Senthil> around. Is my finding correct, or am I missing something?
We implemented the current scheme because it fits what "dwz" emits. At
the time nothing else emitted DW_TAG_imported_unit, and I did not want
to implement something I had no reasonable way to test.
Senthil> FWIW, I managed to hack GCC into generating the following
Senthil> DWARF output if -ffunction-sections is turned on. gdb treats
Senthil> the CUs at offset 0x31 and 0x66 as full fledged CUs though,
Senthil> and eventually crashes when trying to resolve main
Senthil> (psymtab->symtab = NULL for the CU containing main).
I think it's fine to implement this if you want.
Tom