diff options
| author | Jacques Pienaar <jpienaar@google.com> | 2016-03-01 21:21:42 +0000 |
|---|---|---|
| committer | Jacques Pienaar <jpienaar@google.com> | 2016-03-01 21:21:42 +0000 |
| commit | ea9f25a740f36305e2265903c5277770d6e977cd (patch) | |
| tree | e1a14481314df1b2bd01c19a18ada204a6a6014e /llvm/include | |
| parent | a6cfb6f682ec819bfb1a272ff10431b2b8e7980c (diff) | |
| download | bcm5719-llvm-ea9f25a740f36305e2265903c5277770d6e977cd.tar.gz bcm5719-llvm-ea9f25a740f36305e2265903c5277770d6e977cd.zip | |
[lanai] Add ELF enum value and relocations.
Add ELF enum value and relocations for Lanai backed.
General Lanai backend discussion on llvm-dev thread "[RFC] Lanai backend" (http://lists.llvm.org/pipermail/llvm-dev/2016-February/095118.html).
Differential Revision: http://reviews.llvm.org/D17008
llvm-svn: 262394
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/Object/ELFObjectFile.h | 4 | ||||
| -rw-r--r-- | llvm/include/llvm/Object/RelocVisitor.h | 15 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/ELF.h | 10 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/ELFRelocs/Lanai.def | 19 |
4 files changed, 48 insertions, 0 deletions
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index 5d826da4c2f..d927aace242 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -835,6 +835,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const { return "ELF32-avr"; case ELF::EM_HEXAGON: return "ELF32-hexagon"; + case ELF::EM_LANAI: + return "ELF32-lanai"; case ELF::EM_MIPS: return "ELF32-mips"; case ELF::EM_PPC: @@ -891,6 +893,8 @@ unsigned ELFObjectFile<ELFT>::getArch() const { return Triple::avr; case ELF::EM_HEXAGON: return Triple::hexagon; + case ELF::EM_LANAI: + return Triple::lanai; case ELF::EM_MIPS: switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) { case ELF::ELFCLASS32: diff --git a/llvm/include/llvm/Object/RelocVisitor.h b/llvm/include/llvm/Object/RelocVisitor.h index d5e4258cb0a..f171f8e1fd4 100644 --- a/llvm/include/llvm/Object/RelocVisitor.h +++ b/llvm/include/llvm/Object/RelocVisitor.h @@ -175,6 +175,14 @@ private: case llvm::ELF::R_ARM_ABS32: return visitELF_ARM_ABS32(R, Value); } + case Triple::lanai: + switch (RelocType) { + case llvm::ELF::R_LANAI_32: + return visitELF_Lanai_32(R, Value); + default: + HasError = true; + return RelocToApply(); + } case Triple::mipsel: case Triple::mips: switch (RelocType) { @@ -311,6 +319,13 @@ private: return RelocToApply(Res, 4); } + /// Lanai ELF + RelocToApply visitELF_Lanai_32(RelocationRef R, uint64_t Value) { + int64_t Addend = getELFAddend(R); + uint32_t Res = (Value + Addend) & 0xFFFFFFFF; + return RelocToApply(Res, 4); + } + /// MIPS ELF RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) { uint32_t Res = Value & 0xFFFFFFFF; diff --git a/llvm/include/llvm/Support/ELF.h b/llvm/include/llvm/Support/ELF.h index 775bf99662b..26354dc1b9b 100644 --- a/llvm/include/llvm/Support/ELF.h +++ b/llvm/include/llvm/Support/ELF.h @@ -315,6 +315,11 @@ enum { // such numbers for an official value for WebAssembly. As soon as one is // allocated, this enum will be updated to use it. EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture + + // A request has been made to the maintainer of the official registry for + // an official value for Lanai. As soon as one is allocated, this enum will be + // updated to use it. + EM_LANAI = 0x8123, // Lanai 32-bit processor }; // Object file classes. @@ -589,6 +594,11 @@ enum { #include "ELFRelocs/Hexagon.def" }; +// ELF Relocation type for Lanai. +enum { +#include "ELFRelocs/Lanai.def" +}; + // ELF Relocation types for S390/zSeries enum { #include "ELFRelocs/SystemZ.def" diff --git a/llvm/include/llvm/Support/ELFRelocs/Lanai.def b/llvm/include/llvm/Support/ELFRelocs/Lanai.def new file mode 100644 index 00000000000..77ecb048403 --- /dev/null +++ b/llvm/include/llvm/Support/ELFRelocs/Lanai.def @@ -0,0 +1,19 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// No relocation +ELF_RELOC(R_LANAI_NONE, 0) +// 21-bit symbol relocation +ELF_RELOC(R_LANAI_21, 1) +// 21-bit symbol relocation with last two bits masked to 0 +ELF_RELOC(R_LANAI_21_F, 2) +// 25-bit branch targets +ELF_RELOC(R_LANAI_25, 3) +// General 32-bit relocation +ELF_RELOC(R_LANAI_32, 4) +// Upper 16-bits of a symbolic relocation +ELF_RELOC(R_LANAI_HI16, 5) +// Lower 16-bits of a symbolic relocation +ELF_RELOC(R_LANAI_LO16, 6) |

