Re: Using DW_TAG_imported_unit for eliminating discarded section DWARF info

Tom Tromey <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
>>>>> "Senthil" == Senthil Kumar Selvaraj <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.