Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOL] Debug sections relocations #32

Conversation

jawilk
Copy link

@jawilk jawilk commented Apr 15, 2022

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 the ELF::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 within BPFELFObjectWriter::getRelocType() so I had to resort to the ELFObjectWriter.cpp file. I am not sure if this is acceptable since this is a more general ObjectWriter 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 in solana-labs/rust to discard it) also have ELF::R_BPF_64_ABS64 relocations. The fix is identifying all .debug_* sections and emitting ELF::R_BPF_64_ABS64 only for them. This check could be made more explicit with

FixupSection.getName().startswith(".debug_")

instead of

!(Flags & ELF::SHF_ALLOC)

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 complete DWARF info which I could load successfully into gdb.

@jawilk jawilk changed the title Debug sections relocations [SOL] Debug sections relocations Apr 15, 2022
@jawilk jawilk force-pushed the debug-sections-relocations branch from e0ead09 to 7e85bb5 Compare April 15, 2022 16:03
…relocations to lld

Co-Authored-By: Richard Patel <richard@blockdaemon.com>

[SOL] emit R_BPF_64_{ABS64, ABS32} for .debug_* sections
@jawilk jawilk force-pushed the debug-sections-relocations branch from 7e85bb5 to 08106ce Compare April 20, 2022 17:24
@dmakarov dmakarov merged commit 672d5f8 into anza-xyz:solana-rustc/13.0-2021-09-30 Apr 21, 2022
@jawilk jawilk deleted the debug-sections-relocations branch May 25, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants