Add the necessary definitions for RISC-V ELF files, including relocs. Also make necessary trivial change to ELFYaml, llvm-objdump, and llvm-readobj in order to work with RISC-V ELFs.
Diff Detail
Event Timeline
Confirmed EM_RISCV and relocations against https://sourceforge.net/p/elftoolchain/code/HEAD/tree/trunk/common/elfdefinitions.h (except that R_RISCV_RVC_LUI, ELF_RELOC(R_RISCV_GPREL_I, ELF_RELOC(R_RISCV_GPREL_S not yet added there).
Aside, it's unfortunate that ElfMachineType has a mix of "friendly" names and verbatim EM_* constants.
include/llvm/Support/ELFRelocs/RISCV.def | ||
---|---|---|
1 | Please insert copyrights header. See other .def files as example. |
include/llvm/Support/ELFRelocs/RISCV.def | ||
---|---|---|
1 | Hi Eugene, I've actually followed the lead of all the other include/llvm/Support/ELFRelocs/*.def files in this case, none of which contain a copyright header in the current llvm HEAD. You're right that other .def files elsewhere in the tree seem to have such a header. |
I guess the relocation types aren't actually documented anywhere? The elftoolchain source code is the canonical location?
At least, I've not seen any RISCV ELF psABI supplement. If there isn't any such thing, someone really ought to start writing one ASAP.
I guess the relocation types aren't actually documented anywhere? The elftoolchain source code is the canonical location?
It is not. I asked about a canonical list on the RISC-V sw-dev list but one did not exist. The best source I had was:
We haven't written up a full ABI description, but you can find the
reloc listing here:https://github.com/riscv/riscv-gnu-toolchain/blob/master/binutils/include/elf/riscv.h
Although it's now a dead link.
FWIW, https://github.com/riscv/riscv-binutils-gdb/blob/riscv-binutils-2.27/include/elf/riscv.h seems to be the current location for your link.
I've not checked the relocations against the ABI doc, but assuming that they're correct it all looks good to me.
Please insert copyrights header. See other .def files as example.