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] re-enable debug info on SBF #25

Conversation

riptl
Copy link

@riptl riptl commented Feb 14, 2022

Set SupportsDebugInformation to true for sbf.

@riptl
Copy link
Author

riptl commented Feb 14, 2022

There's probably a good reason why this was disabled in the first place. I've tested it with a C program and it works fine though.

@riptl
Copy link
Author

riptl commented Feb 14, 2022

Aha! ld.lld: error: canvas.c:(.BTF.ext+0xC0): unrecognized reloc R_BPF_64_NODYLD32

sbf/bpfel+solana doesn't support the R_BPF_64_NODYLD32 reloc required for BPF Type Format section. Looks like an easy fix though.

@riptl riptl marked this pull request as draft February 14, 2022 12:17
@riptl
Copy link
Author

riptl commented Feb 14, 2022

Another problem is this

https://github.com/solana-labs/llvm-project/blob/321d9c077f20a571f3ec7ba4513b78e7ccf13a71/llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp#L97

This corrupts all relocs in the .rel.debug_line section, which need to be R_BPF_64_ABS32.

I patched that section by hand and got a working Solana .so program with full DWARF info and even a copy of the C source code included in the BTF section. 😃

@riptl riptl marked this pull request as ready for review February 15, 2022 00:13
@riptl
Copy link
Author

riptl commented Feb 15, 2022

Debug section relocs work now, @dmakarov would you mind taking a look?

@dmakarov
Copy link
Collaborator

Looks good, but I'll run a few more tests before I can merge this.

@riptl
Copy link
Author

riptl commented Feb 15, 2022

Thanks – one thing I was concerned about was relocs in the .rodata section. I've yet to test them, I hope I didn't break them.

@dmakarov
Copy link
Collaborator

I get the relocation error when a program is loaded to RBPF

ELF error: Relocation failed, unknown type 2

Pretty much all our tests fail with this change.

If you want to test this, build solana-labs/rust with the src/llvm-project submodule updated to include your changes. Once you have the rust compiler binaries, make a symbolic link rust in ~/.cache/solana/v1.23/bpf-tools/ to point to stage1/ subdir in your build of rust ( rust/build/x86_64-apple-darwin/stage1) and then run

cargo test --features="bpf_c,bpf_rust" -- --nocapture --test-threads=1

in solana-labs/solana/programs/bpf

@riptl
Copy link
Author

riptl commented Feb 23, 2022

Thanks for verifying, I will investigate this further then. The solution is probably to only use the R_BPF_64_ABS32 relocs for debug sections and otherwise the R_BPF_64_32 variant.

@riptl
Copy link
Author

riptl commented Apr 15, 2022

Moved over to #32

@riptl riptl closed this Apr 15, 2022
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.

None yet

2 participants