diff options
author | Matt Fleming <matt@console-pimps.org> | 2010-07-06 18:44:02 +0000 |
---|---|---|
committer | Matt Fleming <matt@console-pimps.org> | 2010-07-06 18:44:02 +0000 |
commit | 004c82ad7c0d2da761726f063373c28ffd18e66d (patch) | |
tree | c498f47f76d3761681194934d7f2faa1ded16301 /include/llvm/Support/ELF.h | |
parent | e07cc5dab102c0f8c3f66c2703c95e547d6bf1c6 (diff) | |
download | external_llvm-004c82ad7c0d2da761726f063373c28ffd18e66d.zip external_llvm-004c82ad7c0d2da761726f063373c28ffd18e66d.tar.gz external_llvm-004c82ad7c0d2da761726f063373c28ffd18e66d.tar.bz2 |
Add X86_64 ELF relocation values and ELF64 relocation classes.
Patch from Roman Divacky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/ELF.h')
-rw-r--r-- | include/llvm/Support/ELF.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index b3d10e9..62851e5 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -159,6 +159,42 @@ enum { ELFOSABI_STANDALONE = 255 // Standalone (embedded) application }; +// X86_64 relocations. +enum { + R_X86_64_NONE = 0, + R_X86_64_64 = 1, + R_X86_64_PC32 = 2, + R_X86_64_GOT32 = 3, + R_X86_64_PLT32 = 4, + R_X86_64_COPY = 5, + R_X86_64_GLOB_DAT = 6, + R_X86_64_JUMP_SLOT = 7, + R_X86_64_RELATIVE = 8, + R_X86_64_GOTPCREL = 9, + R_X86_64_32 = 10, + R_X86_64_32S = 11, + R_X86_64_16 = 12, + R_X86_64_PC16 = 13, + R_X86_64_8 = 14, + R_X86_64_PC8 = 15, + R_X86_64_DTPMOD64 = 16, + R_X86_64_DTPOFF64 = 17, + R_X86_64_TPOFF64 = 18, + R_X86_64_TLSGD = 19, + R_X86_64_TLSLD = 20, + R_X86_64_DTPOFF32 = 21, + R_X86_64_GOTTPOFF = 22, + R_X86_64_TPOFF32 = 23, + R_X86_64_PC64 = 24, + R_X86_64_GOTOFF64 = 25, + R_X86_64_GOTPC32 = 26, + R_X86_64_SIZE32 = 32, + R_X86_64_SIZE64 = 33, + R_X86_64_GOTPC32_TLSDESC = 34, + R_X86_64_TLSDESC_CALL = 35, + R_X86_64_TLSDESC = 36 +}; + // Section header. struct Elf32_Shdr { Elf32_Word sh_name; // Section name (index into string table) @@ -299,6 +335,43 @@ struct Elf32_Rela { }; }; +// Relocation entry, without explicit addend. +struct Elf64_Rel { + Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr). + Elf64_Xword r_info; // Symbol table index and type of relocation to apply. + + // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, + // and ELF64_R_INFO macros defined in the ELF specification: + Elf64_Xword getSymbol () const { return (r_info >> 32); } + unsigned char getType () const { + return (unsigned char) (r_info & 0xffffffffL); + } + void setSymbol (Elf32_Word s) { setSymbolAndType (s, getType ()); } + void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); } + void setSymbolAndType (Elf64_Xword s, unsigned char t) { + r_info = (s << 32) + (t&0xffffffffL); + }; +}; + +// Relocation entry with explicit addend. +struct Elf64_Rela { + Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr). + Elf64_Xword r_info; // Symbol table index and type of relocation to apply. + Elf64_Sxword r_addend; // Compute value for relocatable field by adding this. + + // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, + // and ELF64_R_INFO macros defined in the ELF specification: + Elf64_Xword getSymbol () const { return (r_info >> 32); } + unsigned char getType () const { + return (unsigned char) (r_info & 0xffffffffL); + } + void setSymbol (Elf64_Xword s) { setSymbolAndType (s, getType ()); } + void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); } + void setSymbolAndType (Elf64_Xword s, unsigned char t) { + r_info = (s << 32) + (t&0xffffffffL); + }; +}; + // Program header. struct Elf32_Phdr { Elf32_Word p_type; // Type of segment |