-
Notifications
You must be signed in to change notification settings - Fork 521
Added support for symbol relocation for RISC-V architecture #613
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
base: main
Are you sure you want to change the base?
Added support for symbol relocation for RISC-V architecture #613
Conversation
@eliben Can you take a look at this? |
@sevaa any concerns? |
Looks in line with how relocation is handled for other architectures. Is there any way to test this? |
Would it be enough to just provide arbitrary elf that uses RISCV relocations and just to add it to testfiles or those elfs have some specific content? @sevaa |
An erroneously written piece of relocation logic most likely will not crash; it will produce wrong bits in the loaded section. How does one test that? |
Ideally, we can create elf that uses RISCV relocations with some functions/variables and if we are able to find those symbols relocations are working properly, but I don't think it is practical to test every sing one relocation type. Everything that is implemented is taken from here: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#reloc-table |
If @eliben says it's OK not to test this exhaustively, I will be OK with that :) |
@adjordjevic-TT can you say what you're using these RISC-V relocations for? (in other words, why this PR?) @sevaa several of the readelf comparison tests rely on correct implementation of relocations. Wouldn't a file compiled for RISC-V with relocations inside therefore exercise this logic? |
We are using it for finding variable's address or value and for implementing backtracing (callstack) for kernels that are running on our hardware that is based on RISCV arch. |
@adjordjevic-TT could you add a simple unit test? Look at the other unit tests in the |
The only sections that are parsed, dumped, and compared by the readelf test are the DWARF ones and notes; in executable/SO binaries, relocations against those are rare (none in the corpus, last time I checked). Were we to dump and compare the disassembly, though, or the initialized global data section, that would be the test. |
Let's continue this discussion in #601 |
Added support for symbol relocation for RISC-V architecture.
Added ENUM_RELOC_TYPE_RISCV to enums.py
Added _RELOCATION_RECIPES_RISCV, two more relocation functions (_reloc_calc_value_plus_sym_6 and _reloc_calc_value_minus_sym_addend_6) and case when e-machine is RISC-V to relocation.py.