When .debug_gnu_pubnames is absent, gold traverses .debug_info to
extract entities to make up symbol table entries. This patch implements
a subset of it to improve .gdb_index coverage.
Is this test case consistent with gold's behavior? (given this subprogram has no source locations here, for instance - does gold still consider such a simplified DIE to be a thing that should be indexed?)
Also would probably be good to document the differences/incompleteness - what cases does this not cover? (false negatives, where an index entry should be present but isn't - and false positives (index entries that shouldn't be present) & the details of things like the attributes for the entry?)
Yeah, not a problem, this isn't powered by DW_AT_sibling (see https://github.com/llvm-mirror/llvm/blob/master/lib/DebugInfo/DWARF/DWARFUnit.cpp#L695 ). Probably be nice if we changed this sibling based iteration to iterator-based iteration to avoid confusion like this & separate out DIE navigation from DIEs themselves.
Oh, right, we do have such an API & should probably use that here instead:
for (const DWARFDie &Child : D.children()) extractSymbol(Child, Idx, Ret);
Is this test case consistent with gold's behavior?
It does. But I think I need to do more work to understand what gold expects (it may have issues with my other multi-cu tests).
% fllvm-mc -filetype=obj gdb-index-debug-info.s -o t.o % gold --gdb-index t.o -o t.gold % fld.lld --gdb-index t.o -o t.gold % diff <(fllvm-dwarfdump -debug-info t.gold) <(fllvm-dwarfdump -debug-info t.lld) 1c1 < t.gold: file format ELF64-x86-64 --- > t.lld: file format ELF64-x86-64
I'm not sure if this is a good thing to create a half-baked .gdb-index section for an incomplete input. Silently creating a .gdb-index that is not complete could be very confusing. I feel like if we do this, we should do this perfectly. Or we should report an warning and should refuse to create a .gdb-index section.
Can gold create a complete .gdb-index section from object files that don't have .debug_gnu_pubnames sections? What if both .debug_gnu_pubnames and .debug_gnu_pubtypes are absent? (I believe -ggnu-pubnames creates both sections, so it is hard to imagine that an object file contains only one of them though.)
If gold can still create .gdb-index sections from object files compiled without -ggnu-pubnames, then, what is the point of -ggnu-pubnames option?
Yeah, I tend to agree about half-baking this. Though, equally I don't personally mind if this is done incrementally either (but I'm not sure it makes it that much easier to follow compared to implementing an attempt at the full algorithm up-front).
What's the purpose of gnu-pubnames: