URL
https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk
Subversion Repositories open8_urisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/open8_urisc/trunk/gnu/binutils/elfcpp
- from Rev 13 to Rev 20
- ↔ Reverse comparison
Rev 13 → Rev 20
/elfcpp.h
0,0 → 1,1815
// elfcpp.h -- main header file for elfcpp -*- C++ -*- |
|
// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
// This is the external interface for elfcpp. |
|
#ifndef ELFCPP_H |
#define ELFCPP_H |
|
#include "elfcpp_swap.h" |
|
#include <stdint.h> |
|
namespace elfcpp |
{ |
|
// Basic ELF types. |
|
// These types are always the same size. |
|
typedef uint16_t Elf_Half; |
typedef uint32_t Elf_Word; |
typedef int32_t Elf_Sword; |
typedef uint64_t Elf_Xword; |
typedef int64_t Elf_Sxword; |
|
// These types vary in size depending on the ELF file class. The |
// template parameter should be 32 or 64. |
|
template<int size> |
struct Elf_types; |
|
template<> |
struct Elf_types<32> |
{ |
typedef uint32_t Elf_Addr; |
typedef uint32_t Elf_Off; |
typedef uint32_t Elf_WXword; |
typedef int32_t Elf_Swxword; |
}; |
|
template<> |
struct Elf_types<64> |
{ |
typedef uint64_t Elf_Addr; |
typedef uint64_t Elf_Off; |
typedef uint64_t Elf_WXword; |
typedef int64_t Elf_Swxword; |
}; |
|
// Offsets within the Ehdr e_ident field. |
|
const int EI_MAG0 = 0; |
const int EI_MAG1 = 1; |
const int EI_MAG2 = 2; |
const int EI_MAG3 = 3; |
const int EI_CLASS = 4; |
const int EI_DATA = 5; |
const int EI_VERSION = 6; |
const int EI_OSABI = 7; |
const int EI_ABIVERSION = 8; |
const int EI_PAD = 9; |
const int EI_NIDENT = 16; |
|
// The valid values found in Ehdr e_ident[EI_MAG0 through EI_MAG3]. |
|
const int ELFMAG0 = 0x7f; |
const int ELFMAG1 = 'E'; |
const int ELFMAG2 = 'L'; |
const int ELFMAG3 = 'F'; |
|
// The valid values found in Ehdr e_ident[EI_CLASS]. |
|
enum |
{ |
ELFCLASSNONE = 0, |
ELFCLASS32 = 1, |
ELFCLASS64 = 2 |
}; |
|
// The valid values found in Ehdr e_ident[EI_DATA]. |
|
enum |
{ |
ELFDATANONE = 0, |
ELFDATA2LSB = 1, |
ELFDATA2MSB = 2 |
}; |
|
// The valid values found in Ehdr e_ident[EI_VERSION] and e_version. |
|
enum |
{ |
EV_NONE = 0, |
EV_CURRENT = 1 |
}; |
|
// The valid values found in Ehdr e_ident[EI_OSABI]. |
|
enum ELFOSABI |
{ |
ELFOSABI_NONE = 0, |
ELFOSABI_HPUX = 1, |
ELFOSABI_NETBSD = 2, |
// ELFOSABI_LINUX is not listed in the ELF standard. |
ELFOSABI_LINUX = 3, |
// ELFOSABI_HURD is not listed in the ELF standard. |
ELFOSABI_HURD = 4, |
ELFOSABI_SOLARIS = 6, |
ELFOSABI_AIX = 7, |
ELFOSABI_IRIX = 8, |
ELFOSABI_FREEBSD = 9, |
ELFOSABI_TRU64 = 10, |
ELFOSABI_MODESTO = 11, |
ELFOSABI_OPENBSD = 12, |
ELFOSABI_OPENVMS = 13, |
ELFOSABI_NSK = 14, |
ELFOSABI_AROS = 15, |
// A GNU extension for the ARM. |
ELFOSABI_ARM = 97, |
// A GNU extension for the MSP. |
ELFOSABI_STANDALONE = 255 |
}; |
|
// The valid values found in the Ehdr e_type field. |
|
enum ET |
{ |
ET_NONE = 0, |
ET_REL = 1, |
ET_EXEC = 2, |
ET_DYN = 3, |
ET_CORE = 4, |
ET_LOOS = 0xfe00, |
ET_HIOS = 0xfeff, |
ET_LOPROC = 0xff00, |
ET_HIPROC = 0xffff |
}; |
|
// The valid values found in the Ehdr e_machine field. |
|
enum EM |
{ |
EM_NONE = 0, |
EM_M32 = 1, |
EM_SPARC = 2, |
EM_386 = 3, |
EM_68K = 4, |
EM_88K = 5, |
// 6 used to be EM_486 |
EM_860 = 7, |
EM_MIPS = 8, |
EM_S370 = 9, |
EM_MIPS_RS3_LE = 10, |
// 11 was the old Sparc V9 ABI. |
// 12 through 14 are reserved. |
EM_PARISC = 15, |
// 16 is reserved. |
// Some old PowerPC object files use 17. |
EM_VPP500 = 17, |
EM_SPARC32PLUS = 18, |
EM_960 = 19, |
EM_PPC = 20, |
EM_PPC64 = 21, |
EM_S390 = 22, |
// 23 through 35 are served. |
EM_V800 = 36, |
EM_FR20 = 37, |
EM_RH32 = 38, |
EM_RCE = 39, |
EM_ARM = 40, |
EM_ALPHA = 41, |
EM_SH = 42, |
EM_SPARCV9 = 43, |
EM_TRICORE = 44, |
EM_ARC = 45, |
EM_H8_300 = 46, |
EM_H8_300H = 47, |
EM_H8S = 48, |
EM_H8_500 = 49, |
EM_IA_64 = 50, |
EM_MIPS_X = 51, |
EM_COLDFIRE = 52, |
EM_68HC12 = 53, |
EM_MMA = 54, |
EM_PCP = 55, |
EM_NCPU = 56, |
EM_NDR1 = 57, |
EM_STARCORE = 58, |
EM_ME16 = 59, |
EM_ST100 = 60, |
EM_TINYJ = 61, |
EM_X86_64 = 62, |
EM_PDSP = 63, |
EM_PDP10 = 64, |
EM_PDP11 = 65, |
EM_FX66 = 66, |
EM_ST9PLUS = 67, |
EM_ST7 = 68, |
EM_68HC16 = 69, |
EM_68HC11 = 70, |
EM_68HC08 = 71, |
EM_68HC05 = 72, |
EM_SVX = 73, |
EM_ST19 = 74, |
EM_VAX = 75, |
EM_CRIS = 76, |
EM_JAVELIN = 77, |
EM_FIREPATH = 78, |
EM_ZSP = 79, |
EM_MMIX = 80, |
EM_HUANY = 81, |
EM_PRISM = 82, |
EM_AVR = 83, |
EM_FR30 = 84, |
EM_D10V = 85, |
EM_D30V = 86, |
EM_V850 = 87, |
EM_M32R = 88, |
EM_MN10300 = 89, |
EM_MN10200 = 90, |
EM_PJ = 91, |
EM_OPENRISC = 92, |
EM_ARC_A5 = 93, |
EM_XTENSA = 94, |
EM_VIDEOCORE = 95, |
EM_TMM_GPP = 96, |
EM_NS32K = 97, |
EM_TPC = 98, |
// Some old picoJava object files use 99 (EM_PJ is correct). |
EM_SNP1K = 99, |
EM_ST200 = 100, |
EM_IP2K = 101, |
EM_MAX = 102, |
EM_CR = 103, |
EM_F2MC16 = 104, |
EM_MSP430 = 105, |
EM_BLACKFIN = 106, |
EM_SE_C33 = 107, |
EM_SEP = 108, |
EM_ARCA = 109, |
EM_UNICORE = 110, |
EM_ALTERA_NIOS2 = 113, |
EM_CRX = 114, |
/* Open8/ARClite/V8. */ |
EM_OPEN8 = 196, |
// The Morph MT. |
EM_MT = 0x2530, |
// DLX. |
EM_DLX = 0x5aa5, |
// FRV. |
EM_FRV = 0x5441, |
// Infineon Technologies 16-bit microcontroller with C166-V2 core. |
EM_X16X = 0x4688, |
// Xstorym16 |
EM_XSTORMY16 = 0xad45, |
// Renesas M32C |
EM_M32C = 0xfeb0, |
// Vitesse IQ2000 |
EM_IQ2000 = 0xfeba, |
// NIOS |
EM_NIOS32 = 0xfebb |
// Old AVR objects used 0x1057 (EM_AVR is correct). |
// Old MSP430 objects used 0x1059 (EM_MSP430 is correct). |
// Old FR30 objects used 0x3330 (EM_FR30 is correct). |
// Old OpenRISC objects used 0x3426 and 0x8472 (EM_OPENRISC is correct). |
// Old D10V objects used 0x7650 (EM_D10V is correct). |
// Old D30V objects used 0x7676 (EM_D30V is correct). |
// Old IP2X objects used 0x8217 (EM_IP2K is correct). |
// Old PowerPC objects used 0x9025 (EM_PPC is correct). |
// Old Alpha objects used 0x9026 (EM_ALPHA is correct). |
// Old M32R objects used 0x9041 (EM_M32R is correct). |
// Old V850 objects used 0x9080 (EM_V850 is correct). |
// Old S/390 objects used 0xa390 (EM_S390 is correct). |
// Old Xtensa objects used 0xabc7 (EM_XTENSA is correct). |
// Old MN10300 objects used 0xbeef (EM_MN10300 is correct). |
// Old MN10200 objects used 0xdead (EM_MN10200 is correct). |
}; |
|
// A special value found in the Ehdr e_phnum field. |
|
enum |
{ |
// Number of program segments stored in sh_info field of first |
// section headre. |
PN_XNUM = 0xffff |
}; |
|
// Special section indices. |
|
enum |
{ |
SHN_UNDEF = 0, |
SHN_LORESERVE = 0xff00, |
SHN_LOPROC = 0xff00, |
SHN_HIPROC = 0xff1f, |
SHN_LOOS = 0xff20, |
SHN_HIOS = 0xff3f, |
SHN_ABS = 0xfff1, |
SHN_COMMON = 0xfff2, |
SHN_XINDEX = 0xffff, |
SHN_HIRESERVE = 0xffff, |
|
// Provide for initial and final section ordering in conjunction |
// with the SHF_LINK_ORDER and SHF_ORDERED section flags. |
SHN_BEFORE = 0xff00, |
SHN_AFTER = 0xff01, |
|
// x86_64 specific large common symbol. |
SHN_X86_64_LCOMMON = 0xff02 |
}; |
|
// The valid values found in the Shdr sh_type field. |
|
enum SHT |
{ |
SHT_NULL = 0, |
SHT_PROGBITS = 1, |
SHT_SYMTAB = 2, |
SHT_STRTAB = 3, |
SHT_RELA = 4, |
SHT_HASH = 5, |
SHT_DYNAMIC = 6, |
SHT_NOTE = 7, |
SHT_NOBITS = 8, |
SHT_REL = 9, |
SHT_SHLIB = 10, |
SHT_DYNSYM = 11, |
SHT_INIT_ARRAY = 14, |
SHT_FINI_ARRAY = 15, |
SHT_PREINIT_ARRAY = 16, |
SHT_GROUP = 17, |
SHT_SYMTAB_SHNDX = 18, |
SHT_LOOS = 0x60000000, |
SHT_HIOS = 0x6fffffff, |
SHT_LOPROC = 0x70000000, |
SHT_HIPROC = 0x7fffffff, |
SHT_LOUSER = 0x80000000, |
SHT_HIUSER = 0xffffffff, |
// The remaining values are not in the standard. |
// Incremental build data. |
SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700, |
SHT_GNU_INCREMENTAL_SYMTAB = 0x6fff4701, |
SHT_GNU_INCREMENTAL_RELOCS = 0x6fff4702, |
SHT_GNU_INCREMENTAL_GOT_PLT = 0x6fff4703, |
// Object attributes. |
SHT_GNU_ATTRIBUTES = 0x6ffffff5, |
// GNU style dynamic hash table. |
SHT_GNU_HASH = 0x6ffffff6, |
// List of prelink dependencies. |
SHT_GNU_LIBLIST = 0x6ffffff7, |
// Versions defined by file. |
SHT_SUNW_verdef = 0x6ffffffd, |
SHT_GNU_verdef = 0x6ffffffd, |
// Versions needed by file. |
SHT_SUNW_verneed = 0x6ffffffe, |
SHT_GNU_verneed = 0x6ffffffe, |
// Symbol versions, |
SHT_SUNW_versym = 0x6fffffff, |
SHT_GNU_versym = 0x6fffffff, |
|
SHT_SPARC_GOTDATA = 0x70000000, |
|
// ARM-specific section types. |
// Exception Index table. |
SHT_ARM_EXIDX = 0x70000001, |
// BPABI DLL dynamic linking pre-emption map. |
SHT_ARM_PREEMPTMAP = 0x70000002, |
// Object file compatibility attributes. |
SHT_ARM_ATTRIBUTES = 0x70000003, |
// Support for debugging overlaid programs. |
SHT_ARM_DEBUGOVERLAY = 0x70000004, |
SHT_ARM_OVERLAYSECTION = 0x70000005, |
|
// x86_64 unwind information. |
SHT_X86_64_UNWIND = 0x70000001, |
|
// Link editor is to sort the entries in this section based on the |
// address specified in the associated symbol table entry. |
SHT_ORDERED = 0x7fffffff |
}; |
|
// The valid bit flags found in the Shdr sh_flags field. |
|
enum SHF |
{ |
SHF_WRITE = 0x1, |
SHF_ALLOC = 0x2, |
SHF_EXECINSTR = 0x4, |
SHF_MERGE = 0x10, |
SHF_STRINGS = 0x20, |
SHF_INFO_LINK = 0x40, |
SHF_LINK_ORDER = 0x80, |
SHF_OS_NONCONFORMING = 0x100, |
SHF_GROUP = 0x200, |
SHF_TLS = 0x400, |
SHF_MASKOS = 0x0ff00000, |
SHF_MASKPROC = 0xf0000000, |
|
// Indicates this section requires ordering in relation to |
// other sections of the same type. Ordered sections are |
// combined within the section pointed to by the sh_link entry. |
// The sh_info values SHN_BEFORE and SHN_AFTER imply that the |
// sorted section is to precede or follow, respectively, all |
// other sections in the set being ordered. |
SHF_ORDERED = 0x40000000, |
// This section is excluded from input to the link-edit of an |
// executable or shared object. This flag is ignored if SHF_ALLOC |
// is also set, or if relocations exist against the section. |
SHF_EXCLUDE = 0x80000000, |
|
// x86_64 specific large section. |
SHF_X86_64_LARGE = 0x10000000 |
}; |
|
// Bit flags which appear in the first 32-bit word of the section data |
// of a SHT_GROUP section. |
|
enum |
{ |
GRP_COMDAT = 0x1, |
GRP_MASKOS = 0x0ff00000, |
GRP_MASKPROC = 0xf0000000 |
}; |
|
// The valid values found in the Phdr p_type field. |
|
enum PT |
{ |
PT_NULL = 0, |
PT_LOAD = 1, |
PT_DYNAMIC = 2, |
PT_INTERP = 3, |
PT_NOTE = 4, |
PT_SHLIB = 5, |
PT_PHDR = 6, |
PT_TLS = 7, |
PT_LOOS = 0x60000000, |
PT_HIOS = 0x6fffffff, |
PT_LOPROC = 0x70000000, |
PT_HIPROC = 0x7fffffff, |
// The remaining values are not in the standard. |
// Frame unwind information. |
PT_GNU_EH_FRAME = 0x6474e550, |
PT_SUNW_EH_FRAME = 0x6474e550, |
// Stack flags. |
PT_GNU_STACK = 0x6474e551, |
// Read only after relocation. |
PT_GNU_RELRO = 0x6474e552, |
// Platform architecture compatibility information |
PT_ARM_ARCHEXT = 0x70000000, |
// Exception unwind tables |
PT_ARM_EXIDX = 0x70000001 |
}; |
|
// The valid bit flags found in the Phdr p_flags field. |
|
enum PF |
{ |
PF_X = 0x1, |
PF_W = 0x2, |
PF_R = 0x4, |
PF_MASKOS = 0x0ff00000, |
PF_MASKPROC = 0xf0000000 |
}; |
|
// Symbol binding from Sym st_info field. |
|
enum STB |
{ |
STB_LOCAL = 0, |
STB_GLOBAL = 1, |
STB_WEAK = 2, |
STB_LOOS = 10, |
STB_GNU_UNIQUE = 10, |
STB_HIOS = 12, |
STB_LOPROC = 13, |
STB_HIPROC = 15 |
}; |
|
// Symbol types from Sym st_info field. |
|
enum STT |
{ |
STT_NOTYPE = 0, |
STT_OBJECT = 1, |
STT_FUNC = 2, |
STT_SECTION = 3, |
STT_FILE = 4, |
STT_COMMON = 5, |
STT_TLS = 6, |
STT_LOOS = 10, |
STT_GNU_IFUNC = 10, |
STT_HIOS = 12, |
STT_LOPROC = 13, |
STT_HIPROC = 15, |
|
// The section type that must be used for register symbols on |
// Sparc. These symbols initialize a global register. |
STT_SPARC_REGISTER = 13, |
|
// ARM: a THUMB function. This is not defined in ARM ELF Specification but |
// used by the GNU tool-chain. |
STT_ARM_TFUNC = 13 |
}; |
|
inline STB |
elf_st_bind(unsigned char info) |
{ |
return static_cast<STB>(info >> 4); |
} |
|
inline STT |
elf_st_type(unsigned char info) |
{ |
return static_cast<STT>(info & 0xf); |
} |
|
inline unsigned char |
elf_st_info(STB bind, STT type) |
{ |
return ((static_cast<unsigned char>(bind) << 4) |
+ (static_cast<unsigned char>(type) & 0xf)); |
} |
|
// Symbol visibility from Sym st_other field. |
|
enum STV |
{ |
STV_DEFAULT = 0, |
STV_INTERNAL = 1, |
STV_HIDDEN = 2, |
STV_PROTECTED = 3 |
}; |
|
inline STV |
elf_st_visibility(unsigned char other) |
{ |
return static_cast<STV>(other & 0x3); |
} |
|
inline unsigned char |
elf_st_nonvis(unsigned char other) |
{ |
return static_cast<STV>(other >> 2); |
} |
|
inline unsigned char |
elf_st_other(STV vis, unsigned char nonvis) |
{ |
return ((nonvis << 2) |
+ (static_cast<unsigned char>(vis) & 3)); |
} |
|
// Reloc information from Rel/Rela r_info field. |
|
template<int size> |
unsigned int |
elf_r_sym(typename Elf_types<size>::Elf_WXword); |
|
template<> |
inline unsigned int |
elf_r_sym<32>(Elf_Word v) |
{ |
return v >> 8; |
} |
|
template<> |
inline unsigned int |
elf_r_sym<64>(Elf_Xword v) |
{ |
return v >> 32; |
} |
|
template<int size> |
unsigned int |
elf_r_type(typename Elf_types<size>::Elf_WXword); |
|
template<> |
inline unsigned int |
elf_r_type<32>(Elf_Word v) |
{ |
return v & 0xff; |
} |
|
template<> |
inline unsigned int |
elf_r_type<64>(Elf_Xword v) |
{ |
return v & 0xffffffff; |
} |
|
template<int size> |
typename Elf_types<size>::Elf_WXword |
elf_r_info(unsigned int s, unsigned int t); |
|
template<> |
inline Elf_Word |
elf_r_info<32>(unsigned int s, unsigned int t) |
{ |
return (s << 8) + (t & 0xff); |
} |
|
template<> |
inline Elf_Xword |
elf_r_info<64>(unsigned int s, unsigned int t) |
{ |
return (static_cast<Elf_Xword>(s) << 32) + (t & 0xffffffff); |
} |
|
// Dynamic tags found in the PT_DYNAMIC segment. |
|
enum DT |
{ |
DT_NULL = 0, |
DT_NEEDED = 1, |
DT_PLTRELSZ = 2, |
DT_PLTGOT = 3, |
DT_HASH = 4, |
DT_STRTAB = 5, |
DT_SYMTAB = 6, |
DT_RELA = 7, |
DT_RELASZ = 8, |
DT_RELAENT = 9, |
DT_STRSZ = 10, |
DT_SYMENT = 11, |
DT_INIT = 12, |
DT_FINI = 13, |
DT_SONAME = 14, |
DT_RPATH = 15, |
DT_SYMBOLIC = 16, |
DT_REL = 17, |
DT_RELSZ = 18, |
DT_RELENT = 19, |
DT_PLTREL = 20, |
DT_DEBUG = 21, |
DT_TEXTREL = 22, |
DT_JMPREL = 23, |
DT_BIND_NOW = 24, |
DT_INIT_ARRAY = 25, |
DT_FINI_ARRAY = 26, |
DT_INIT_ARRAYSZ = 27, |
DT_FINI_ARRAYSZ = 28, |
DT_RUNPATH = 29, |
DT_FLAGS = 30, |
|
// This is used to mark a range of dynamic tags. It is not really |
// a tag value. |
DT_ENCODING = 32, |
|
DT_PREINIT_ARRAY = 32, |
DT_PREINIT_ARRAYSZ = 33, |
DT_LOOS = 0x6000000d, |
DT_HIOS = 0x6ffff000, |
DT_LOPROC = 0x70000000, |
DT_HIPROC = 0x7fffffff, |
|
// The remaining values are extensions used by GNU or Solaris. |
DT_VALRNGLO = 0x6ffffd00, |
DT_GNU_PRELINKED = 0x6ffffdf5, |
DT_GNU_CONFLICTSZ = 0x6ffffdf6, |
DT_GNU_LIBLISTSZ = 0x6ffffdf7, |
DT_CHECKSUM = 0x6ffffdf8, |
DT_PLTPADSZ = 0x6ffffdf9, |
DT_MOVEENT = 0x6ffffdfa, |
DT_MOVESZ = 0x6ffffdfb, |
DT_FEATURE = 0x6ffffdfc, |
DT_POSFLAG_1 = 0x6ffffdfd, |
DT_SYMINSZ = 0x6ffffdfe, |
DT_SYMINENT = 0x6ffffdff, |
DT_VALRNGHI = 0x6ffffdff, |
|
DT_ADDRRNGLO = 0x6ffffe00, |
DT_GNU_HASH = 0x6ffffef5, |
DT_TLSDESC_PLT = 0x6ffffef6, |
DT_TLSDESC_GOT = 0x6ffffef7, |
DT_GNU_CONFLICT = 0x6ffffef8, |
DT_GNU_LIBLIST = 0x6ffffef9, |
DT_CONFIG = 0x6ffffefa, |
DT_DEPAUDIT = 0x6ffffefb, |
DT_AUDIT = 0x6ffffefc, |
DT_PLTPAD = 0x6ffffefd, |
DT_MOVETAB = 0x6ffffefe, |
DT_SYMINFO = 0x6ffffeff, |
DT_ADDRRNGHI = 0x6ffffeff, |
|
DT_RELACOUNT = 0x6ffffff9, |
DT_RELCOUNT = 0x6ffffffa, |
DT_FLAGS_1 = 0x6ffffffb, |
DT_VERDEF = 0x6ffffffc, |
DT_VERDEFNUM = 0x6ffffffd, |
DT_VERNEED = 0x6ffffffe, |
DT_VERNEEDNUM = 0x6fffffff, |
|
DT_VERSYM = 0x6ffffff0, |
|
// Specify the value of _GLOBAL_OFFSET_TABLE_. |
DT_PPC_GOT = 0x70000000, |
|
// Specify the start of the .glink section. |
DT_PPC64_GLINK = 0x70000000, |
|
// Specify the start and size of the .opd section. |
DT_PPC64_OPD = 0x70000001, |
DT_PPC64_OPDSZ = 0x70000002, |
|
// The index of an STT_SPARC_REGISTER symbol within the DT_SYMTAB |
// symbol table. One dynamic entry exists for every STT_SPARC_REGISTER |
// symbol in the symbol table. |
DT_SPARC_REGISTER = 0x70000001, |
|
DT_AUXILIARY = 0x7ffffffd, |
DT_USED = 0x7ffffffe, |
DT_FILTER = 0x7fffffff |
}; |
|
// Flags found in the DT_FLAGS dynamic element. |
|
enum DF |
{ |
DF_ORIGIN = 0x1, |
DF_SYMBOLIC = 0x2, |
DF_TEXTREL = 0x4, |
DF_BIND_NOW = 0x8, |
DF_STATIC_TLS = 0x10 |
}; |
|
// Flags found in the DT_FLAGS_1 dynamic element. |
|
enum DF_1 |
{ |
DF_1_NOW = 0x1, |
DF_1_GLOBAL = 0x2, |
DF_1_GROUP = 0x4, |
DF_1_NODELETE = 0x8, |
DF_1_LOADFLTR = 0x10, |
DF_1_INITFIRST = 0x20, |
DF_1_NOOPEN = 0x40, |
DF_1_ORIGIN = 0x80, |
DF_1_DIRECT = 0x100, |
DF_1_TRANS = 0x200, |
DF_1_INTERPOSE = 0x400, |
DF_1_NODEFLIB = 0x800, |
DF_1_NODUMP = 0x1000, |
DF_1_CONLFAT = 0x2000 |
}; |
|
// Version numbers which appear in the vd_version field of a Verdef |
// structure. |
|
const int VER_DEF_NONE = 0; |
const int VER_DEF_CURRENT = 1; |
|
// Version numbers which appear in the vn_version field of a Verneed |
// structure. |
|
const int VER_NEED_NONE = 0; |
const int VER_NEED_CURRENT = 1; |
|
// Bit flags which appear in vd_flags of Verdef and vna_flags of |
// Vernaux. |
|
const int VER_FLG_BASE = 0x1; |
const int VER_FLG_WEAK = 0x2; |
const int VER_FLG_INFO = 0x4; |
|
// Special constants found in the SHT_GNU_versym entries. |
|
const int VER_NDX_LOCAL = 0; |
const int VER_NDX_GLOBAL = 1; |
|
// A SHT_GNU_versym section holds 16-bit words. This bit is set if |
// the symbol is hidden and can only be seen when referenced using an |
// explicit version number. This is a GNU extension. |
|
const int VERSYM_HIDDEN = 0x8000; |
|
// This is the mask for the rest of the data in a word read from a |
// SHT_GNU_versym section. |
|
const int VERSYM_VERSION = 0x7fff; |
|
// Note descriptor type codes for notes in a non-core file with an |
// empty name. |
|
enum |
{ |
// A version string. |
NT_VERSION = 1, |
// An architecture string. |
NT_ARCH = 2 |
}; |
|
// Note descriptor type codes for notes in a non-core file with the |
// name "GNU". |
|
enum |
{ |
// The minimum ABI level. This is used by the dynamic linker to |
// describe the minimal kernel version on which a shared library may |
// be used. Th value should be four words. Word 0 is an OS |
// descriptor (see below). Word 1 is the major version of the ABI. |
// Word 2 is the minor version. Word 3 is the subminor version. |
NT_GNU_ABI_TAG = 1, |
// Hardware capabilities information. Word 0 is the number of |
// entries. Word 1 is a bitmask of enabled entries. The rest of |
// the descriptor is a series of entries, where each entry is a |
// single byte followed by a nul terminated string. The byte gives |
// the bit number to test if enabled in the bitmask. |
NT_GNU_HWCAP = 2, |
// The build ID as set by the linker's --build-id option. The |
// format of the descriptor depends on the build ID style. |
NT_GNU_BUILD_ID = 3, |
// The version of gold used to link. Th descriptor is just a |
// string. |
NT_GNU_GOLD_VERSION = 4 |
}; |
|
// The OS values which may appear in word 0 of a NT_GNU_ABI_TAG note. |
|
enum |
{ |
ELF_NOTE_OS_LINUX = 0, |
ELF_NOTE_OS_GNU = 1, |
ELF_NOTE_OS_SOLARIS2 = 2, |
ELF_NOTE_OS_FREEBSD = 3, |
ELF_NOTE_OS_NETBSD = 4, |
ELF_NOTE_OS_SYLLABLE = 5 |
}; |
|
} // End namespace elfcpp. |
|
// Include internal details after defining the types. |
#include "elfcpp_internal.h" |
|
namespace elfcpp |
{ |
|
// The offset of the ELF file header in the ELF file. |
|
const int file_header_offset = 0; |
|
// ELF structure sizes. |
|
template<int size> |
struct Elf_sizes |
{ |
// Size of ELF file header. |
static const int ehdr_size = sizeof(internal::Ehdr_data<size>); |
// Size of ELF segment header. |
static const int phdr_size = sizeof(internal::Phdr_data<size>); |
// Size of ELF section header. |
static const int shdr_size = sizeof(internal::Shdr_data<size>); |
// Size of ELF symbol table entry. |
static const int sym_size = sizeof(internal::Sym_data<size>); |
// Sizes of ELF reloc entries. |
static const int rel_size = sizeof(internal::Rel_data<size>); |
static const int rela_size = sizeof(internal::Rela_data<size>); |
// Size of ELF dynamic entry. |
static const int dyn_size = sizeof(internal::Dyn_data<size>); |
// Size of ELF version structures. |
static const int verdef_size = sizeof(internal::Verdef_data); |
static const int verdaux_size = sizeof(internal::Verdaux_data); |
static const int verneed_size = sizeof(internal::Verneed_data); |
static const int vernaux_size = sizeof(internal::Vernaux_data); |
}; |
|
// Accessor class for the ELF file header. |
|
template<int size, bool big_endian> |
class Ehdr |
{ |
public: |
Ehdr(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Ehdr_data<size>*>(p)) |
{ } |
|
template<typename File> |
Ehdr(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Ehdr_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
const unsigned char* |
get_e_ident() const |
{ return this->p_->e_ident; } |
|
Elf_Half |
get_e_type() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_type); } |
|
Elf_Half |
get_e_machine() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_machine); } |
|
Elf_Word |
get_e_version() const |
{ return Convert<32, big_endian>::convert_host(this->p_->e_version); } |
|
typename Elf_types<size>::Elf_Addr |
get_e_entry() const |
{ return Convert<size, big_endian>::convert_host(this->p_->e_entry); } |
|
typename Elf_types<size>::Elf_Off |
get_e_phoff() const |
{ return Convert<size, big_endian>::convert_host(this->p_->e_phoff); } |
|
typename Elf_types<size>::Elf_Off |
get_e_shoff() const |
{ return Convert<size, big_endian>::convert_host(this->p_->e_shoff); } |
|
Elf_Word |
get_e_flags() const |
{ return Convert<32, big_endian>::convert_host(this->p_->e_flags); } |
|
Elf_Half |
get_e_ehsize() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_ehsize); } |
|
Elf_Half |
get_e_phentsize() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_phentsize); } |
|
Elf_Half |
get_e_phnum() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_phnum); } |
|
Elf_Half |
get_e_shentsize() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_shentsize); } |
|
Elf_Half |
get_e_shnum() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_shnum); } |
|
Elf_Half |
get_e_shstrndx() const |
{ return Convert<16, big_endian>::convert_host(this->p_->e_shstrndx); } |
|
private: |
const internal::Ehdr_data<size>* p_; |
}; |
|
// Write class for the ELF file header. |
|
template<int size, bool big_endian> |
class Ehdr_write |
{ |
public: |
Ehdr_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Ehdr_data<size>*>(p)) |
{ } |
|
void |
put_e_ident(const unsigned char v[EI_NIDENT]) const |
{ memcpy(this->p_->e_ident, v, EI_NIDENT); } |
|
void |
put_e_type(Elf_Half v) |
{ this->p_->e_type = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_machine(Elf_Half v) |
{ this->p_->e_machine = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_version(Elf_Word v) |
{ this->p_->e_version = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_e_entry(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->e_entry = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_e_phoff(typename Elf_types<size>::Elf_Off v) |
{ this->p_->e_phoff = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_e_shoff(typename Elf_types<size>::Elf_Off v) |
{ this->p_->e_shoff = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_e_flags(Elf_Word v) |
{ this->p_->e_flags = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_e_ehsize(Elf_Half v) |
{ this->p_->e_ehsize = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_phentsize(Elf_Half v) |
{ this->p_->e_phentsize = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_phnum(Elf_Half v) |
{ this->p_->e_phnum = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_shentsize(Elf_Half v) |
{ this->p_->e_shentsize = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_shnum(Elf_Half v) |
{ this->p_->e_shnum = Convert<16, big_endian>::convert_host(v); } |
|
void |
put_e_shstrndx(Elf_Half v) |
{ this->p_->e_shstrndx = Convert<16, big_endian>::convert_host(v); } |
|
private: |
internal::Ehdr_data<size>* p_; |
}; |
|
// Accessor class for an ELF section header. |
|
template<int size, bool big_endian> |
class Shdr |
{ |
public: |
Shdr(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Shdr_data<size>*>(p)) |
{ } |
|
template<typename File> |
Shdr(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Shdr_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Word |
get_sh_name() const |
{ return Convert<32, big_endian>::convert_host(this->p_->sh_name); } |
|
Elf_Word |
get_sh_type() const |
{ return Convert<32, big_endian>::convert_host(this->p_->sh_type); } |
|
typename Elf_types<size>::Elf_WXword |
get_sh_flags() const |
{ return Convert<size, big_endian>::convert_host(this->p_->sh_flags); } |
|
typename Elf_types<size>::Elf_Addr |
get_sh_addr() const |
{ return Convert<size, big_endian>::convert_host(this->p_->sh_addr); } |
|
typename Elf_types<size>::Elf_Off |
get_sh_offset() const |
{ return Convert<size, big_endian>::convert_host(this->p_->sh_offset); } |
|
typename Elf_types<size>::Elf_WXword |
get_sh_size() const |
{ return Convert<size, big_endian>::convert_host(this->p_->sh_size); } |
|
Elf_Word |
get_sh_link() const |
{ return Convert<32, big_endian>::convert_host(this->p_->sh_link); } |
|
Elf_Word |
get_sh_info() const |
{ return Convert<32, big_endian>::convert_host(this->p_->sh_info); } |
|
typename Elf_types<size>::Elf_WXword |
get_sh_addralign() const |
{ return |
Convert<size, big_endian>::convert_host(this->p_->sh_addralign); } |
|
typename Elf_types<size>::Elf_WXword |
get_sh_entsize() const |
{ return Convert<size, big_endian>::convert_host(this->p_->sh_entsize); } |
|
private: |
const internal::Shdr_data<size>* p_; |
}; |
|
// Write class for an ELF section header. |
|
template<int size, bool big_endian> |
class Shdr_write |
{ |
public: |
Shdr_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Shdr_data<size>*>(p)) |
{ } |
|
void |
put_sh_name(Elf_Word v) |
{ this->p_->sh_name = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_sh_type(Elf_Word v) |
{ this->p_->sh_type = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_sh_flags(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->sh_flags = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_sh_addr(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->sh_addr = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_sh_offset(typename Elf_types<size>::Elf_Off v) |
{ this->p_->sh_offset = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_sh_size(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->sh_size = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_sh_link(Elf_Word v) |
{ this->p_->sh_link = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_sh_info(Elf_Word v) |
{ this->p_->sh_info = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_sh_addralign(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->sh_addralign = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_sh_entsize(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->sh_entsize = Convert<size, big_endian>::convert_host(v); } |
|
private: |
internal::Shdr_data<size>* p_; |
}; |
|
// Accessor class for an ELF segment header. |
|
template<int size, bool big_endian> |
class Phdr |
{ |
public: |
Phdr(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Phdr_data<size>*>(p)) |
{ } |
|
template<typename File> |
Phdr(File* file, typename File::Location loc) |
: p_(reinterpret_cast<internal::Phdr_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Word |
get_p_type() const |
{ return Convert<32, big_endian>::convert_host(this->p_->p_type); } |
|
typename Elf_types<size>::Elf_Off |
get_p_offset() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_offset); } |
|
typename Elf_types<size>::Elf_Addr |
get_p_vaddr() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_vaddr); } |
|
typename Elf_types<size>::Elf_Addr |
get_p_paddr() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_paddr); } |
|
typename Elf_types<size>::Elf_WXword |
get_p_filesz() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_filesz); } |
|
typename Elf_types<size>::Elf_WXword |
get_p_memsz() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_memsz); } |
|
Elf_Word |
get_p_flags() const |
{ return Convert<32, big_endian>::convert_host(this->p_->p_flags); } |
|
typename Elf_types<size>::Elf_WXword |
get_p_align() const |
{ return Convert<size, big_endian>::convert_host(this->p_->p_align); } |
|
private: |
const internal::Phdr_data<size>* p_; |
}; |
|
// Write class for an ELF segment header. |
|
template<int size, bool big_endian> |
class Phdr_write |
{ |
public: |
Phdr_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Phdr_data<size>*>(p)) |
{ } |
|
void |
put_p_type(Elf_Word v) |
{ this->p_->p_type = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_p_offset(typename Elf_types<size>::Elf_Off v) |
{ this->p_->p_offset = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_p_vaddr(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->p_vaddr = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_p_paddr(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->p_paddr = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_p_filesz(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->p_filesz = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_p_memsz(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->p_memsz = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_p_flags(Elf_Word v) |
{ this->p_->p_flags = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_p_align(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->p_align = Convert<size, big_endian>::convert_host(v); } |
|
private: |
internal::Phdr_data<size>* p_; |
}; |
|
// Accessor class for an ELF symbol table entry. |
|
template<int size, bool big_endian> |
class Sym |
{ |
public: |
Sym(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Sym_data<size>*>(p)) |
{ } |
|
template<typename File> |
Sym(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Sym_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Word |
get_st_name() const |
{ return Convert<32, big_endian>::convert_host(this->p_->st_name); } |
|
typename Elf_types<size>::Elf_Addr |
get_st_value() const |
{ return Convert<size, big_endian>::convert_host(this->p_->st_value); } |
|
typename Elf_types<size>::Elf_WXword |
get_st_size() const |
{ return Convert<size, big_endian>::convert_host(this->p_->st_size); } |
|
unsigned char |
get_st_info() const |
{ return this->p_->st_info; } |
|
STB |
get_st_bind() const |
{ return elf_st_bind(this->get_st_info()); } |
|
STT |
get_st_type() const |
{ return elf_st_type(this->get_st_info()); } |
|
unsigned char |
get_st_other() const |
{ return this->p_->st_other; } |
|
STV |
get_st_visibility() const |
{ return elf_st_visibility(this->get_st_other()); } |
|
unsigned char |
get_st_nonvis() const |
{ return elf_st_nonvis(this->get_st_other()); } |
|
Elf_Half |
get_st_shndx() const |
{ return Convert<16, big_endian>::convert_host(this->p_->st_shndx); } |
|
private: |
const internal::Sym_data<size>* p_; |
}; |
|
// Writer class for an ELF symbol table entry. |
|
template<int size, bool big_endian> |
class Sym_write |
{ |
public: |
Sym_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Sym_data<size>*>(p)) |
{ } |
|
void |
put_st_name(Elf_Word v) |
{ this->p_->st_name = Convert<32, big_endian>::convert_host(v); } |
|
void |
put_st_value(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->st_value = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_st_size(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->st_size = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_st_info(unsigned char v) |
{ this->p_->st_info = v; } |
|
void |
put_st_info(STB bind, STT type) |
{ this->p_->st_info = elf_st_info(bind, type); } |
|
void |
put_st_other(unsigned char v) |
{ this->p_->st_other = v; } |
|
void |
put_st_other(STV vis, unsigned char nonvis) |
{ this->p_->st_other = elf_st_other(vis, nonvis); } |
|
void |
put_st_shndx(Elf_Half v) |
{ this->p_->st_shndx = Convert<16, big_endian>::convert_host(v); } |
|
Sym<size, big_endian> |
sym() |
{ return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); } |
|
private: |
internal::Sym_data<size>* p_; |
}; |
|
// Accessor classes for an ELF REL relocation entry. |
|
template<int size, bool big_endian> |
class Rel |
{ |
public: |
Rel(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Rel_data<size>*>(p)) |
{ } |
|
template<typename File> |
Rel(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Rel_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
typename Elf_types<size>::Elf_Addr |
get_r_offset() const |
{ return Convert<size, big_endian>::convert_host(this->p_->r_offset); } |
|
typename Elf_types<size>::Elf_WXword |
get_r_info() const |
{ return Convert<size, big_endian>::convert_host(this->p_->r_info); } |
|
private: |
const internal::Rel_data<size>* p_; |
}; |
|
// Writer class for an ELF Rel relocation. |
|
template<int size, bool big_endian> |
class Rel_write |
{ |
public: |
Rel_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Rel_data<size>*>(p)) |
{ } |
|
void |
put_r_offset(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->r_offset = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_r_info(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->r_info = Convert<size, big_endian>::convert_host(v); } |
|
private: |
internal::Rel_data<size>* p_; |
}; |
|
// Accessor class for an ELF Rela relocation. |
|
template<int size, bool big_endian> |
class Rela |
{ |
public: |
Rela(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Rela_data<size>*>(p)) |
{ } |
|
template<typename File> |
Rela(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Rela_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
typename Elf_types<size>::Elf_Addr |
get_r_offset() const |
{ return Convert<size, big_endian>::convert_host(this->p_->r_offset); } |
|
typename Elf_types<size>::Elf_WXword |
get_r_info() const |
{ return Convert<size, big_endian>::convert_host(this->p_->r_info); } |
|
typename Elf_types<size>::Elf_Swxword |
get_r_addend() const |
{ return Convert<size, big_endian>::convert_host(this->p_->r_addend); } |
|
private: |
const internal::Rela_data<size>* p_; |
}; |
|
// Writer class for an ELF Rela relocation. |
|
template<int size, bool big_endian> |
class Rela_write |
{ |
public: |
Rela_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Rela_data<size>*>(p)) |
{ } |
|
void |
put_r_offset(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->r_offset = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_r_info(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->r_info = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_r_addend(typename Elf_types<size>::Elf_Swxword v) |
{ this->p_->r_addend = Convert<size, big_endian>::convert_host(v); } |
|
private: |
internal::Rela_data<size>* p_; |
}; |
|
// Accessor classes for entries in the ELF SHT_DYNAMIC section aka |
// PT_DYNAMIC segment. |
|
template<int size, bool big_endian> |
class Dyn |
{ |
public: |
Dyn(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Dyn_data<size>*>(p)) |
{ } |
|
template<typename File> |
Dyn(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Dyn_data<size>*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
typename Elf_types<size>::Elf_Swxword |
get_d_tag() const |
{ return Convert<size, big_endian>::convert_host(this->p_->d_tag); } |
|
typename Elf_types<size>::Elf_WXword |
get_d_val() const |
{ return Convert<size, big_endian>::convert_host(this->p_->d_val); } |
|
typename Elf_types<size>::Elf_Addr |
get_d_ptr() const |
{ return Convert<size, big_endian>::convert_host(this->p_->d_val); } |
|
private: |
const internal::Dyn_data<size>* p_; |
}; |
|
// Write class for an entry in the SHT_DYNAMIC section. |
|
template<int size, bool big_endian> |
class Dyn_write |
{ |
public: |
Dyn_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Dyn_data<size>*>(p)) |
{ } |
|
void |
put_d_tag(typename Elf_types<size>::Elf_Swxword v) |
{ this->p_->d_tag = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_d_val(typename Elf_types<size>::Elf_WXword v) |
{ this->p_->d_val = Convert<size, big_endian>::convert_host(v); } |
|
void |
put_d_ptr(typename Elf_types<size>::Elf_Addr v) |
{ this->p_->d_val = Convert<size, big_endian>::convert_host(v); } |
|
private: |
internal::Dyn_data<size>* p_; |
}; |
|
// Accessor classes for entries in the ELF SHT_GNU_verdef section. |
|
template<int size, bool big_endian> |
class Verdef |
{ |
public: |
Verdef(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Verdef_data*>(p)) |
{ } |
|
template<typename File> |
Verdef(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Verdef_data*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Half |
get_vd_version() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vd_version); } |
|
Elf_Half |
get_vd_flags() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vd_flags); } |
|
Elf_Half |
get_vd_ndx() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vd_ndx); } |
|
Elf_Half |
get_vd_cnt() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vd_cnt); } |
|
Elf_Word |
get_vd_hash() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vd_hash); } |
|
Elf_Word |
get_vd_aux() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vd_aux); } |
|
Elf_Word |
get_vd_next() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vd_next); } |
|
private: |
const internal::Verdef_data* p_; |
}; |
|
template<int size, bool big_endian> |
class Verdef_write |
{ |
public: |
Verdef_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Verdef_data*>(p)) |
{ } |
|
void |
set_vd_version(Elf_Half v) |
{ this->p_->vd_version = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vd_flags(Elf_Half v) |
{ this->p_->vd_flags = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vd_ndx(Elf_Half v) |
{ this->p_->vd_ndx = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vd_cnt(Elf_Half v) |
{ this->p_->vd_cnt = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vd_hash(Elf_Word v) |
{ this->p_->vd_hash = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vd_aux(Elf_Word v) |
{ this->p_->vd_aux = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vd_next(Elf_Word v) |
{ this->p_->vd_next = Convert<32, big_endian>::convert_host(v); } |
|
private: |
internal::Verdef_data* p_; |
}; |
|
// Accessor classes for auxiliary entries in the ELF SHT_GNU_verdef |
// section. |
|
template<int size, bool big_endian> |
class Verdaux |
{ |
public: |
Verdaux(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Verdaux_data*>(p)) |
{ } |
|
template<typename File> |
Verdaux(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Verdaux_data*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Word |
get_vda_name() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vda_name); } |
|
Elf_Word |
get_vda_next() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vda_next); } |
|
private: |
const internal::Verdaux_data* p_; |
}; |
|
template<int size, bool big_endian> |
class Verdaux_write |
{ |
public: |
Verdaux_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Verdaux_data*>(p)) |
{ } |
|
void |
set_vda_name(Elf_Word v) |
{ this->p_->vda_name = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vda_next(Elf_Word v) |
{ this->p_->vda_next = Convert<32, big_endian>::convert_host(v); } |
|
private: |
internal::Verdaux_data* p_; |
}; |
|
// Accessor classes for entries in the ELF SHT_GNU_verneed section. |
|
template<int size, bool big_endian> |
class Verneed |
{ |
public: |
Verneed(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Verneed_data*>(p)) |
{ } |
|
template<typename File> |
Verneed(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Verneed_data*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Half |
get_vn_version() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vn_version); } |
|
Elf_Half |
get_vn_cnt() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vn_cnt); } |
|
Elf_Word |
get_vn_file() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vn_file); } |
|
Elf_Word |
get_vn_aux() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vn_aux); } |
|
Elf_Word |
get_vn_next() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vn_next); } |
|
private: |
const internal::Verneed_data* p_; |
}; |
|
template<int size, bool big_endian> |
class Verneed_write |
{ |
public: |
Verneed_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Verneed_data*>(p)) |
{ } |
|
void |
set_vn_version(Elf_Half v) |
{ this->p_->vn_version = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vn_cnt(Elf_Half v) |
{ this->p_->vn_cnt = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vn_file(Elf_Word v) |
{ this->p_->vn_file = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vn_aux(Elf_Word v) |
{ this->p_->vn_aux = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vn_next(Elf_Word v) |
{ this->p_->vn_next = Convert<32, big_endian>::convert_host(v); } |
|
private: |
internal::Verneed_data* p_; |
}; |
|
// Accessor classes for auxiliary entries in the ELF SHT_GNU_verneed |
// section. |
|
template<int size, bool big_endian> |
class Vernaux |
{ |
public: |
Vernaux(const unsigned char* p) |
: p_(reinterpret_cast<const internal::Vernaux_data*>(p)) |
{ } |
|
template<typename File> |
Vernaux(File* file, typename File::Location loc) |
: p_(reinterpret_cast<const internal::Vernaux_data*>( |
file->view(loc.file_offset, loc.data_size).data())) |
{ } |
|
Elf_Word |
get_vna_hash() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vna_hash); } |
|
Elf_Half |
get_vna_flags() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vna_flags); } |
|
Elf_Half |
get_vna_other() const |
{ return Convert<16, big_endian>::convert_host(this->p_->vna_other); } |
|
Elf_Word |
get_vna_name() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vna_name); } |
|
Elf_Word |
get_vna_next() const |
{ return Convert<32, big_endian>::convert_host(this->p_->vna_next); } |
|
private: |
const internal::Vernaux_data* p_; |
}; |
|
template<int size, bool big_endian> |
class Vernaux_write |
{ |
public: |
Vernaux_write(unsigned char* p) |
: p_(reinterpret_cast<internal::Vernaux_data*>(p)) |
{ } |
|
void |
set_vna_hash(Elf_Word v) |
{ this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vna_flags(Elf_Half v) |
{ this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vna_other(Elf_Half v) |
{ this->p_->vna_other = Convert<16, big_endian>::convert_host(v); } |
|
void |
set_vna_name(Elf_Word v) |
{ this->p_->vna_name = Convert<32, big_endian>::convert_host(v); } |
|
void |
set_vna_next(Elf_Word v) |
{ this->p_->vna_next = Convert<32, big_endian>::convert_host(v); } |
|
private: |
internal::Vernaux_data* p_; |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFPCP_H) |
/i386.h
0,0 → 1,98
// i386.h -- ELF definitions specific to EM_386 -*- C++ -*- |
|
// Copyright 2006, 2007, 2010 Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_I386_H |
#define ELFCPP_I386_H |
|
// Documentation for the TLS relocs is taken from |
// http://people.redhat.com/drepper/tls.pdf |
// http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt |
|
namespace elfcpp |
{ |
|
enum |
{ |
R_386_NONE = 0, // No reloc |
R_386_32 = 1, // Direct 32 bit zero extended |
R_386_PC32 = 2, // PC relative 32 bit signed |
R_386_GOT32 = 3, // 32 bit GOT entry |
R_386_PLT32 = 4, // 32 bit PLT address |
R_386_COPY = 5, // Copy symbol at runtime |
R_386_GLOB_DAT = 6, // Create GOT entry |
R_386_JUMP_SLOT = 7, // Create PLT entry |
R_386_RELATIVE = 8, // Adjust by program base |
R_386_GOTOFF = 9, // 32-bit GOT offset |
R_386_GOTPC = 10, // 32-bit PC relative offset to GOT |
// Used by Sun. |
R_386_32PLT = 11, |
// TLS extensions. |
R_386_TLS_TPOFF = 14, // Outstanding Initial Exec reloc, gnu-style (both) |
R_386_TLS_IE = 15, // Initial Initial Exec reloc, gnu-style (no-PIC) |
R_386_TLS_GOTIE = 16, // Initial Initial Exec reloc, gnu-style (for PIC) |
R_386_TLS_LE = 17, // Initial Local Exec reloc, gnu-style |
R_386_TLS_GD = 18, // Initial General Dynamic reloc, gnu-style |
R_386_TLS_LDM = 19, // Initial Local Dynamic reloc, gnu-style |
// GNU extensions. |
R_386_16 = 20, // Direct 16 bit zero extended |
R_386_PC16 = 21, // 16 bit sign extended pc relative |
R_386_8 = 22, // Direct 8 bit sign extended |
R_386_PC8 = 23, // 8 bit sign extended pc relative |
// More TLS relocs. |
R_386_TLS_GD_32 = 24, // Initial General Dynamic reloc, sun-style |
R_386_TLS_GD_PUSH = 25, // Initial General Dynamic reloc, sun-style |
R_386_TLS_GD_CALL = 26, // Initial General Dynamic reloc, sun-style |
R_386_TLS_GD_POP = 27, // Initial General Dynamic reloc, sun-style |
R_386_TLS_LDM_32 = 28, // Initial Local Dynamic reloc, sun-style |
R_386_TLS_LDM_PUSH = 29, // Initial Local Dynamic reloc, sun-style |
R_386_TLS_LDM_CALL = 30, // Initial Local Dynamic reloc, sun-style |
R_386_TLS_LDM_POP = 31, // Initial Local Dynamic reloc, sun-style |
R_386_TLS_LDO_32 = 32, // Initial Local Dynamic reloc, sun+gnu styles |
R_386_TLS_IE_32 = 33, // Initial Initial Exec reloc, sun-style |
R_386_TLS_LE_32 = 34, // Initial Local Exec reloc, sun-style |
R_386_TLS_DTPMOD32 = 35, // Outstanding General/Local Dynamic reloc, sun+gnu |
R_386_TLS_DTPOFF32 = 36, // Outstanding General Dynamic reloc, sun+gnu |
R_386_TLS_TPOFF32 = 37, // Outstanding Initial Exec reloc, sun-style |
R_386_TLS_GOTDESC = 39, // GOT offset for TLS descriptor |
R_386_TLS_DESC_CALL = 40, // Marker of call through TLS desc for relaxation |
R_386_TLS_DESC = 41, // TLS descriptor containing pointer to code and |
// to argument, returning TLS offset for symbol |
R_386_IRELATIVE = 42, // Adjust indirectly by program base |
// Used by Intel. |
R_386_USED_BY_INTEL_200 = 200, |
// GNU vtable garbage collection extensions. |
R_386_GNU_VTINHERIT = 250, |
R_386_GNU_VTENTRY = 251 |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_I386_H) |
/x86_64.h
0,0 → 1,101
// x86-64.h -- ELF definitions specific to EM_X86_64 -*- C++ -*- |
|
// Copyright 2006, 2007, 2010 Free Software Foundation, Inc. |
// Written by Andrew Chatham. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_X86_64_H |
#define ELFCPP_X86_64_H |
|
namespace elfcpp |
{ |
|
// Documentation is taken from |
// http://www.x86-64.org/documentation/abi-0.98.pdf |
// elf.h |
// Documentation for the TLS relocs is taken from |
// http://people.redhat.com/drepper/tls.pdf |
// http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt |
|
enum |
{ |
R_X86_64_NONE = 0, // No reloc |
R_X86_64_64 = 1, // Direct 64 bit |
R_X86_64_PC32 = 2, // PC relative 32 bit signed |
R_X86_64_GOT32 = 3, // 32 bit GOT entry |
R_X86_64_PLT32 = 4, // 32 bit PLT address |
R_X86_64_COPY = 5, // Copy symbol at runtime |
R_X86_64_GLOB_DAT = 6, // Create GOT entry |
R_X86_64_JUMP_SLOT = 7, // Create PLT entry |
R_X86_64_RELATIVE = 8, // Adjust by program base |
R_X86_64_GOTPCREL = 9, // 32 bit signed PC relative offset to GOT |
R_X86_64_32 = 10, // Direct 32 bit zero extended |
R_X86_64_32S = 11, // Direct 32 bit sign extended |
R_X86_64_16 = 12, // Direct 16 bit zero extended |
R_X86_64_PC16 = 13, // 16 bit sign extended pc relative |
R_X86_64_8 = 14, // Direct 8 bit sign extended |
R_X86_64_PC8 = 15, // 8 bit sign extended pc relative |
|
// TLS relocations |
R_X86_64_DTPMOD64 = 16, // ID of module containing symbol |
R_X86_64_DTPOFF64 = 17, // Offset in module's TLS block |
R_X86_64_TPOFF64 = 18, // Offset in initial TLS block |
R_X86_64_TLSGD = 19, // 32 bit signed PC relative offset to two |
// GOT entries for GD symbol |
R_X86_64_TLSLD = 20, // 32 bit signed PC relative offset to two |
// GOT entries for LD symbol |
R_X86_64_DTPOFF32 = 21, // Offset in TLS block |
R_X86_64_GOTTPOFF = 22, // 32 bit signed PC relative offset to GOT |
// entry for IE symbol |
R_X86_64_TPOFF32 = 23, // Offset in initial TLS block |
|
R_X86_64_PC64 = 24, // 64-bit PC relative |
R_X86_64_GOTOFF64 = 25, // 64-bit GOT offset |
R_X86_64_GOTPC32 = 26, // 32-bit PC relative offset to GOT |
|
R_X86_64_GOT64 = 27, // 64-bit GOT entry offset |
R_X86_64_GOTPCREL64 = 28, // 64-bit PC relative offset to GOT entry |
R_X86_64_GOTPC64 = 29, // 64-bit PC relative offset to GOT |
R_X86_64_GOTPLT64 = 30, // Like GOT64, indicates that PLT entry needed |
R_X86_64_PLTOFF64 = 31, // 64-bit GOT relative offset to PLT entry |
|
R_X86_64_SIZE32 = 32, |
R_X86_64_SIZE64 = 33, |
|
R_X86_64_GOTPC32_TLSDESC = 34, // 32-bit PC relative to TLS descriptor in GOT |
R_X86_64_TLSDESC_CALL = 35, // Relaxable call through TLS descriptor |
R_X86_64_TLSDESC = 36, // 2 by 64-bit TLS descriptor |
R_X86_64_IRELATIVE = 37, // Adjust indirectly by program base |
// GNU vtable garbage collection extensions. |
R_X86_64_GNU_VTINHERIT = 250, |
R_X86_64_GNU_VTENTRY = 251 |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_X86_64_H) |
/arm.h
0,0 → 1,344
// arm.h -- ELF definitions specific to EM_ARM -*- C++ -*- |
|
// Copyright 2009, Free Software Foundation, Inc. |
// Written by Doug Kwan <dougkwan@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_ARM_H |
#define ELFCPP_ARM_H |
|
// The relocation type information is taken from: |
// |
// ELF for the ARM Architecture |
// Document number: ARM IHI 0044C, current through ABI release 2.07 |
// Date of Issue: 10th October, 2008 |
// |
|
namespace elfcpp |
{ |
|
// |
// ARM Relocations Codes |
// |
|
// Operation notes: |
// S: Address of the symbol. |
// A: Addend for relocation. |
// P: Address of the place being relocated. |
// Pa: Adjusted address of the place being relocated (P & 0xfffffffc) |
// T: is 1 if S has type STT_FUNC and the symbol addresses a Thumb |
// instruction.Thumb-bit; it is 0 otherwise. |
// B(S): Addressing origin of the output segment defining S. |
// GOT_ORG: Addressing origin of the Global Offset Table. |
// GOT(S): Address of the GOT entry for S. |
// |
|
enum |
{ |
// Type Class Operation |
// ------------------------------ |
R_ARM_NONE = 0, // Static Misc |
R_ARM_PC24 = 1, // Deprecated ARM ((S + A) | T) - P |
R_ARM_ABS32 = 2, // Static Data (S + A) | T |
R_ARM_REL32 = 3, // Static Data ((S + A) | T) - P |
R_ARM_LDR_PC_G0 = 4, // Static ARM S + A - P |
R_ARM_ABS16 = 5, // Static Data S + A |
R_ARM_ABS12 = 6, // Static ARM S + A |
R_ARM_THM_ABS5 = 7, // Static Thumb16 S + A |
R_ARM_ABS8 = 8, // Static Data S + A |
R_ARM_SBREL32 = 9, // Static Data ((S + A) | T) - B(S) |
R_ARM_THM_CALL = 10, // Static Thumb32 ((S + A) | T) - P |
R_ARM_THM_PC8 = 11, // Static Thumb16 |
R_ARM_BREL_ADJ = 12, // Dynamic Data DeltaB(S) + A |
R_ARM_TLS_DESC = 13, // Dynamic Data |
R_ARM_THM_SWI8 = 14, // Obsolete |
R_ARM_XPC25 = 15, // Obsolete |
R_ARM_THM_XPC22 = 16, // Obsolete |
R_ARM_TLS_DTPMOD32 = 17, // Dynamic Data Module(S) |
R_ARM_TLS_DTPOFF32 = 18, // Dynamic Data S + A - TLS |
R_ARM_TLS_TPOFF32 = 19, // Dynamic Data S + A - tp |
R_ARM_COPY = 20, // Dynamic Misc |
R_ARM_GLOB_DAT = 21, // Dynamic Data (S + A) | T |
R_ARM_JUMP_SLOT = 22, // Dynamic Data (S + A) | T |
R_ARM_RELATIVE = 23, // Dynamic Data B(S) + A |
R_ARM_GOTOFF32 = 24, // Static Data (((S + A) | T) - GOT_ORG |
R_ARM_BASE_PREL = 25, // Static Data B(S) + A - P |
R_ARM_GOT_BREL = 26, // Static Data GOT(S) + A - GOT_ORG |
R_ARM_PLT32 = 27, // Deprecated ARM ((S + A) | T) - P |
R_ARM_CALL = 28, // Static ARM ((S + A) | T) - P |
R_ARM_JUMP24 = 29, // Static ARM ((S + A) | T) - P |
R_ARM_THM_JUMP24 = 30, // Static Thumb32 ((S + A) | T) - P |
R_ARM_BASE_ABS = 31, // Static Data B(S) + A |
R_ARM_ALU_PCREL_7_0 = 32, // Obsolete |
R_ARM_ALU_PCREL_15_8 = 33, // Obsolete |
R_ARM_ALU_PCREL_23_15 = 34, // Obsolete |
R_ARM_LDR_SBREL_11_0_NC = 35, // Deprecated ARM S + A - B(S) |
R_ARM_ALU_SBREL_19_12_NC = 36,// Deprecated ARM S + A - B(S) |
R_ARM_ALU_SBREL_27_20_CK = 37,// Deprecated ARM S + A - B(S) |
R_ARM_TARGET1 = 38, // Data Misc (S + A) | T or |
// ((S + A) | T) - P |
R_ARM_SBREL31 = 39, // Deprecated Data ((S + A) | T) - B(S) |
R_ARM_V4BX = 40, // Static Misc |
R_ARM_TARGET2 = 41, // Static Misc |
R_ARM_PREL31 = 42, // Static Data ((S + A) | T) - P |
R_ARM_MOVW_ABS_NC = 43, // Static ARM (S + A) | T |
R_ARM_MOVT_ABS = 44, // Static ARM S + A |
R_ARM_MOVW_PREL_NC = 45, // Static ARM ((S + A) | T) - P |
R_ARM_MOVT_PREL = 46, // Static ARM S + A - P |
R_ARM_THM_MOVW_ABS_NC = 47, // Static Thumb32 (S + A) | T |
R_ARM_THM_MOVT_ABS = 48, // Static Thumb32 S + A - P |
R_ARM_THM_MOVW_PREL_NC = 49, // Static Thumb32 ((S + A) | T) - P |
R_ARM_THM_MOVT_PREL = 50, // Static Thumb32 S + A - P |
R_ARM_THM_JUMP19 = 51, // Static Thumb32 ((S + A) | T) - P |
R_ARM_THM_JUMP6 = 52, // Static Thumb16 S + A - P |
R_ARM_THM_ALU_PREL_11_0 = 53, // Static Thumb32 ((S + A) | T) - Pa |
R_ARM_THM_PC12 = 54, // Static Thumb32 S + A - Pa |
R_ARM_ABS32_NOI = 55, // Static Data S + A |
R_ARM_REL32_NOI = 56, // Static Data S + A - P |
R_ARM_ALU_PC_G0_NC = 57, // Static ARM ((S + A) | T) - P |
R_ARM_ALU_PC_G0 = 58, // Static ARM ((S + A) | T) - P |
R_ARM_ALU_PC_G1_NC = 59, // Static ARM ((S + A) | T) - P |
R_ARM_ALU_PC_G1 = 60, // Static ARM ((S + A) | T) - P |
R_ARM_ALU_PC_G2 = 61, // Static ARM ((S + A) | T) - P |
R_ARM_LDR_PC_G1 = 62, // Static ARM S + A - P |
R_ARM_LDR_PC_G2 = 63, // Static ARM S + A - P |
R_ARM_LDRS_PC_G0 = 64, // Static ARM S + A - P |
R_ARM_LDRS_PC_G1 = 65, // Static ARM S + A - P |
R_ARM_LDRS_PC_G2 = 66, // Static ARM S + A - P |
R_ARM_LDC_PC_G0 = 67, // Static ARM S + A - P |
R_ARM_LDC_PC_G1 = 68, // Static ARM S + A - P |
R_ARM_LDC_PC_G2 = 69, // Static ARM S + A - P |
R_ARM_ALU_SB_G0_NC = 70, // Static ARM ((S + A) | T) - B(S) |
R_ARM_ALU_SB_G0 = 71, // Static ARM ((S + A) | T) - B(S) |
R_ARM_ALU_SB_G1_NC = 72, // Static ARM ((S + A) | T) - B(S) |
R_ARM_ALU_SB_G1 = 73, // Static ARM ((S + A) | T) - B(S) |
R_ARM_ALU_SB_G2 = 74, // Static ARM ((S + A) | T) - B(S) |
R_ARM_LDR_SB_G0 = 75, // Static ARM S + A - B(S) |
R_ARM_LDR_SB_G1 = 76, // Static ARM S + A - B(S) |
R_ARM_LDR_SB_G2 = 77, // Static ARM S + A - B(S) |
R_ARM_LDRS_SB_G0 = 78, // Static ARM S + A - B(S) |
R_ARM_LDRS_SB_G1 = 79, // Static ARM S + A - B(S) |
R_ARM_LDRS_SB_G2 = 80, // Static ARM S + A - B(S) |
R_ARM_LDC_SB_G0 = 81, // Static ARM S + A - B(S) |
R_ARM_LDC_SB_G1 = 82, // Static ARM S + A - B(S) |
R_ARM_LDC_SB_G2 = 83, // Static ARM S + A - B(S) |
R_ARM_MOVW_BREL_NC = 84, // Static ARM ((S + A) | T) - B(S) |
R_ARM_MOVT_BREL = 85, // Static ARM S + A - B(S) |
R_ARM_MOVW_BREL = 86, // Static ARM ((S + A) | T) - B(S) |
R_ARM_THM_MOVW_BREL_NC = 87, // Static Thumb32 ((S + A) | T) - B(S) |
R_ARM_THM_MOVT_BREL = 88, // Static Thumb32 S + A - B(S) |
R_ARM_THM_MOVW_BREL = 89, // Static Thumb32 ((S + A) | T) - B(S) |
R_ARM_TLS_GOTDESC = 90, // Static Data |
R_ARM_TLS_CALL = 91, // Static ARM |
R_ARM_TLS_DESCSEQ = 92, // Static ARM TLS relaxation |
R_ARM_THM_TLS_CALL = 93, // Static Thumb32 |
R_ARM_PLT32_ABS = 94, // Static Data PLT(S) + A |
R_ARM_GOT_ABS = 95, // Static Data GOT(S) + A |
R_ARM_GOT_PREL = 96, // Static Data GOT(S) + A - P |
R_ARM_GOT_BREL12 = 97, // Static ARM GOT(S) + A - GOT_ORG |
R_ARM_GOTOFF12 = 98, // Static ARM S + A - GOT_ROG |
R_ARM_GOTRELAX = 99, // Static Misc |
R_ARM_GNU_VTENTRY = 100, // Deprecated Data |
R_ARM_GNU_VTINHERIT = 101, // Deprecated Data |
R_ARM_THM_JUMP11 = 102, // Static Thumb16 S + A - P |
R_ARM_THM_JUMP8 = 103, // Static Thumb16 S + A - P |
R_ARM_TLS_GD32 = 104, // Static Data GOT(S) + A - P |
R_ARM_TLS_LDM32 = 105, // Static Data GOT(S) + A - P |
R_ARM_TLS_LDO32 = 106, // Static Data S + A - TLS |
R_ARM_TLS_IE32 = 107, // Static Data GOT(S) + A - P |
R_ARM_TLS_LE32 = 108, // Static Data S + A - tp |
R_ARM_TLS_LDO12 = 109, // Static ARM S + A - TLS |
R_ARM_TLS_LE12 = 110, // Static ARM S + A - tp |
R_ARM_TLS_IE12GP = 111, // Static ARM GOT(S) + A - GOT_ORG |
R_ARM_PRIVATE_0 = 112, // Private (n = 0, 1, ... 15) |
R_ARM_PRIVATE_1 = 113, |
R_ARM_PRIVATE_2 = 114, |
R_ARM_PRIVATE_3 = 115, |
R_ARM_PRIVATE_4 = 116, |
R_ARM_PRIVATE_5 = 117, |
R_ARM_PRIVATE_6 = 118, |
R_ARM_PRIVATE_7 = 119, |
R_ARM_PRIVATE_8 = 120, |
R_ARM_PRIVATE_9 = 121, |
R_ARM_PRIVATE_10 = 122, |
R_ARM_PRIVATE_11 = 123, |
R_ARM_PRIVATE_12 = 124, |
R_ARM_PRIVATE_13 = 125, |
R_ARM_PRIVATE_14 = 126, |
R_ARM_PRIVATE_15 = 127, |
R_ARM_ME_TOO = 128, // Obsolete |
R_ARM_THM_TLS_DESCSEQ16 = 129,// Static Thumb16 |
R_ARM_THM_TLS_DESCSEQ32 = 130,// Static Thumb32 |
// 131 - 139 Unallocated |
// 140 - 159 Dynamic Reserved for future allocation |
// 160 - 255 Unallocated |
}; |
|
// e_flags values used for ARM. We only support flags defined in AAELF. |
|
enum |
{ |
EF_ARM_BE8 = 0x00800000, |
|
// Mask to extract EABI version, not really a flag value. |
EF_ARM_EABIMASK = 0xFF000000, |
|
EF_ARM_EABI_UNKNOWN = 0x00000000, |
EF_ARM_EABI_VER1 = 0x01000000, |
EF_ARM_EABI_VER2 = 0x02000000, |
EF_ARM_EABI_VER3 = 0x03000000, |
EF_ARM_EABI_VER4 = 0x04000000, |
EF_ARM_EABI_VER5 = 0x05000000, |
}; |
|
// Extract EABI version from flags. |
|
inline Elf_Word |
arm_eabi_version(Elf_Word flags) |
{ return flags & EF_ARM_EABIMASK; } |
|
// Values for the Tag_CPU_arch EABI attribute. |
enum |
{ |
TAG_CPU_ARCH_PRE_V4, |
TAG_CPU_ARCH_V4, |
TAG_CPU_ARCH_V4T, |
TAG_CPU_ARCH_V5T, |
TAG_CPU_ARCH_V5TE, |
TAG_CPU_ARCH_V5TEJ, |
TAG_CPU_ARCH_V6, |
TAG_CPU_ARCH_V6KZ, |
TAG_CPU_ARCH_V6T2, |
TAG_CPU_ARCH_V6K, |
TAG_CPU_ARCH_V7, |
TAG_CPU_ARCH_V6_M, |
TAG_CPU_ARCH_V6S_M, |
TAG_CPU_ARCH_V7E_M, |
MAX_TAG_CPU_ARCH = TAG_CPU_ARCH_V7E_M, |
// Pseudo-architecture to allow objects to be compatible with the subset of |
// armv4t and armv6-m. This value should never be stored in object files. |
TAG_CPU_ARCH_V4T_PLUS_V6_M = (MAX_TAG_CPU_ARCH + 1) |
}; |
|
// EABI object attributes. |
enum |
{ |
// 0-3 are generic. |
Tag_CPU_raw_name = 4, |
Tag_CPU_name = 5, |
Tag_CPU_arch = 6, |
Tag_CPU_arch_profile = 7, |
Tag_ARM_ISA_use = 8, |
Tag_THUMB_ISA_use = 9, |
Tag_FP_arch = 10, |
Tag_WMMX_arch = 11, |
Tag_Advanced_SIMD_arch = 12, |
Tag_PCS_config = 13, |
Tag_ABI_PCS_R9_use = 14, |
Tag_ABI_PCS_RW_data = 15, |
Tag_ABI_PCS_RO_data = 16, |
Tag_ABI_PCS_GOT_use = 17, |
Tag_ABI_PCS_wchar_t = 18, |
Tag_ABI_FP_rounding = 19, |
Tag_ABI_FP_denormal = 20, |
Tag_ABI_FP_exceptions = 21, |
Tag_ABI_FP_user_exceptions = 22, |
Tag_ABI_FP_number_model = 23, |
Tag_ABI_align_needed = 24, |
Tag_ABI_align_preserved = 25, |
Tag_ABI_enum_size = 26, |
Tag_ABI_HardFP_use = 27, |
Tag_ABI_VFP_args = 28, |
Tag_ABI_WMMX_args = 29, |
Tag_ABI_optimization_goals = 30, |
Tag_ABI_FP_optimization_goals = 31, |
// 32 is generic (Tag_compatibility). |
Tag_undefined33 = 33, |
Tag_CPU_unaligned_access = 34, |
Tag_undefined35 = 35, |
Tag_FP_HP_extension = 36, |
Tag_undefined37 = 37, |
Tag_ABI_FP_16bit_format = 38, |
Tag_undefined39 = 39, |
Tag_undefined40 = 40, |
Tag_undefined41 = 41, |
Tag_MPextension_use = 42, |
Tag_undefined43 = 43, |
Tag_DIV_use = 44, |
Tag_nodefaults = 64, |
Tag_also_compatible_with = 65, |
Tag_T2EE_use = 66, |
Tag_conformance = 67, |
Tag_Virtualization_use = 68, |
Tag_undefined69 = 69, |
Tag_MPextension_use_legacy = 70, |
|
// The following tags are legacy names for other tags. |
Tag_VFP_arch = Tag_FP_arch, |
Tag_ABI_align8_needed = Tag_ABI_align_needed, |
Tag_ABI_align8_preserved = Tag_ABI_align_preserved, |
Tag_VFP_HP_extension = Tag_FP_HP_extension |
}; |
|
// Values for Tag_ABI_PCS_R9_use. |
enum |
{ |
AEABI_R9_V6 = 0, |
AEABI_R9_SB = 1, |
AEABI_R9_TLS = 2, |
AEABI_R9_unused = 3 |
}; |
|
// Values for Tag_ABI_PCS_RW_data. |
enum |
{ |
AEABI_PCS_RW_data_absolute = 0, |
AEABI_PCS_RW_data_PCrel = 1, |
AEABI_PCS_RW_data_SBrel = 2, |
AEABI_PCS_RW_data_unused = 3 |
}; |
|
// Values for Tag_ABI_enum_size. |
enum |
{ |
AEABI_enum_unused = 0, |
AEABI_enum_short = 1, |
AEABI_enum_wide = 2, |
AEABI_enum_forced_wide = 3 |
}; |
|
// For Exception Index Table. (Exception handling ABI for the ARM |
// architectue, Section 5) |
enum |
{ |
EXIDX_CANTUNWIND = 1, |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_ARM_H) |
/powerpc.h
0,0 → 1,189
// powerpc.h -- ELF definitions specific to EM_PPC and EM_PPC64 -*- C++ -*- |
|
// Copyright 2008, 2010 Free Software Foundation, Inc. |
// Written by David S. Miller <davem@davemloft.net>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_POWERPC_H |
#define ELFCPP_POWERPC_H |
|
namespace elfcpp |
{ |
|
// The relocation numbers for 32-bit and 64-bit powerpc are nearly |
// identical. Therefore I've adopted the convention of using |
// R_POWERPC_foo for values which are the same in R_PPC_* and R_PPC64_*. |
// For relocations which are specific to the word size I will use |
// R_PPC_foo or R_PPC64_foo. |
enum |
{ |
R_POWERPC_NONE = 0, |
R_POWERPC_ADDR32 = 1, |
R_POWERPC_ADDR24 = 2, |
R_POWERPC_ADDR16 = 3, |
R_POWERPC_ADDR16_LO = 4, |
R_POWERPC_ADDR16_HI = 5, |
R_POWERPC_ADDR16_HA = 6, |
R_POWERPC_ADDR14 = 7, |
R_POWERPC_ADDR14_BRTAKEN = 8, |
R_POWERPC_ADDR14_BRNTAKEN = 9, |
R_POWERPC_REL24 = 10, |
R_POWERPC_REL14 = 11, |
R_POWERPC_REL14_BRTAKEN = 12, |
R_POWERPC_REL14_BRNTAKEN = 13, |
R_POWERPC_GOT16 = 14, |
R_POWERPC_GOT16_LO = 15, |
R_POWERPC_GOT16_HI = 16, |
R_POWERPC_GOT16_HA = 17, |
R_PPC_PLTREL24 = 18, |
R_POWERPC_COPY = 19, |
R_POWERPC_GLOB_DAT = 20, |
R_POWERPC_JMP_SLOT = 21, |
R_POWERPC_RELATIVE = 22, |
R_PPC_LOCAL24PC = 23, |
R_POWERPC_UADDR32 = 24, |
R_POWERPC_UADDR16 = 25, |
R_POWERPC_REL32 = 26, |
R_POWERPC_PLT32 = 27, |
R_POWERPC_PLTREL32 = 28, |
R_POWERPC_PLT16_LO = 29, |
R_POWERPC_PLT16_HI = 30, |
R_POWERPC_PLT16_HA = 31, |
R_PPC_SDAREL16 = 32, |
R_POWERPC_SECTOFF = 33, |
R_POWERPC_SECTOFF_LO = 34, |
R_POWERPC_SECTOFF_HI = 35, |
R_POWERPC_SECTOFF_HA = 36, |
R_POWERPC_ADDR30 = 37, |
R_PPC64_ADDR64 = 38, |
R_PPC64_ADDR16_HIGHER = 39, |
R_PPC64_ADDR16_HIGHERA = 40, |
R_PPC64_ADDR16_HIGHEST = 41, |
R_PPC64_ADDR16_HIGHESTA = 42, |
R_PPC64_UADDR64 = 43, |
R_PPC64_REL64 = 44, |
R_PPC64_PLT64 = 45, |
R_PPC64_PLTREL64 = 46, |
R_PPC64_TOC16 = 47, |
R_PPC64_TOC16_LO = 48, |
R_PPC64_TOC16_HI = 49, |
R_PPC64_TOC16_HA = 50, |
R_PPC64_TOC = 51, |
R_PPC64_PLTGOT16 = 52, |
R_PPC64_PLTGOT16_LO = 53, |
R_PPC64_PLTGOT16_HI = 54, |
R_PPC64_PLTGOT16_HA = 55, |
R_PPC64_ADDR16_DS = 56, |
R_PPC64_ADDR16_LO_DS = 57, |
R_PPC64_GOT16_DS = 58, |
R_PPC64_GOT16_LO_DS = 59, |
R_PPC64_PLT16_LO_DS = 60, |
R_PPC64_SECTOFF_DS = 61, |
R_PPC64_SECTOFF_LO_DS = 62, |
R_PPC64_TOC16_DS = 63, |
R_PPC64_TOC16_LO_DS = 64, |
R_PPC64_PLTGOT16_DS = 65, |
R_PPC64_PLTGOT16_LO_DS = 66, |
R_POWERPC_TLS = 67, |
R_POWERPC_DTPMOD = 68, |
R_POWERPC_TPREL16 = 69, |
R_POWERPC_TPREL16_LO = 70, |
R_POWERPC_TPREL16_HI = 71, |
R_POWERPC_TPREL16_HA = 72, |
R_POWERPC_TPREL = 73, |
R_POWERPC_DTPREL16 = 74, |
R_POWERPC_DTPREL16_LO = 75, |
R_POWERPC_DTPREL16_HI = 76, |
R_POWERPC_DTPREL16_HA = 77, |
R_POWERPC_DTPREL = 78, |
R_POWERPC_GOT_TLSGD16 = 79, |
R_POWERPC_GOT_TLSGD16_LO = 80, |
R_POWERPC_GOT_TLSGD16_HI = 81, |
R_POWERPC_GOT_TLSGD16_HA = 82, |
R_POWERPC_GOT_TLSLD16 = 83, |
R_POWERPC_GOT_TLSLD16_LO = 84, |
R_POWERPC_GOT_TLSLD16_HI = 85, |
R_POWERPC_GOT_TLSLD16_HA = 86, |
R_POWERPC_GOT_TPREL16 = 87, |
R_POWERPC_GOT_TPREL16_LO = 88, |
R_POWERPC_GOT_TPREL16_HI = 89, |
R_POWERPC_GOT_TPREL16_HA = 90, |
R_POWERPC_GOT_DTPREL16 = 91, |
R_POWERPC_GOT_DTPREL16_LO = 92, |
R_POWERPC_GOT_DTPREL16_HI = 93, |
R_POWERPC_GOT_DTPREL16_HA = 94, |
R_PPC64_TPREL16_DS = 95, |
R_PPC64_TPREL16_LO_DS = 96, |
R_PPC64_TPREL16_HIGHER = 97, |
R_PPC64_TPREL16_HIGHERA = 98, |
R_PPC64_TPREL16_HIGHEST = 99, |
R_PPC64_TPREL16_HIGHESTA = 100, |
R_PPC64_DTPREL16_DS = 101, |
R_PPC64_DTPREL16_LO_DS = 102, |
R_PPC64_DTPREL16_HIGHER = 103, |
R_PPC64_DTPREL16_HIGHERA = 104, |
R_PPC64_DTPREL16_HIGHEST = 105, |
R_PPC64_DTPREL16_HIGHESTA = 106, |
R_PPC_EMB_NADDR32 = 101, |
R_PPC_EMB_NADDR16 = 102, |
R_PPC_EMB_NADDR16_LO = 103, |
R_PPC_EMB_NADDR16_HI = 104, |
R_PPC_EMB_NADDR16_HA = 105, |
R_PPC_EMB_SDAI16 = 106, |
R_PPC_EMB_SDA2I16 = 107, |
R_PPC_EMB_SDA2REL = 108, |
R_PPC_EMB_SDA21 = 109, |
R_PPC_EMB_MRKREF = 110, |
R_PPC_EMB_RELSEC16 = 111, |
R_PPC_EMB_RELST_LO = 112, |
R_PPC_EMB_RELST_HI = 113, |
R_PPC_EMB_RELST_HA = 114, |
R_PPC_EMB_BIT_FLD = 115, |
R_PPC_EMB_RELSDA = 116, |
|
R_POWERPC_IRELATIVE = 248, |
R_PPC_REL16 = 249, |
R_PPC_REL16_LO = 250, |
R_PPC_REL16_HI = 251, |
R_PPC_REL16_HA = 252, |
R_POWERPC_GNU_VTINHERIT = 253, |
R_POWERPC_GNU_VTENTRY = 254, |
R_PPC_TOC16 = 255, |
}; |
|
// e_flags values defined for powerpc |
enum |
{ |
EF_PPC_EMB = 0x80000000, // PowerPC embedded flag. |
EF_PPC_RELOCATABLE = 0x00010000, // PowerPC -mrelocatable flag. */ |
EF_PPC_RELOCATABLE_LIB = 0x00008000, // PowerPC -mrelocatable-lib flag. */ |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_POWERPC_H) |
/ChangeLog
0,0 → 1,193
2010-08-12 Cary Coutant <ccoutant@google.com> |
|
* elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_GOT_PLT. |
|
2010-08-12 Cary Coutant <ccoutant@google.com> |
|
* elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, |
SHT_GNU_INCREMENTAL_RELOCS. |
|
2010-08-04 Ian Lance Taylor <iant@google.com> |
|
* i386.h (R_386_IRELATIVE): Define. |
* powerpc.h (R_POWERPC_IRELATIVE): Define. |
(R_PPC_RELAX32, R_PPC_RELAX32PC): Don't define. |
(R_PPC_RELAX32_PLT, R_PPC_RELAX32PC_PLT): Don't define. |
* sparc.h (R_SPARC_IRELATIVE): Define. |
* x86_64.h (R_X86_64_IRELATIVE): Define. |
(R_X86_64_GNU_VTINHERIT): Rename from R_386_GNU_VTINHERIT. |
(R_X86_64_GNU_VTENTRY): Rename from R_386_GNU_VTENTRY. |
|
2010-05-12 Doug Kwan <dougkwan@google.com> |
|
* arm.h (Tag_FP_arch, Tag_ABI_align_needed, Tag_ABI_align_preserved, |
Tag_FP_HP_extension, Tag_MPextension_use_legacy): Rename from |
existing tags. |
(Tag_undefined40, Tag_undefined41, Tag_MPextension_use, |
Tag_undefined43): New tags. |
(Targ_VFP_arch, Tag_ABI_align8_needed, TAG_ABI_align8_preserved, |
Tag_VFP_HP_extension): Define aliases for backward compatiblity. |
|
2010-03-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> |
|
* elfcpp.h (VER_FLG_INFO): Define. |
|
2010-01-21 Doug Kwan <dougkwan@google.com> |
|
* arm.h (EXIDX_CANTUNWIND): New enum. |
|
2010-01-19 Ian Lance Taylor <iant@google.com> |
|
* elfcpp.h (PN_XNUM): Define. |
|
2009-12-14 Ian Lance Taylor <iant@google.com> |
|
* elfcpp_file.h: Revert last patch. |
|
2009-12-11 Nick Clifton <nickc@redhat.com> |
|
* elfcpp_file.h: Fix shadowed variable warnings. |
|
2009-12-10 Doug Kwan <dougkwan@google.com> |
|
* arm.h: New enums for EABI object attribute tags and values. |
|
2009-12-05 Doug Kwan <dougkwan@google.com> |
|
* arm.h: Define enums for Tag_CPU_arch EABI attribute. |
|
2009-11-24 Rafael Avila de Espindola <espindola@google.com> |
|
* elfcpp_file.h: Include elfcpp.h. |
|
2009-11-03 Ian Lance Taylor <iant@google.com> |
|
* elfcpp.h: Remove trailing commas from enum definitions. |
|
2009-10-30 Doug Kwan <dougkwan@google.com> |
|
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN, |
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3, |
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific |
flags. |
(arm_eabi_version): New inline function. |
* elfcpp.h: Add a comment about DT_ENCODING. |
|
2009-10-16 Doug Kwan <dougkwan@google.com> |
|
* elfcpp/elfcpp.h (DT_PREINIT_ARRAY): Correct enum value. |
|
2009-10-09 Andrew Pinski <andrew_pinski@playstation.sony.com> |
|
* elfcpp/elfcpp_file.h (Elf_file::section_name): Change shstr_size |
to Elf_WXword. |
|
2009-10-09 Mikolaj Zalewski <mikolajz@google.com> |
|
* elf_file.h: (class Elf_strtab): New class. |
|
2009-10-09 Mikolaj Zalewski <mikolajz@google.com> |
|
* elfcpp_file.h: Fix header guard. Include <cstdio>. |
(class Elf_recognizer): New class, code from gold/object.cc. |
(Elf_file::find_section_by_type): New method. |
|
2009-07-23 Ulrich Drepper <drepper@redhat.com> |
|
* elfcpp.h (enum STB): Add STB_GNU_UNIQUE. |
|
2009-06-21 Ian Lance Taylor <iant@google.com> |
|
* elfcpp.h (SHN_X86_64_LCOMMON): Define enum constant. |
(enum SHT): Add SHT_X86_64_UNWIND. |
(enum SHF): Add SHT_X86_64_LARGE. |
|
2009-05-27 Doug Kwan <dougkwan@google.com> |
|
* arm.h: New file. |
* elfcpp.h (enum SHT): Add ARM-specific special sections. |
(enum PT): Add ARM-specific section types. |
(enum SST): Add STT_ARM_TFUNC. |
|
2009-04-30 Nick Clifton <nickc@redhat.com> |
|
* elfcpp.h (enum STT): Add STT_GNU_IFUNC. |
|
2009-03-20 Mikolaj Zalewski <mikolajz@google.com> |
|
* elfcpp.h (SHT_GNU_INCREMENTAL_INPUTS): Define. |
|
2009-03-01 Ian Lance Taylor <iant@google.com> |
|
* elfcpp_swap.h: #include "config.h". Only #include <byteswap.h> |
if HAVE_BYTESWAP_H is defined; if not, provide definitions for |
bswap_{16,32,64}. For gcc 4.3 and later, use the builtin bswap |
functions. Check WORDS_BIGENDIAN rather than __BYTE_ORDER. |
|
2009-01-06 H.J. Lu <hongjiu.lu@intel.com> |
|
* elfcpp.h (enum STT): Remove STT_IFUNC. |
|
2008-12-03 Nick Clifton <nickc@redhat.com> |
|
* elfcpp.h (enum STT): Add STT_IFUNC. |
|
2008-06-12 David S. Miller <davem@davemloft.net> |
|
* powerpc.h: New file. |
* elfcpp.h (SHT_ORDERED): New enum constant. |
(DT_PPC_GOT, DT_PPC64_GLINK, DT_PPC64_OPD, DT_PPC64_OPDSZ): Same. |
|
2008-05-28 Caleb Howe <cshowe@google.com> |
|
* dwarf.h (enum DW_FORM): Define. |
|
2008-04-19 Ian Lance Taylor <iant@google.com> |
|
* elfcpp_file.h (class Elf_file): Add large_shndx_offset_ field. |
(Elf_file::large_shndx_offset): New function. |
(Elf_file::construct): Initialize large_shndx_offset_. |
(Elf_File::initialize_shnum): If necessary, adjust shstrndx_ and |
set large_shndx_offset_. |
|
2008-04-16 David S. Miller <davem@davemloft.net> |
|
* elfcpp.h (DF_1_NOW, DF_1_GLOBAL, DF_1_GROUP, |
DF_1_NODELETE, DF_1_LOADFLTR, DF_1_INITFIRST, |
DF_1_NOOPEN, DF_1_ORIGIN, DF_1_DIRECT, DF_1_TRANS, |
DF_1_INTERPOSE, DF_1_NODEFLIB, DF_1_NODUMP, |
DF_1_CONLFAT): New enum constants. |
|
2008-04-15 David S. Miller <davem@davemloft.net> |
|
* sparc.h (EF_SPARC_EXT_MASK, EF_SPARC_32PLUS_MASK, |
EF_SPARC_32PLUS, EF_SPARC_SUN_US1, EF_SPARC_HAL_R1, |
EF_SPARC_SUN_US3, EF_SPARC_LEDATA, EF_SPARCV9_MM, |
EF_SPARCV9_TSO, EF_SPARCV9_PSO, EF_SPARCV9_RMO): |
Define as enum constants. |
|
2008-04-11 David S. Miller <davem@davemloft.net> |
|
* sparc.h: New file |
* elfcpp.h (SHN_BEFORE, SHN_AFTER): New enum constants. |
(SHT_SPARC_GOTDATA, SHF_ORDERED, SHF_EXCLUDE, |
STT_SPARC_REGISTER, DT_SPARC_REGISTER): Likewise. |
|
2008-04-03 Ian Lance Taylor <iant@google.com> |
|
* elfcpp_swap.h (Swap_unaligned<64, true>::writeval): Correct |
byte order. |
|
2008-03-24 Ian Lance Taylor <iant@google.com> |
|
* elfcpp.h (NT_VERSION, NT_ARCH): Define as enum constants. |
(NT_GNU_ABI_TAG, NT_GNU_HWCAP): Likewise. |
(NT_GNU_BUILD_ID, NT_GNU_GOLD_VERSION): Likewise. |
(ELF_NOTE_OS_LINUX, ELF_NOTE_OS_GNU): Likewise. |
(ELF_NOTE_OS_SOLARIS2, ELF_NOTE_OS_NETBSD): Likewise. |
(ELF_NOTE_OS_SYLLABLE): Likewise. |
|
2008-03-21 Ian Lance Taylor <iant@google.com> |
|
* Added source code to GNU binutils. |
|
/dwarf.h
0,0 → 1,408
// dwarf.h -- DWARF2 constants -*- C++ -*- |
|
// Copyright 2006, 2007, Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_DWARF_H |
#define ELFCPP_DWARF_H |
|
namespace elfcpp |
{ |
|
// DWARF2 codes. |
|
enum DW_TAG |
{ |
DW_TAG_padding = 0x00, |
DW_TAG_array_type = 0x01, |
DW_TAG_class_type = 0x02, |
DW_TAG_entry_point = 0x03, |
DW_TAG_enumeration_type = 0x04, |
DW_TAG_formal_parameter = 0x05, |
DW_TAG_imported_declaration = 0x08, |
DW_TAG_label = 0x0a, |
DW_TAG_lexical_block = 0x0b, |
DW_TAG_member = 0x0d, |
DW_TAG_pointer_type = 0x0f, |
DW_TAG_reference_type = 0x10, |
DW_TAG_compile_unit = 0x11, |
DW_TAG_string_type = 0x12, |
DW_TAG_structure_type = 0x13, |
DW_TAG_subroutine_type = 0x15, |
DW_TAG_typedef = 0x16, |
DW_TAG_union_type = 0x17, |
DW_TAG_unspecified_parameters = 0x18, |
DW_TAG_variant = 0x19, |
DW_TAG_common_block = 0x1a, |
DW_TAG_common_inclusion = 0x1b, |
DW_TAG_inheritance = 0x1c, |
DW_TAG_inlined_subroutine = 0x1d, |
DW_TAG_module = 0x1e, |
DW_TAG_ptr_to_member_type = 0x1f, |
DW_TAG_set_type = 0x20, |
DW_TAG_subrange_type = 0x21, |
DW_TAG_with_stmt = 0x22, |
DW_TAG_access_declaration = 0x23, |
DW_TAG_base_type = 0x24, |
DW_TAG_catch_block = 0x25, |
DW_TAG_const_type = 0x26, |
DW_TAG_constant = 0x27, |
DW_TAG_enumerator = 0x28, |
DW_TAG_file_type = 0x29, |
DW_TAG_friend = 0x2a, |
DW_TAG_namelist = 0x2b, |
DW_TAG_namelist_item = 0x2c, |
DW_TAG_packed_type = 0x2d, |
DW_TAG_subprogram = 0x2e, |
DW_TAG_template_type_param = 0x2f, |
DW_TAG_template_value_param = 0x30, |
DW_TAG_thrown_type = 0x31, |
DW_TAG_try_block = 0x32, |
DW_TAG_variant_part = 0x33, |
DW_TAG_variable = 0x34, |
DW_TAG_volatile_type = 0x35, |
|
// DWARF3. |
DW_TAG_dwarf_procedure = 0x36, |
DW_TAG_restrict_type = 0x37, |
DW_TAG_interface_type = 0x38, |
DW_TAG_namespace = 0x39, |
DW_TAG_imported_module = 0x3a, |
DW_TAG_unspecified_type = 0x3b, |
DW_TAG_partial_unit = 0x3c, |
DW_TAG_imported_unit = 0x3d, |
DW_TAG_condition = 0x3f, |
DW_TAG_shared_type = 0x40, |
|
// SGI/MIPS extensions. |
DW_TAG_MIPS_loop = 0x4081, |
|
// HP extensions. |
// See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz. |
DW_TAG_HP_array_descriptor = 0x4090, |
|
// GNU extensions. |
DW_TAG_format_label = 0x4101, // For FORTRAN 77 and Fortran 90. |
DW_TAG_function_template = 0x4102, // For C++. |
DW_TAG_class_template = 0x4103, // For C++. |
DW_TAG_GNU_BINCL = 0x4104, |
DW_TAG_GNU_EINCL = 0x4105, |
|
// Extensions for UPC. See: http://upc.gwu.edu/~upc. |
DW_TAG_upc_shared_type = 0x8765, |
DW_TAG_upc_strict_type = 0x8766, |
DW_TAG_upc_relaxed_type = 0x8767, |
|
// PGI (STMicroelectronics) extensions. No documentation available. |
DW_TAG_PGI_kanji_type = 0xA000, |
DW_TAG_PGI_interface_block = 0xA020 |
}; |
|
enum DW_FORM |
{ |
DW_FORM_null = 0x00, |
DW_FORM_addr = 0x01, |
DW_FORM_block2 = 0x03, |
DW_FORM_block4 = 0x04, |
DW_FORM_data2 = 0x05, |
DW_FORM_data4 = 0x06, |
DW_FORM_data8 = 0x07, |
DW_FORM_string = 0x08, |
DW_FORM_block = 0x09, |
DW_FORM_block1 = 0x0a, |
DW_FORM_data1 = 0x0b, |
DW_FORM_flag = 0x0c, |
DW_FORM_sdata = 0x0d, |
DW_FORM_strp = 0x0e, |
DW_FORM_udata = 0x0f, |
DW_FORM_ref_addr = 0x10, |
DW_FORM_ref1 = 0x11, |
DW_FORM_ref2 = 0x12, |
DW_FORM_ref4 = 0x13, |
DW_FORM_ref8 = 0x14, |
DW_FORM_ref_udata = 0x15, |
DW_FORM_indirect = 0x16 |
}; |
|
// Frame unwind information. |
|
enum DW_EH_PE |
{ |
DW_EH_PE_absptr = 0x00, |
DW_EH_PE_omit = 0xff, |
|
DW_EH_PE_uleb128 = 0x01, |
DW_EH_PE_udata2 = 0x02, |
DW_EH_PE_udata4 = 0x03, |
DW_EH_PE_udata8 = 0x04, |
DW_EH_PE_signed = 0x08, |
DW_EH_PE_sleb128 = 0x09, |
DW_EH_PE_sdata2 = 0x0a, |
DW_EH_PE_sdata4 = 0x0b, |
DW_EH_PE_sdata8 = 0x0c, |
|
DW_EH_PE_pcrel = 0x10, |
DW_EH_PE_textrel = 0x20, |
DW_EH_PE_datarel = 0x30, |
DW_EH_PE_funcrel = 0x40, |
DW_EH_PE_aligned = 0x50, |
|
DW_EH_PE_indirect = 0x80 |
}; |
|
// Line number opcodes. |
|
enum DW_LINE_OPS |
{ |
DW_LNS_extended_op = 0, |
DW_LNS_copy = 1, |
DW_LNS_advance_pc = 2, |
DW_LNS_advance_line = 3, |
DW_LNS_set_file = 4, |
DW_LNS_set_column = 5, |
DW_LNS_negate_stmt = 6, |
DW_LNS_set_basic_block = 7, |
DW_LNS_const_add_pc = 8, |
DW_LNS_fixed_advance_pc = 9, |
// DWARF 3. |
DW_LNS_set_prologue_end = 10, |
DW_LNS_set_epilogue_begin = 11, |
DW_LNS_set_isa = 12 |
}; |
|
// Line number extended opcodes. |
|
enum DW_LINE_EXTENDED_OPS |
{ |
DW_LNE_end_sequence = 1, |
DW_LNE_set_address = 2, |
DW_LNE_define_file = 3, |
// HP extensions. |
DW_LNE_HP_negate_is_UV_update = 0x11, |
DW_LNE_HP_push_context = 0x12, |
DW_LNE_HP_pop_context = 0x13, |
DW_LNE_HP_set_file_line_column = 0x14, |
DW_LNE_HP_set_routine_name = 0x15, |
DW_LNE_HP_set_sequence = 0x16, |
DW_LNE_HP_negate_post_semantics = 0x17, |
DW_LNE_HP_negate_function_exit = 0x18, |
DW_LNE_HP_negate_front_end_logical = 0x19, |
DW_LNE_HP_define_proc = 0x20 |
}; |
|
// Type encoding names and codes |
|
enum DW_ENCODING |
{ |
DW_ATE_address =0x1, |
DW_ATE_boolean =0x2, |
DW_ATE_complex_float =0x3, |
DW_ATE_float =0x4, |
DW_ATE_signed =0x5, |
DW_ATE_signed_char =0x6, |
DW_ATE_unsigned =0x7, |
DW_ATE_unsigned_char =0x8, |
// DWARF3/DWARF3f |
DW_ATE_imaginary_float =0x9, |
DW_ATE_packed_decimal =0xa, |
DW_ATE_numeric_string =0xb, |
DW_ATE_edited =0xc, |
DW_ATE_signed_fixed =0xd, |
DW_ATE_unsigned_fixed =0xe, |
DW_ATE_decimal_float =0xf, |
DW_ATE_lo_user =0x80, |
DW_ATE_hi_user =0xff |
}; |
|
// Location virtual machine opcodes |
|
enum DW_OP |
{ |
DW_OP_addr =0x03, |
DW_OP_deref =0x06, |
DW_OP_const1u =0x08, |
DW_OP_const1s =0x09, |
DW_OP_const2u =0x0a, |
DW_OP_const2s =0x0b, |
DW_OP_const4u =0x0c, |
DW_OP_const4s =0x0d, |
DW_OP_const8u =0x0e, |
DW_OP_const8s =0x0f, |
DW_OP_constu =0x10, |
DW_OP_consts =0x11, |
DW_OP_dup =0x12, |
DW_OP_drop =0x13, |
DW_OP_over =0x14, |
DW_OP_pick =0x15, |
DW_OP_swap =0x16, |
DW_OP_rot =0x17, |
DW_OP_xderef =0x18, |
DW_OP_abs =0x19, |
DW_OP_and =0x1a, |
DW_OP_div =0x1b, |
DW_OP_minus =0x1c, |
DW_OP_mod =0x1d, |
DW_OP_mul =0x1e, |
DW_OP_neg =0x1f, |
DW_OP_not =0x20, |
DW_OP_or =0x21, |
DW_OP_plus =0x22, |
DW_OP_plus_uconst =0x23, |
DW_OP_shl =0x24, |
DW_OP_shr =0x25, |
DW_OP_shra =0x26, |
DW_OP_xor =0x27, |
DW_OP_bra =0x28, |
DW_OP_eq =0x29, |
DW_OP_ge =0x2a, |
DW_OP_gt =0x2b, |
DW_OP_le =0x2c, |
DW_OP_lt =0x2d, |
DW_OP_ne =0x2e, |
DW_OP_skip =0x2f, |
DW_OP_lit0 =0x30, |
DW_OP_lit1 =0x31, |
DW_OP_lit2 =0x32, |
DW_OP_lit3 =0x33, |
DW_OP_lit4 =0x34, |
DW_OP_lit5 =0x35, |
DW_OP_lit6 =0x36, |
DW_OP_lit7 =0x37, |
DW_OP_lit8 =0x38, |
DW_OP_lit9 =0x39, |
DW_OP_lit10 =0x3a, |
DW_OP_lit11 =0x3b, |
DW_OP_lit12 =0x3c, |
DW_OP_lit13 =0x3d, |
DW_OP_lit14 =0x3e, |
DW_OP_lit15 =0x3f, |
DW_OP_lit16 =0x40, |
DW_OP_lit17 =0x41, |
DW_OP_lit18 =0x42, |
DW_OP_lit19 =0x43, |
DW_OP_lit20 =0x44, |
DW_OP_lit21 =0x45, |
DW_OP_lit22 =0x46, |
DW_OP_lit23 =0x47, |
DW_OP_lit24 =0x48, |
DW_OP_lit25 =0x49, |
DW_OP_lit26 =0x4a, |
DW_OP_lit27 =0x4b, |
DW_OP_lit28 =0x4c, |
DW_OP_lit29 =0x4d, |
DW_OP_lit30 =0x4e, |
DW_OP_lit31 =0x4f, |
DW_OP_reg0 =0x50, |
DW_OP_reg1 =0x51, |
DW_OP_reg2 =0x52, |
DW_OP_reg3 =0x53, |
DW_OP_reg4 =0x54, |
DW_OP_reg5 =0x55, |
DW_OP_reg6 =0x56, |
DW_OP_reg7 =0x57, |
DW_OP_reg8 =0x58, |
DW_OP_reg9 =0x59, |
DW_OP_reg10 =0x5a, |
DW_OP_reg11 =0x5b, |
DW_OP_reg12 =0x5c, |
DW_OP_reg13 =0x5d, |
DW_OP_reg14 =0x5e, |
DW_OP_reg15 =0x5f, |
DW_OP_reg16 =0x60, |
DW_OP_reg17 =0x61, |
DW_OP_reg18 =0x62, |
DW_OP_reg19 =0x63, |
DW_OP_reg20 =0x64, |
DW_OP_reg21 =0x65, |
DW_OP_reg22 =0x66, |
DW_OP_reg23 =0x67, |
DW_OP_reg24 =0x68, |
DW_OP_reg25 =0x69, |
DW_OP_reg26 =0x6a, |
DW_OP_reg27 =0x6b, |
DW_OP_reg28 =0x6c, |
DW_OP_reg29 =0x6d, |
DW_OP_reg30 =0x6e, |
DW_OP_reg31 =0x6f, |
DW_OP_breg0 =0x70, |
DW_OP_breg1 =0x71, |
DW_OP_breg2 =0x72, |
DW_OP_breg3 =0x73, |
DW_OP_breg4 =0x74, |
DW_OP_breg5 =0x75, |
DW_OP_breg6 =0x76, |
DW_OP_breg7 =0x77, |
DW_OP_breg8 =0x78, |
DW_OP_breg9 =0x79, |
DW_OP_breg10 =0x7a, |
DW_OP_breg11 =0x7b, |
DW_OP_breg12 =0x7c, |
DW_OP_breg13 =0x7d, |
DW_OP_breg14 =0x7e, |
DW_OP_breg15 =0x7f, |
DW_OP_breg16 =0x80, |
DW_OP_breg17 =0x81, |
DW_OP_breg18 =0x82, |
DW_OP_breg19 =0x83, |
DW_OP_breg20 =0x84, |
DW_OP_breg21 =0x85, |
DW_OP_breg22 =0x86, |
DW_OP_breg23 =0x87, |
DW_OP_breg24 =0x88, |
DW_OP_breg25 =0x89, |
DW_OP_breg26 =0x8a, |
DW_OP_breg27 =0x8b, |
DW_OP_breg28 =0x8c, |
DW_OP_breg29 =0x8d, |
DW_OP_breg30 =0x8e, |
DW_OP_breg31 =0x8f, |
DW_OP_regX =0x90, |
DW_OP_fbreg =0x91, |
DW_OP_bregX =0x92, |
DW_OP_piece =0x93, |
DW_OP_deref_size =0x94, |
DW_OP_xderef_size =0x95, |
DW_OP_nop =0x96, |
// DWARF3/DWARF3f |
DW_OP_push_object_address =0x97, |
DW_OP_call2 =0x98, |
DW_OP_call4 =0x99, |
DW_OP_call_ref =0x9a, |
DW_OP_form_tls_address =0x9b, |
DW_OP_call_frame_cfa =0x9c, |
DW_OP_bit_piece =0x9d, |
DW_OP_lo_user =0xe0, |
DW_OP_hi_user =0xff, |
// GNU extensions |
DW_OP_GNU_push_tls_address =0xe0 |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_DWARF_H) |
/elfcpp_swap.h
0,0 → 1,435
// elfcpp_swap.h -- Handle swapping for elfcpp -*- C++ -*- |
|
// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
// This header file defines basic template classes to efficiently swap |
// numbers between host form and target form. When the host and |
// target have the same endianness, these turn into no-ops. |
|
#ifndef ELFCPP_SWAP_H |
#define ELFCPP_SWAP_H |
|
#include <stdint.h> |
|
// We need an autoconf-generated config.h file for endianness and |
// swapping. We check two macros: WORDS_BIGENDIAN and |
// HAVE_BYTESWAP_H. |
|
#include "config.h" |
|
#ifdef HAVE_BYTESWAP_H |
#include <byteswap.h> |
#else |
// Provide our own versions of the byteswap functions. |
inline uint16_t |
bswap_16(uint16_t v) |
{ |
return ((v >> 8) & 0xff) | ((v & 0xff) << 8); |
} |
|
inline uint32_t |
bswap_32(uint32_t v) |
{ |
return ( ((v & 0xff000000) >> 24) |
| ((v & 0x00ff0000) >> 8) |
| ((v & 0x0000ff00) << 8) |
| ((v & 0x000000ff) << 24)); |
} |
|
inline uint64_t |
bswap_64(uint64_t v) |
{ |
return ( ((v & 0xff00000000000000ULL) >> 56) |
| ((v & 0x00ff000000000000ULL) >> 40) |
| ((v & 0x0000ff0000000000ULL) >> 24) |
| ((v & 0x000000ff00000000ULL) >> 8) |
| ((v & 0x00000000ff000000ULL) << 8) |
| ((v & 0x0000000000ff0000ULL) << 24) |
| ((v & 0x000000000000ff00ULL) << 40) |
| ((v & 0x00000000000000ffULL) << 56)); |
} |
#endif // !defined(HAVE_BYTESWAP_H) |
|
// gcc 4.3 and later provides __builtin_bswap32 and __builtin_bswap64. |
|
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) |
#undef bswap_32 |
#define bswap_32 __builtin_bswap32 |
#undef bswap_64 |
#define bswap_64 __builtin_bswap64 |
#endif |
|
namespace elfcpp |
{ |
|
// Endian simply indicates whether the host is big endian or not. |
|
struct Endian |
{ |
public: |
// Used for template specializations. |
static const bool host_big_endian = |
#ifdef WORDS_BIGENDIAN |
true |
#else |
false |
#endif |
; |
}; |
|
// Valtype_base is a template based on size (8, 16, 32, 64) which |
// defines the type Valtype as the unsigned integer, and |
// Signed_valtype as the signed integer, of the specified size. |
|
template<int size> |
struct Valtype_base; |
|
template<> |
struct Valtype_base<8> |
{ |
typedef uint8_t Valtype; |
typedef int8_t Signed_valtype; |
}; |
|
template<> |
struct Valtype_base<16> |
{ |
typedef uint16_t Valtype; |
typedef int16_t Signed_valtype; |
}; |
|
template<> |
struct Valtype_base<32> |
{ |
typedef uint32_t Valtype; |
typedef int32_t Signed_valtype; |
}; |
|
template<> |
struct Valtype_base<64> |
{ |
typedef uint64_t Valtype; |
typedef int64_t Signed_valtype; |
}; |
|
// Convert_endian is a template based on size and on whether the host |
// and target have the same endianness. It defines the type Valtype |
// as Valtype_base does, and also defines a function convert_host |
// which takes an argument of type Valtype and returns the same value, |
// but swapped if the host and target have different endianness. |
|
template<int size, bool same_endian> |
struct Convert_endian; |
|
template<int size> |
struct Convert_endian<size, true> |
{ |
typedef typename Valtype_base<size>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ return v; } |
}; |
|
template<> |
struct Convert_endian<8, false> |
{ |
typedef Valtype_base<8>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ return v; } |
}; |
|
template<> |
struct Convert_endian<16, false> |
{ |
typedef Valtype_base<16>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ return bswap_16(v); } |
}; |
|
template<> |
struct Convert_endian<32, false> |
{ |
typedef Valtype_base<32>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ return bswap_32(v); } |
}; |
|
template<> |
struct Convert_endian<64, false> |
{ |
typedef Valtype_base<64>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ return bswap_64(v); } |
}; |
|
// Convert is a template based on size and on whether the target is |
// big endian. It defines Valtype and convert_host like |
// Convert_endian. That is, it is just like Convert_endian except in |
// the meaning of the second template parameter. |
|
template<int size, bool big_endian> |
struct Convert |
{ |
typedef typename Valtype_base<size>::Valtype Valtype; |
|
static inline Valtype |
convert_host(Valtype v) |
{ |
return Convert_endian<size, big_endian == Endian::host_big_endian> |
::convert_host(v); |
} |
}; |
|
// Swap is a template based on size and on whether the target is big |
// endian. It defines the type Valtype and the functions readval and |
// writeval. The functions read and write values of the appropriate |
// size out of buffers, swapping them if necessary. readval and |
// writeval are overloaded to take pointers to the appropriate type or |
// pointers to unsigned char. |
|
template<int size, bool big_endian> |
struct Swap |
{ |
typedef typename Valtype_base<size>::Valtype Valtype; |
|
static inline Valtype |
readval(const Valtype* wv) |
{ return Convert<size, big_endian>::convert_host(*wv); } |
|
static inline void |
writeval(Valtype* wv, Valtype v) |
{ *wv = Convert<size, big_endian>::convert_host(v); } |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ return readval(reinterpret_cast<const Valtype*>(wv)); } |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ writeval(reinterpret_cast<Valtype*>(wv), v); } |
}; |
|
// We need to specialize the 8-bit version of Swap to avoid |
// conflicting overloads, since both versions of readval and writeval |
// will have the same type parameters. |
|
template<bool big_endian> |
struct Swap<8, big_endian> |
{ |
typedef typename Valtype_base<8>::Valtype Valtype; |
|
static inline Valtype |
readval(const Valtype* wv) |
{ return *wv; } |
|
static inline void |
writeval(Valtype* wv, Valtype v) |
{ *wv = v; } |
}; |
|
// Swap_unaligned is a template based on size and on whether the |
// target is big endian. It defines the type Valtype and the |
// functions readval and writeval. The functions read and write |
// values of the appropriate size out of buffers which may be |
// misaligned. |
|
template<int size, bool big_endian> |
struct Swap_unaligned; |
|
template<bool big_endian> |
struct Swap_unaligned<8, big_endian> |
{ |
typedef typename Valtype_base<8>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ return *wv; } |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ *wv = v; } |
}; |
|
template<> |
struct Swap_unaligned<16, false> |
{ |
typedef Valtype_base<16>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return (wv[1] << 8) | wv[0]; |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[1] = v >> 8; |
wv[0] = v; |
} |
}; |
|
template<> |
struct Swap_unaligned<16, true> |
{ |
typedef Valtype_base<16>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return (wv[0] << 8) | wv[1]; |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[0] = v >> 8; |
wv[1] = v; |
} |
}; |
|
template<> |
struct Swap_unaligned<32, false> |
{ |
typedef Valtype_base<32>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return (wv[3] << 24) | (wv[2] << 16) | (wv[1] << 8) | wv[0]; |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[3] = v >> 24; |
wv[2] = v >> 16; |
wv[1] = v >> 8; |
wv[0] = v; |
} |
}; |
|
template<> |
struct Swap_unaligned<32, true> |
{ |
typedef Valtype_base<32>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return (wv[0] << 24) | (wv[1] << 16) | (wv[2] << 8) | wv[3]; |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[0] = v >> 24; |
wv[1] = v >> 16; |
wv[2] = v >> 8; |
wv[3] = v; |
} |
}; |
|
template<> |
struct Swap_unaligned<64, false> |
{ |
typedef Valtype_base<64>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return ((static_cast<Valtype>(wv[7]) << 56) |
| (static_cast<Valtype>(wv[6]) << 48) |
| (static_cast<Valtype>(wv[5]) << 40) |
| (static_cast<Valtype>(wv[4]) << 32) |
| (static_cast<Valtype>(wv[3]) << 24) |
| (static_cast<Valtype>(wv[2]) << 16) |
| (static_cast<Valtype>(wv[1]) << 8) |
| static_cast<Valtype>(wv[0])); |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[7] = v >> 56; |
wv[6] = v >> 48; |
wv[5] = v >> 40; |
wv[4] = v >> 32; |
wv[3] = v >> 24; |
wv[2] = v >> 16; |
wv[1] = v >> 8; |
wv[0] = v; |
} |
}; |
|
template<> |
struct Swap_unaligned<64, true> |
{ |
typedef Valtype_base<64>::Valtype Valtype; |
|
static inline Valtype |
readval(const unsigned char* wv) |
{ |
return ((static_cast<Valtype>(wv[0]) << 56) |
| (static_cast<Valtype>(wv[1]) << 48) |
| (static_cast<Valtype>(wv[2]) << 40) |
| (static_cast<Valtype>(wv[3]) << 32) |
| (static_cast<Valtype>(wv[4]) << 24) |
| (static_cast<Valtype>(wv[5]) << 16) |
| (static_cast<Valtype>(wv[6]) << 8) |
| static_cast<Valtype>(wv[7])); |
} |
|
static inline void |
writeval(unsigned char* wv, Valtype v) |
{ |
wv[0] = v >> 56; |
wv[1] = v >> 48; |
wv[2] = v >> 40; |
wv[3] = v >> 32; |
wv[4] = v >> 24; |
wv[5] = v >> 16; |
wv[6] = v >> 8; |
wv[7] = v; |
} |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_SWAP_H) |
/elfcpp_internal.h
0,0 → 1,240
// elfcpp_internal.h -- internals for elfcpp -*- C++ -*- |
|
// Copyright 2006, 2007, Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
// This is included by elfcpp.h, the external interface, but holds |
// information which we want to keep private. |
|
#ifndef ELFCPP_INTERNAL_H |
#define ELFCPP_INTERNAL_H |
|
namespace elfcpp |
{ |
|
namespace internal |
{ |
|
// The ELF file header. |
|
template<int size> |
struct Ehdr_data |
{ |
unsigned char e_ident[EI_NIDENT]; |
Elf_Half e_type; |
Elf_Half e_machine; |
Elf_Word e_version; |
typename Elf_types<size>::Elf_Addr e_entry; |
typename Elf_types<size>::Elf_Off e_phoff; |
typename Elf_types<size>::Elf_Off e_shoff; |
Elf_Word e_flags; |
Elf_Half e_ehsize; |
Elf_Half e_phentsize; |
Elf_Half e_phnum; |
Elf_Half e_shentsize; |
Elf_Half e_shnum; |
Elf_Half e_shstrndx; |
}; |
|
// An ELF section header. |
|
template<int size> |
struct Shdr_data |
{ |
Elf_Word sh_name; |
Elf_Word sh_type; |
typename Elf_types<size>::Elf_WXword sh_flags; |
typename Elf_types<size>::Elf_Addr sh_addr; |
typename Elf_types<size>::Elf_Off sh_offset; |
typename Elf_types<size>::Elf_WXword sh_size; |
Elf_Word sh_link; |
Elf_Word sh_info; |
typename Elf_types<size>::Elf_WXword sh_addralign; |
typename Elf_types<size>::Elf_WXword sh_entsize; |
}; |
|
// An ELF segment header. We use template specialization for the |
// 32-bit and 64-bit versions because the fields are in a different |
// order. |
|
template<int size> |
struct Phdr_data; |
|
template<> |
struct Phdr_data<32> |
{ |
Elf_Word p_type; |
Elf_types<32>::Elf_Off p_offset; |
Elf_types<32>::Elf_Addr p_vaddr; |
Elf_types<32>::Elf_Addr p_paddr; |
Elf_Word p_filesz; |
Elf_Word p_memsz; |
Elf_Word p_flags; |
Elf_Word p_align; |
}; |
|
template<> |
struct Phdr_data<64> |
{ |
Elf_Word p_type; |
Elf_Word p_flags; |
Elf_types<64>::Elf_Off p_offset; |
Elf_types<64>::Elf_Addr p_vaddr; |
Elf_types<64>::Elf_Addr p_paddr; |
Elf_Xword p_filesz; |
Elf_Xword p_memsz; |
Elf_Xword p_align; |
}; |
|
// An ELF symbol table entry. We use template specialization for the |
// 32-bit and 64-bit versions because the fields are in a different |
// order. |
|
template<int size> |
struct Sym_data; |
|
template<> |
struct Sym_data<32> |
{ |
Elf_Word st_name; |
Elf_types<32>::Elf_Addr st_value; |
Elf_Word st_size; |
unsigned char st_info; |
unsigned char st_other; |
Elf_Half st_shndx; |
}; |
|
template<> |
struct Sym_data<64> |
{ |
Elf_Word st_name; |
unsigned char st_info; |
unsigned char st_other; |
Elf_Half st_shndx; |
Elf_types<64>::Elf_Addr st_value; |
Elf_Xword st_size; |
}; |
|
// ELF relocation table entries. |
|
template<int size> |
struct Rel_data |
{ |
typename Elf_types<size>::Elf_Addr r_offset; |
typename Elf_types<size>::Elf_WXword r_info; |
}; |
|
template<int size> |
struct Rela_data |
{ |
typename Elf_types<size>::Elf_Addr r_offset; |
typename Elf_types<size>::Elf_WXword r_info; |
typename Elf_types<size>::Elf_Swxword r_addend; |
}; |
|
// An entry in the ELF SHT_DYNAMIC section aka PT_DYNAMIC segment. |
|
template<int size> |
struct Dyn_data |
{ |
typename Elf_types<size>::Elf_Swxword d_tag; |
typename Elf_types<size>::Elf_WXword d_val; |
}; |
|
// An entry in a SHT_GNU_verdef section. This structure is the same |
// in 32-bit and 64-bit ELF files. |
|
struct Verdef_data |
{ |
// Version number of structure (VER_DEF_*). |
Elf_Half vd_version; |
// Bit flags (VER_FLG_*). |
Elf_Half vd_flags; |
// Version index. |
Elf_Half vd_ndx; |
// Number of auxiliary Verdaux entries. |
Elf_Half vd_cnt; |
// Hash of name. |
Elf_Word vd_hash; |
// Byte offset to first Verdaux entry. |
Elf_Word vd_aux; |
// Byte offset to next Verdef entry. |
Elf_Word vd_next; |
}; |
|
// An auxiliary entry in a SHT_GNU_verdef section. This structure is |
// the same in 32-bit and 64-bit ELF files. |
|
struct Verdaux_data |
{ |
// Offset in string table of version name. |
Elf_Word vda_name; |
// Byte offset to next Verdaux entry. |
Elf_Word vda_next; |
}; |
|
// An entry in a SHT_GNU_verneed section. This structure is the same |
// in 32-bit and 64-bit ELF files. |
|
struct Verneed_data |
{ |
// Version number of structure (VER_NEED_*). |
Elf_Half vn_version; |
// Number of auxiliary Vernaux entries. |
Elf_Half vn_cnt; |
// Offset in string table of library name. |
Elf_Word vn_file; |
// Byte offset to first Vernaux entry. |
Elf_Word vn_aux; |
// Byt eoffset to next Verneed entry. |
Elf_Word vn_next; |
}; |
|
// An auxiliary entry in a SHT_GNU_verneed section. This structure is |
// the same in 32-bit and 64-bit ELF files. |
|
struct Vernaux_data |
{ |
// Hash of dependency name. |
Elf_Word vna_hash; |
// Bit flags (VER_FLG_*). |
Elf_Half vna_flags; |
// Version index used in SHT_GNU_versym entries. |
Elf_Half vna_other; |
// Offset in string table of version name. |
Elf_Word vna_name; |
// Byte offset to next Vernaux entry. |
Elf_Word vna_next; |
}; |
|
} // End namespace internal. |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_INTERNAL_H) |
/README
0,0 → 1,9
elfcpp is a C++ library for reading and writing ELF information. This |
was written to support gold, the ELF linker, and may not be generally |
useful. |
|
elfcpp does not do file I/O. It deals only with offsets and memory |
data. |
|
For efficiency, most accessors are templates with two arguments: the |
ELF file class (32 or 64 bits) and the endianness. |
/elfcpp_file.h
0,0 → 1,688
// elfcpp_file.h -- file access for elfcpp -*- C++ -*- |
|
// Copyright 2006, 2007, Free Software Foundation, Inc. |
// Written by Ian Lance Taylor <iant@google.com>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
// This header file defines the class Elf_file which can be used to |
// read useful data from an ELF file. The functions here are all |
// templates which take a file interface object as a parameter. This |
// type must have a subtype View. This type must support two methods: |
// View view(off_t file_offset, off_t data_size) |
// returns a View for the specified part of the file. |
// void error(const char* printf_format, ...) |
// prints an error message and does not return. The subtype View must |
// support a method |
// const unsigned char* data() |
// which returns a pointer to a buffer containing the requested data. |
// This general interface is used to read data from the file. Objects |
// of type View will never survive longer than the elfcpp function. |
|
// Some of these functions must return a reference to part of the |
// file. To use these, the file interface must support a subtype |
// Location: |
// Location(off_t file_offset, off_t data_size) |
// To use this in conjunction with the accessors types Shdr, etc., the |
// file interface should support an overload of view: |
// View view(Location) |
// This permits writing |
// elfcpp::Shdr shdr(file, ef.section_header(n)); |
|
#ifndef ELFCPP_FILE_H |
#define ELFCPP_FILE_H |
|
#include <string> |
#include <cstdio> |
#include <cstring> |
|
#include "elfcpp.h" |
|
namespace elfcpp |
{ |
|
// A simple helper class to recognize if a file has an ELF header. |
|
class Elf_recognizer |
{ |
public: |
// Maximum header size. The user should try to read this much of |
// the file when using this class. |
|
static const int max_header_size = Elf_sizes<64>::ehdr_size; |
|
// Checks if the file contains the ELF magic. Other header fields |
// are not checked. |
|
static bool |
is_elf_file(const unsigned char* ehdr_buf, int size); |
|
// Check if EHDR_BUF/BUFSIZE is a valid header of a 32-bit or |
// 64-bit, little-endian or big-endian ELF file. Assumes |
// is_elf_file() has been checked to be true. If the header is not |
// valid, *ERROR contains a human-readable error message. If is is, |
// *SIZE is set to either 32 or 64, *BIG_ENDIAN is set to indicate |
// whether the file is big-endian. |
|
static bool |
is_valid_header(const unsigned char* ehdr_buf, off_t bufsize, |
int* size, bool* big_endian, |
std::string* error); |
}; |
|
// This object is used to read an ELF file. |
// SIZE: The size of file, 32 or 64. |
// BIG_ENDIAN: Whether the file is in big-endian format. |
// FILE: A file reading type as described above. |
|
template<int size, bool big_endian, typename File> |
class Elf_file |
{ |
private: |
typedef Elf_file<size, big_endian, File> This; |
|
public: |
static const int ehdr_size = Elf_sizes<size>::ehdr_size; |
static const int phdr_size = Elf_sizes<size>::phdr_size; |
static const int shdr_size = Elf_sizes<size>::shdr_size; |
static const int sym_size = Elf_sizes<size>::sym_size; |
static const int rel_size = Elf_sizes<size>::rel_size; |
static const int rela_size = Elf_sizes<size>::rela_size; |
|
typedef Ehdr<size, big_endian> Ef_ehdr; |
typedef Phdr<size, big_endian> Ef_phdr; |
typedef Shdr<size, big_endian> Ef_shdr; |
typedef Sym<size, big_endian> Ef_sym; |
|
// Construct an Elf_file given an ELF file header. |
Elf_file(File* file, const Ef_ehdr& ehdr) |
{ this->construct(file, ehdr); } |
|
// Construct an ELF file. |
inline |
Elf_file(File* file); |
|
// Return the file offset to the section headers. |
off_t |
shoff() const |
{ return this->shoff_; } |
|
// Find the first section with an sh_type field equal to TYPE and |
// return its index. Returns SHN_UNDEF if there is no such section. |
unsigned int |
find_section_by_type(unsigned int type); |
|
// Return the number of sections. |
unsigned int |
shnum() |
{ |
this->initialize_shnum(); |
return this->shnum_; |
} |
|
// Return the section index of the section name string table. |
unsigned int |
shstrndx() |
{ |
this->initialize_shnum(); |
return this->shstrndx_; |
} |
|
// Return the value to subtract from section indexes >= |
// SHN_LORESERVE. See the comment in initialize_shnum. |
int |
large_shndx_offset() |
{ |
this->initialize_shnum(); |
return this->large_shndx_offset_; |
} |
|
// Return the location of the header of section SHNDX. |
typename File::Location |
section_header(unsigned int shndx) |
{ |
return typename File::Location(this->section_header_offset(shndx), |
shdr_size); |
} |
|
// Return the name of section SHNDX. |
std::string |
section_name(unsigned int shndx); |
|
// Return the location of the contents of section SHNDX. |
typename File::Location |
section_contents(unsigned int shndx); |
|
// Return the size of section SHNDX. |
typename Elf_types<size>::Elf_WXword |
section_size(unsigned int shndx); |
|
// Return the flags of section SHNDX. |
typename Elf_types<size>::Elf_WXword |
section_flags(unsigned int shndx); |
|
// Return the address of section SHNDX. |
typename Elf_types<size>::Elf_Addr |
section_addr(unsigned int shndx); |
|
// Return the type of section SHNDX. |
Elf_Word |
section_type(unsigned int shndx); |
|
// Return the link field of section SHNDX. |
Elf_Word |
section_link(unsigned int shndx); |
|
// Return the info field of section SHNDX. |
Elf_Word |
section_info(unsigned int shndx); |
|
// Return the addralign field of section SHNDX. |
typename Elf_types<size>::Elf_WXword |
section_addralign(unsigned int shndx); |
|
private: |
// Shared constructor code. |
void |
construct(File* file, const Ef_ehdr& ehdr); |
|
// Initialize shnum_ and shstrndx_. |
void |
initialize_shnum(); |
|
// Return the file offset of the header of section SHNDX. |
off_t |
section_header_offset(unsigned int shndx); |
|
// The file we are reading. |
File* file_; |
// The file offset to the section headers. |
off_t shoff_; |
// The number of sections. |
unsigned int shnum_; |
// The section index of the section name string table. |
unsigned int shstrndx_; |
// Offset to add to sections larger than SHN_LORESERVE. |
int large_shndx_offset_; |
}; |
|
// A small wrapper around SHT_STRTAB data mapped to memory. It checks that the |
// index is not out of bounds and the string is NULL-terminated. |
|
class Elf_strtab |
{ |
public: |
// Construct an Elf_strtab for a section with contents *P and size SIZE. |
Elf_strtab(const unsigned char* p, size_t size); |
|
// Return the file offset to the section headers. |
bool |
get_c_string(size_t offset, const char** cstring) const |
{ |
if (offset >= this->usable_size_) |
return false; |
*cstring = this->base_ + offset; |
return true; |
} |
|
private: |
// Contents of the section mapped to memory. |
const char* base_; |
// One larger that the position of the last NULL character in the section. |
// For valid SHT_STRTAB sections, this is the size of the section. |
size_t usable_size_; |
}; |
|
// Inline function definitions. |
|
// Check for presence of the ELF magic number. |
|
inline bool |
Elf_recognizer::is_elf_file(const unsigned char* ehdr_buf, int size) |
{ |
if (size < 4) |
return false; |
|
static unsigned char elfmagic[4] = |
{ |
elfcpp::ELFMAG0, elfcpp::ELFMAG1, |
elfcpp::ELFMAG2, elfcpp::ELFMAG3 |
}; |
return memcmp(ehdr_buf, elfmagic, 4) == 0; |
} |
|
namespace |
{ |
|
// Print a number to a string. |
|
inline std::string |
internal_printf_int(const char* format, int arg) |
{ |
char buf[256]; |
snprintf(buf, sizeof(buf), format, arg); |
return std::string(buf); |
} |
|
} // End anonymous namespace. |
|
// Check the validity of the ELF header. |
|
inline bool |
Elf_recognizer::is_valid_header( |
const unsigned char* ehdr_buf, |
off_t bufsize, |
int* size, |
bool* big_endian, |
std::string* error) |
{ |
if (bufsize < elfcpp::EI_NIDENT) |
{ |
*error = _("ELF file too short"); |
return false; |
} |
|
int v = ehdr_buf[elfcpp::EI_VERSION]; |
if (v != elfcpp::EV_CURRENT) |
{ |
if (v == elfcpp::EV_NONE) |
*error = _("invalid ELF version 0"); |
else |
*error = internal_printf_int(_("unsupported ELF version %d"), v); |
return false; |
} |
|
int c = ehdr_buf[elfcpp::EI_CLASS]; |
if (c == elfcpp::ELFCLASSNONE) |
{ |
*error = _("invalid ELF class 0"); |
return false; |
} |
else if (c != elfcpp::ELFCLASS32 |
&& c != elfcpp::ELFCLASS64) |
{ |
*error = internal_printf_int(_("unsupported ELF class %d"), c); |
return false; |
} |
|
int d = ehdr_buf[elfcpp::EI_DATA]; |
if (d == elfcpp::ELFDATANONE) |
{ |
*error = _("invalid ELF data encoding"); |
return false; |
} |
else if (d != elfcpp::ELFDATA2LSB |
&& d != elfcpp::ELFDATA2MSB) |
{ |
*error = internal_printf_int(_("unsupported ELF data encoding %d"), d); |
return false; |
} |
|
*big_endian = (d == elfcpp::ELFDATA2MSB); |
|
if (c == elfcpp::ELFCLASS32) |
{ |
if (bufsize < elfcpp::Elf_sizes<32>::ehdr_size) |
{ |
*error = _("ELF file too short"); |
return false; |
} |
*size = 32; |
} |
else |
{ |
if (bufsize < elfcpp::Elf_sizes<64>::ehdr_size) |
{ |
*error = _("ELF file too short"); |
return false; |
} |
*size = 64; |
} |
|
return true; |
} |
|
// Template function definitions. |
|
// Construct an Elf_file given an ELF file header. |
|
template<int size, bool big_endian, typename File> |
void |
Elf_file<size, big_endian, File>::construct(File* file, const Ef_ehdr& ehdr) |
{ |
this->file_ = file; |
this->shoff_ = ehdr.get_e_shoff(); |
this->shnum_ = ehdr.get_e_shnum(); |
this->shstrndx_ = ehdr.get_e_shstrndx(); |
this->large_shndx_offset_ = 0; |
if (ehdr.get_e_ehsize() != This::ehdr_size) |
file->error(_("bad e_ehsize (%d != %d)"), |
ehdr.get_e_ehsize(), This::ehdr_size); |
if (ehdr.get_e_shentsize() != This::shdr_size) |
file->error(_("bad e_shentsize (%d != %d)"), |
ehdr.get_e_shentsize(), This::shdr_size); |
} |
|
// Construct an ELF file. |
|
template<int size, bool big_endian, typename File> |
inline |
Elf_file<size, big_endian, File>::Elf_file(File* file) |
{ |
typename File::View v(file->view(file_header_offset, This::ehdr_size)); |
this->construct(file, Ef_ehdr(v.data())); |
} |
|
// Initialize the shnum_ and shstrndx_ fields, handling overflow. |
|
template<int size, bool big_endian, typename File> |
void |
Elf_file<size, big_endian, File>::initialize_shnum() |
{ |
if ((this->shnum_ == 0 || this->shstrndx_ == SHN_XINDEX) |
&& this->shoff_ != 0) |
{ |
typename File::View v(this->file_->view(this->shoff_, This::shdr_size)); |
Ef_shdr shdr(v.data()); |
|
if (this->shnum_ == 0) |
this->shnum_ = shdr.get_sh_size(); |
|
if (this->shstrndx_ == SHN_XINDEX) |
{ |
this->shstrndx_ = shdr.get_sh_link(); |
|
// Versions of the GNU binutils between 2.12 and 2.18 did |
// not handle objects with more than SHN_LORESERVE sections |
// correctly. All large section indexes were offset by |
// 0x100. Some information can be found here: |
// http://sourceware.org/bugzilla/show_bug.cgi?id=5900 . |
// Fortunately these object files are easy to detect, as the |
// GNU binutils always put the section header string table |
// near the end of the list of sections. Thus if the |
// section header string table index is larger than the |
// number of sections, then we know we have to subtract |
// 0x100 to get the real section index. |
if (this->shstrndx_ >= this->shnum_) |
{ |
if (this->shstrndx_ >= elfcpp::SHN_LORESERVE + 0x100) |
{ |
this->large_shndx_offset_ = - 0x100; |
this->shstrndx_ -= 0x100; |
} |
if (this->shstrndx_ >= this->shnum_) |
this->file_->error(_("bad shstrndx: %u >= %u"), |
this->shstrndx_, this->shnum_); |
} |
} |
} |
} |
|
// Find section with sh_type equal to TYPE and return its index. |
// Returns SHN_UNDEF if not found. |
|
template<int size, bool big_endian, typename File> |
unsigned int |
Elf_file<size, big_endian, File>::find_section_by_type(unsigned int type) |
{ |
unsigned int shnum = this->shnum(); |
typename File::View v(this->file_->view(this->shoff_, |
This::shdr_size * shnum)); |
for (unsigned int i = 0; i < shnum; i++) |
{ |
Ef_shdr shdr(v.data() + This::shdr_size * i); |
if (shdr.get_sh_type() == type) |
return i; |
} |
return SHN_UNDEF; |
} |
|
// Return the file offset of the section header of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
off_t |
Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) |
{ |
if (shndx >= this->shnum()) |
this->file_->error(_("section_header_offset: bad shndx %u >= %u"), |
shndx, this->shnum()); |
return this->shoff_ + This::shdr_size * shndx; |
} |
|
// Return the name of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
std::string |
Elf_file<size, big_endian, File>::section_name(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
// Get the section name offset. |
unsigned int sh_name; |
{ |
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
Ef_shdr shdr(v.data()); |
sh_name = shdr.get_sh_name(); |
} |
|
// Get the file offset for the section name string table data. |
off_t shstr_off; |
typename Elf_types<size>::Elf_WXword shstr_size; |
{ |
const unsigned int shstrndx = this->shstrndx_; |
typename File::View v(file->view(this->section_header_offset(shstrndx), |
This::shdr_size)); |
Ef_shdr shstr_shdr(v.data()); |
shstr_off = shstr_shdr.get_sh_offset(); |
shstr_size = shstr_shdr.get_sh_size(); |
} |
|
if (sh_name >= shstr_size) |
file->error(_("bad section name offset for section %u: %u"), |
shndx, sh_name); |
|
typename File::View v(file->view(shstr_off, shstr_size)); |
|
const unsigned char* datau = v.data(); |
const char* data = reinterpret_cast<const char*>(datau); |
const void* p = ::memchr(data + sh_name, '\0', shstr_size - sh_name); |
if (p == NULL) |
file->error(_("missing null terminator for name of section %u"), |
shndx); |
|
size_t len = static_cast<const char*>(p) - (data + sh_name); |
|
return std::string(data + sh_name, len); |
} |
|
// Return the contents of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
typename File::Location |
Elf_file<size, big_endian, File>::section_contents(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_contents: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
Ef_shdr shdr(v.data()); |
return typename File::Location(shdr.get_sh_offset(), shdr.get_sh_size()); |
} |
|
// Get the size of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
typename Elf_types<size>::Elf_WXword |
Elf_file<size, big_endian, File>::section_size(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_size: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_size(); |
} |
|
// Return the section flags of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
typename Elf_types<size>::Elf_WXword |
Elf_file<size, big_endian, File>::section_flags(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_flags: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_flags(); |
} |
|
// Return the address of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
typename Elf_types<size>::Elf_Addr |
Elf_file<size, big_endian, File>::section_addr(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_flags: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_addr(); |
} |
|
// Return the type of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
Elf_Word |
Elf_file<size, big_endian, File>::section_type(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_type: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_type(); |
} |
|
// Return the sh_link field of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
Elf_Word |
Elf_file<size, big_endian, File>::section_link(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_link: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_link(); |
} |
|
// Return the sh_info field of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
Elf_Word |
Elf_file<size, big_endian, File>::section_info(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_info: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_info(); |
} |
|
// Return the sh_addralign field of section SHNDX. |
|
template<int size, bool big_endian, typename File> |
typename Elf_types<size>::Elf_WXword |
Elf_file<size, big_endian, File>::section_addralign(unsigned int shndx) |
{ |
File* const file = this->file_; |
|
if (shndx >= this->shnum()) |
file->error(_("section_addralign: bad shndx %u >= %u"), |
shndx, this->shnum()); |
|
typename File::View v(file->view(this->section_header_offset(shndx), |
This::shdr_size)); |
|
Ef_shdr shdr(v.data()); |
return shdr.get_sh_addralign(); |
} |
|
inline |
Elf_strtab::Elf_strtab(const unsigned char* p, size_t size) |
{ |
// Check if the section is NUL-terminated. If it isn't, we ignore |
// the last part to make sure we don't return non-NUL-terminated |
// strings. |
while (size > 0 && p[size - 1] != 0) |
size--; |
this->base_ = reinterpret_cast<const char*>(p); |
this->usable_size_ = size; |
} |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_FILE_H) |
/sparc.h
0,0 → 1,171
// sparc.h -- ELF definitions specific to EM_SPARC -*- C++ -*- |
|
// Copyright 2008, 2010 Free Software Foundation, Inc. |
// Written by David S. Miller <davem@davemloft.net>. |
|
// This file is part of elfcpp. |
|
// This program is free software; you can redistribute it and/or |
// modify it under the terms of the GNU Library General Public License |
// as published by the Free Software Foundation; either version 2, or |
// (at your option) any later version. |
|
// In addition to the permissions in the GNU Library General Public |
// License, the Free Software Foundation gives you unlimited |
// permission to link the compiled version of this file into |
// combinations with other programs, and to distribute those |
// combinations without any restriction coming from the use of this |
// file. (The Library Public License restrictions do apply in other |
// respects; for example, they cover modification of the file, and |
/// distribution when not linked into a combined executable.) |
|
// This program is distributed in the hope that it will be useful, but |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// Library General Public License for more details. |
|
// You should have received a copy of the GNU Library General Public |
// License along with this program; if not, write to the Free Software |
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
// 02110-1301, USA. |
|
#ifndef ELFCPP_SPARC_H |
#define ELFCPP_SPARC_H |
|
// Documentation for the TLS relocs is taken from |
// http://people.redhat.com/drepper/tls.pdf |
// |
// More full documentation on sparc specific ELF file |
// format details can be found at |
// |
// http://docs.sun.com/app/docs/doc/819/0690/ |
// "Linker and Libraries Guide" |
// |
// specifically Chapter 7 "Object File Format" and |
// Chapter 8 "Thread-Local Storage" |
|
namespace elfcpp |
{ |
|
enum |
{ |
R_SPARC_NONE = 0, // No reloc |
R_SPARC_8 = 1, // Direct 8 bit |
R_SPARC_16 = 2, // Direct 16 bit |
R_SPARC_32 = 3, // Direct 32 bit |
R_SPARC_DISP8 = 4, // PC relative 8 bit |
R_SPARC_DISP16 = 5, // PC relative 16 bit |
R_SPARC_DISP32 = 6, // PC relative 32 bit |
R_SPARC_WDISP30 = 7, // PC relative 30 bit shifted |
R_SPARC_WDISP22 = 8, // PC relative 22 bit shifted |
R_SPARC_HI22 = 9, // High 22 bit |
R_SPARC_22 = 10, // Direct 22 bit |
R_SPARC_13 = 11, // Direct 13 bit |
R_SPARC_LO10 = 12, // Truncated 10 bit |
R_SPARC_GOT10 = 13, // Truncated 10 bit GOT entry |
R_SPARC_GOT13 = 14, // 13 bit GOT entry |
R_SPARC_GOT22 = 15, // 22 bit GOT entry shifted |
R_SPARC_PC10 = 16, // PC relative 10 bit truncated |
R_SPARC_PC22 = 17, // PC relative 22 bit shifted |
R_SPARC_WPLT30 = 18, // 30 bit PC relative PLT address |
R_SPARC_COPY = 19, // Copy symbol at runtime |
R_SPARC_GLOB_DAT = 20, // Create GOT entry |
R_SPARC_JMP_SLOT = 21, // Create PLT entry |
R_SPARC_RELATIVE = 22, // Adjust by program base |
R_SPARC_UA32 = 23, // Direct 32 bit unaligned |
R_SPARC_PLT32 = 24, // Direct 32 bit ref to PLT entry |
R_SPARC_HIPLT22 = 25, // High 22 bit PLT entry |
R_SPARC_LOPLT10 = 26, // Truncated 10 bit PLT entry |
R_SPARC_PCPLT32 = 27, // PC rel 32 bit ref to PLT entry |
R_SPARC_PCPLT22 = 28, // PC rel high 22 bit PLT entry |
R_SPARC_PCPLT10 = 29, // PC rel trunc 10 bit PLT entry |
R_SPARC_10 = 30, // Direct 10 bit |
R_SPARC_11 = 31, // Direct 11 bit |
R_SPARC_64 = 32, // Direct 64 bit |
R_SPARC_OLO10 = 33, // 10bit with secondary 13bit addend |
R_SPARC_HH22 = 34, // Top 22 bits of direct 64 bit |
R_SPARC_HM10 = 35, // High middle 10 bits of ... |
R_SPARC_LM22 = 36, // Low middle 22 bits of ... |
R_SPARC_PC_HH22 = 37, // Top 22 bits of pc rel 64 bit |
R_SPARC_PC_HM10 = 38, // High middle 10 bit of ... |
R_SPARC_PC_LM22 = 39, // Low miggle 22 bits of ... |
R_SPARC_WDISP16 = 40, // PC relative 16 bit shifted |
R_SPARC_WDISP19 = 41, // PC relative 19 bit shifted |
R_SPARC_GLOB_JMP = 42, // was part of v9 ABI but was removed |
R_SPARC_7 = 43, // Direct 7 bit |
R_SPARC_5 = 44, // Direct 5 bit |
R_SPARC_6 = 45, // Direct 6 bit |
R_SPARC_DISP64 = 46, // PC relative 64 bit |
R_SPARC_PLT64 = 47, // Direct 64 bit ref to PLT entry |
R_SPARC_HIX22 = 48, // High 22 bit complemented |
R_SPARC_LOX10 = 49, // Truncated 11 bit complemented |
R_SPARC_H44 = 50, // Direct high 12 of 44 bit |
R_SPARC_M44 = 51, // Direct mid 22 of 44 bit |
R_SPARC_L44 = 52, // Direct low 10 of 44 bit |
R_SPARC_REGISTER = 53, // Global register usage |
R_SPARC_UA64 = 54, // Direct 64 bit unaligned |
R_SPARC_UA16 = 55, // Direct 16 bit unaligned |
R_SPARC_TLS_GD_HI22 = 56, // Initial General Dynamic reloc, high 22-bit |
R_SPARC_TLS_GD_LO10 = 57, // Initial General Dynamic reloc, low 10-bit |
R_SPARC_TLS_GD_ADD = 58, // Initial General Dynamic reloc, add |
R_SPARC_TLS_GD_CALL = 59, // Initial General Dynamic reloc, call |
R_SPARC_TLS_LDM_HI22 = 60, // Initial Local Dynamic reloc, high 22-bit |
R_SPARC_TLS_LDM_LO10 = 61, // Initial Local Dynamic reloc, low 10-bit |
R_SPARC_TLS_LDM_ADD = 62, // Initial Local Dynamic reloc, add |
R_SPARC_TLS_LDM_CALL = 63, // Initial Local Dynamic reloc, call |
R_SPARC_TLS_LDO_HIX22 = 64, // Initial Local Dynamic, high extended 22-bit |
R_SPARC_TLS_LDO_LOX10 = 65, // Initial Local Dynamic, low extended 10-bit |
R_SPARC_TLS_LDO_ADD = 66, // Initial Local Dynamic, add extended |
R_SPARC_TLS_IE_HI22 = 67, // Initial Initial Exec reloc, high 22-bit |
R_SPARC_TLS_IE_LO10 = 68, // Initial Initial Exec reloc, low 10-bit |
R_SPARC_TLS_IE_LD = 69, // Initial Initial Exec reloc, load 32-bit |
R_SPARC_TLS_IE_LDX = 70, // Initial Initial Exec reloc, load 64-bit |
R_SPARC_TLS_IE_ADD = 71, // Initial Initial Exec reloc, add |
R_SPARC_TLS_LE_HIX22 = 72, // Initial Local Exec reloc, high extended 22-bit |
R_SPARC_TLS_LE_LOX10 = 73, // Initial Local Exec reloc, low extended 10-bit |
R_SPARC_TLS_DTPMOD32 = 74, // Outstanding General/Local Dynamic reloc, 32-bit |
R_SPARC_TLS_DTPMOD64 = 75, // Outstanding General/Local Dynamic reloc, 64-bit |
R_SPARC_TLS_DTPOFF32 = 76, // Outstanding General Dynamic reloc, 32-bit |
R_SPARC_TLS_DTPOFF64 = 77, // Outstanding General Dynamic reloc, 64-bit |
R_SPARC_TLS_TPOFF32 = 78, // Outstanding Initial Exec reloc, 32-bit |
R_SPARC_TLS_TPOFF64 = 79, // Outstanding Initial Exec reloc, 64-bit |
|
// GOT data code transformations |
R_SPARC_GOTDATA_HIX22 = 80, |
R_SPARC_GOTDATA_LOX10 = 81, |
R_SPARC_GOTDATA_OP_HIX22 = 82, |
R_SPARC_GOTDATA_OP_LOX10 = 83, |
R_SPARC_GOTDATA_OP = 84, |
|
R_SPARC_H34 = 85, // Direct high 12 of 34 bit |
R_SPARC_SIZE32 = 86, // size of symbol, 32-bit |
R_SPARC_SIZE64 = 87, // size of symbol, 64-bit |
|
R_SPARC_IRELATIVE = 249, // Adjust indirectly by program base |
|
// GNU vtable garbage collection extensions. |
R_SPARC_GNU_VTINHERIT = 250, |
R_SPARC_GNU_VTENTRY = 251, |
|
R_SPARC_REV32 = 252, |
}; |
|
// e_flags values defined for sparc |
enum |
{ |
EF_SPARC_EXT_MASK = 0xffff00, // reserved for vendor extensions |
EF_SPARC_32PLUS_MASK = 0xffff00, // bits indicating V8+ type |
EF_SPARC_32PLUS = 0x000100, // generic V8+ features |
EF_SPARC_SUN_US1 = 0x000200, // Sun UltraSPARC-I extensions |
EF_SPARC_HAL_R1 = 0x000400, // HAL R1 extensions |
EF_SPARC_SUN_US3 = 0x000800, // Sun UltraSPARC-III extensions |
EF_SPARC_LEDATA = 0x800000, // little endian data |
EF_SPARCV9_MM = 0x3, // memory model mask |
EF_SPARCV9_TSO = 0x0, // total store ordering |
EF_SPARCV9_PSO = 0x1, // partial store ordering |
EF_SPARCV9_RMO = 0x2, // relaxed store ordering |
}; |
|
} // End namespace elfcpp. |
|
#endif // !defined(ELFCPP_SPARC_H) |