[llvm-commits] [PATCH] add X86_64 relocation entries
Chris Lattner
clattner at apple.com
Wed Jun 30 21:12:10 PDT 2010
On Jun 30, 2010, at 12:22 PM, Matt Fleming wrote:
> From: Roman Divacky <rdivacky at pes.vlakno.cz>
>
> Here's another patch that adds some ELF values, this one from Roman
> Divacky. If no one yells I'll commit this later this week.
Looks ok to me, but please stay in 80 columns and punctuate your comments (end with ".").
Thanks Matt!
-Chris
>
> ---
> include/llvm/Support/ELF.h | 69 ++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 69 insertions(+), 0 deletions(-)
>
> diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h
> index 6e863f8..3d413d5 100644
> --- a/include/llvm/Support/ELF.h
> +++ b/include/llvm/Support/ELF.h
> @@ -174,6 +174,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)
> @@ -339,6 +375,39 @@ 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
> --
> 1.6.4.rc0
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list