[llvm] [LLVM][DWARF] Add support for .gnu_debuglink (PR #77715)

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 14:51:12 PST 2024


================
@@ -127,6 +127,9 @@ class DWARFContext : public DIContext {
 
   std::unique_ptr<const DWARFObject> DObj;
 
+  /// Binary containing debug information after objcopy --only-keep-debug
+  object::OwningBinary<object::ObjectFile> GnuLink;
----------------
mysterymath wrote:

> Presumably that's what debuginfod support does too? (well, one way or another - as you say, perhaps underspecified for all these different flavors of split/partial binaries, etc - for now, I guess debuginfod support is retrieving the whole unstripped binary, so it's strictly better/more complete than the case being supported here with debuglink - but that points to, even more, that they could use the same path in this case (because the path is good enough for debuglink to only-keep-debug, so it's certainly fine to use that path for the more complete whole-unstripped-binary case for debuginfod))

What I ended up doing for debuginfod is kind-of situational; generally the tools that can invoke debuginfod look for debug info in the binaries that are directly available to them, but failing that, they retrieve the debug binary and then use it just for its DWARF. For tools that only operate on DWARF, the fetched binary can replace the original, but for other tools, the DWARF that the tool analyzes may be loaded from a different binary than the one the rest of the tool operates on.

Last time I checked (and if I understand their code correctly), the GNU implementation handles this in a more centralized way; both debuglink sections and debuginfod lookups can provide additional auxiliary sections that get tacked on to a binary. (Unfortunately I don't remember the precise semantics of this.) Something that can merge sections like this would be the best of both worlds, since it would produce an uber-image that could be passed around trivially. But I didn't see a straightforward way to do this in LLVM.

https://github.com/llvm/llvm-project/pull/77715


More information about the llvm-commits mailing list