This patch helps add support for emitting the .debug_gnu_pubnames and .debug_gnu_pubtypes sections.
The .debug_gnu_pub* sections is verified by llvm-dwarfdump.
Known issues:
- Doesn't support emitting multiple pub-tables.
Differential D82367
[ObjectYAML][ELF] Add support for emitting the .debug_gnu_pubnames/pubtypes sections. Higuoxing on Jun 23 2020, 4:36 AM. Authored by
Details This patch helps add support for emitting the .debug_gnu_pubnames and .debug_gnu_pubtypes sections. The .debug_gnu_pub* sections is verified by llvm-dwarfdump. Known issues:
Diff Detail
Event TimelineComment Actions My understanding of the .debug_gun_pubnames table is that it is a slightly different format to the .debug_pubnames table. The output of yaml2obj here is not consistent with the parsing code for GNU style, as far as I can tell, because of this and the bug you mentioned. I don't think we should add support for the section unless it is actually formatted correctly, as it is likely to cause confusion, should anybody attempt to use it in its seemingly-working-but-broken state. Comment Actions LGTM, with one suggestion.
Comment Actions Is ".debug_gnu_pubtypes" different and/or better than the old ".debug_pubtypes" in terms of contents? AFAIK all debuggers completely ignore these sections as they don't contain all types (only public types). I did a quick web search for ".debug_gnu_pubtypes" and didn't find any docs or anything documenting this format. Comment Actions My general understanding is that GCC/GDB folks implemented .debug_gnu_pubnames(/types) because of the lack of guarantees in debug_pubnames(/types) - GCC does consume/rely on these sections (& gold can produce .gdb_index from these gnu_pub* sections - which is /necessary/ for correctness of gdb when using Split DWARF, in fact). I'm guessing like lots of stuff, it's probably basically defined by the agreement between GCC and GDB - and Clang/LLVM just tries to implement gnu_pub* to be as compatible as possible with that. Comment Actions Was there any documentation on this where the contents of this new format are detailed? Sounds promising and I would love to have LLDB to not have to manually index DWARF on all linux/android targets if at all possible. Comment Actions The GCC doc mentions that the "-ggnu-pubnames" option is only useful with a linker that can produce GDB@ index version 7. @item -ggnu-pubnames @opindex ggnu-pubnames Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format suitable for conversion into a GDB@ index. This option is only useful with a linker that can produce GDB@ index version 7. See: https://raw.githubusercontent.com/gcc-mirror/gcc/master/gcc/doc/invoke.texi (This file is large, searching key word "ggnu-pubnames" may help) Comment Actions Not that I know of.
Presumably LLDB should probably be looking at the newer .debug_names format that's been standardized/documented, and derived from the apple names accelerator tables. Comment Actions We have support already and we do look at that. Not many compilers enable DWARF5 at the moment, so we rarely see the .debug_names in any binaries, but LLDB is ready for these. It is hard to control and change the toolchains that people build with. My idea was to write a post processing tool that can add the .debug_names to binaries, like maybe llvm-objcopy or other tool. Comment Actions Yep, a post-processing tool to add .debug_names could be nice. Given folks have to add extra flags to get gnu (or non-gnu) pubnames (-ggnu-pubnames in both GCC and Clang) with GCC and Clang - they could instead switch to DWARFv5 "just as easily" (not quite, but close) - though certainly the ecosystem issues if they need to support tools that can't consume DWARFv5, etc. (perhaps .debug_names could be supported in pre-v5 modes as a backwards/partial compatibility mode - rather than having to produce gnu_pubnames) Though producing gnu_pubnames/plain pubnames and linking those into .debug_names in the linker wouldn't be a bad thing to support either (though maybe has the problem of "this doesn't have all the names it needs to have" which is the general problem with all this). |
Should this be tested via llvm-dwarfdump instead? (perhaps there's already lots of precedent/reasons that yaml2obj is being tested via readobj?)