Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an expansion of #25
I was discussing with @terorie how we might get complete debug info back in.
After inspecting some objdumps I found
ELF::R_BPF_64_ABS32
relocations in.debug_*
sections only reference relocatable symbols in other.debug_*
sections (mostly.debug_{str, abbrev, frame}
). So these can be filtered by checking the absence of theELF::SHF_ALLOC
flag in the target symbol's section header.ELF::R_BPF_64_ABS64
in.debug_*
sections reference symbols in the.text
section and I couldn't find a fix withinBPFELFObjectWriter::getRelocType()
so I had to resort to theELFObjectWriter.cpp
file. I am not sure if this is acceptable since this is a more generalObjectWriter
used by other Archs as well.The tests in #25 failed because in the final shared object
.data.rel.ro
(and.eh_frame
before the recent commit insolana-labs/rust
to discard it) also haveELF::R_BPF_64_ABS64
relocations. The fix is identifying all.debug_*
sections and emittingELF::R_BPF_64_ABS64
only for them. This check could be made more explicit withFixupSection.getName().startswith(".debug_")
instead of
if needed in this line
https://github.com/jawilk/llvm-project/blob/e0ead099cacad6535137b94a5b9fb9880eb4c43a/llvm/lib/MC/ELFObjectWriter.cpp#L1461
After these changes the tests in
solana-labs/solana/programs/bpf
passed for me and I got completeDWARF
info which I could load successfully intogdb
.