Page MenuHomePhabricator

[RISCV 2/10] Add RISC-V ELF defines
ClosedPublic

Authored by asb on Aug 16 2016, 8:20 AM.

Details

Summary

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

asb updated this revision to Diff 68184.Aug 16 2016, 8:20 AM
asb retitled this revision from to [RISCV 2/10] Add RISC-V ELF defines.
asb updated this object.
asb added reviewers: theraven, jyknight.
asb added a subscriber: llvm-commits.
emaste accepted this revision.Aug 16 2016, 2:41 PM
emaste added a reviewer: emaste.
emaste added a subscriber: emaste.

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.

This revision is now accepted and ready to land.Aug 16 2016, 2:41 PM
Eugene.Zelenko added inline comments.
include/llvm/Support/ELFRelocs/RISCV.def
1

Please insert copyrights header. See other .def files as example.

asb added inline comments.Aug 17 2016, 12:14 AM
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.

jyknight accepted this revision.Aug 17 2016, 12:12 PM
jyknight edited edge metadata.

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).

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.

theraven accepted this revision.Aug 26 2016, 6:03 AM
theraven edited edge metadata.

I've not checked the relocations against the ABI doc, but assuming that they're correct it all looks good to me.

asb closed this revision.Nov 1 2016, 10:24 AM

Closed by rL285708 and rL285709.