update
This commit is contained in:
104
idasdk75/ldr/elf/common.cpp
Normal file
104
idasdk75/ldr/elf/common.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Interactive disassembler (IDA)
|
||||
* Copyright (c) 1990-98 by Ilfak Guilfanov.
|
||||
* E-mail: ig@datarescue.com
|
||||
* ELF binary loader.
|
||||
* Copyright (c) 1995-2006 by Iouri Kharon.
|
||||
* E-mail: yjh@styx.cabel.net
|
||||
*
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <idp.hpp>
|
||||
|
||||
#include "elfbase.h"
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Functions common for EFD & DEBUGGER
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
static bool dummy_error_handler(const reader_t &, reader_t::errcode_t, ...)
|
||||
{
|
||||
// ignore all errors
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool is_elf_file(linput_t *li)
|
||||
{
|
||||
reader_t reader(li);
|
||||
reader.set_handler(dummy_error_handler);
|
||||
return reader.read_ident() && reader.read_header();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
inline bool can_be_solaris(reader_t &reader)
|
||||
{
|
||||
switch ( reader.get_header().e_machine )
|
||||
{
|
||||
case EM_SPARC:
|
||||
case EM_SPARC32PLUS:
|
||||
case EM_SPARC64:
|
||||
case EM_386:
|
||||
case EM_486:
|
||||
case EM_X86_64:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
int elf_machine_2_proc_module_id(reader_t &reader)
|
||||
{
|
||||
int id = -1;
|
||||
switch ( reader.get_header().e_machine )
|
||||
{
|
||||
#define CASE(E_ID, P_ID) case EM_##E_ID: id = PLFM_##P_ID; break
|
||||
CASE(ARM, ARM);
|
||||
CASE(SH, SH);
|
||||
CASE(PPC, PPC);
|
||||
CASE(PPC64, PPC);
|
||||
CASE(860, I860);
|
||||
CASE(68K, 68K);
|
||||
CASE(MIPS, MIPS);
|
||||
CASE(CISCO7200, MIPS);
|
||||
CASE(CISCO3620, MIPS);
|
||||
CASE(386, 386);
|
||||
CASE(486, 386);
|
||||
CASE(X86_64, 386);
|
||||
CASE(SPARC, SPARC);
|
||||
CASE(SPARC32PLUS, SPARC);
|
||||
CASE(SPARC64, SPARC);
|
||||
CASE(ALPHA, ALPHA);
|
||||
CASE(IA64, IA64);
|
||||
CASE(H8300, H8);
|
||||
CASE(H8300H, H8);
|
||||
CASE(H8S, H8);
|
||||
CASE(H8500, H8);
|
||||
CASE(V850, NEC_V850X);
|
||||
CASE(NECV850, NEC_V850X);
|
||||
CASE(PARISC, HPPA);
|
||||
CASE(6811, 6800);
|
||||
CASE(6812, MC6812);
|
||||
CASE(I960, I960);
|
||||
CASE(ARC, ARC);
|
||||
CASE(ARCOMPACT, ARC);
|
||||
CASE(ARC_COMPACT2, ARC);
|
||||
CASE(M32R, M32R);
|
||||
CASE(ST9, ST9);
|
||||
CASE(FR, FR);
|
||||
CASE(AVR, AVR);
|
||||
CASE(SPU, SPU);
|
||||
CASE(C166, C166);
|
||||
CASE(M16C, M16C);
|
||||
CASE(MN10200, MN102L00);
|
||||
// CASE(MN10300, MN103L00); // FIXME: Dunno what to do, here.
|
||||
// CASE(MCORE, MCORE); // FIXME: PLFM_MCORE still defined in mcore/reg.cpp
|
||||
CASE(S390, S390);
|
||||
#undef CASE
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
3136
idasdk75/ldr/elf/elf.h
Normal file
3136
idasdk75/ldr/elf/elf.h
Normal file
File diff suppressed because it is too large
Load Diff
999
idasdk75/ldr/elf/elfbase.h
Normal file
999
idasdk75/ldr/elf/elfbase.h
Normal file
@@ -0,0 +1,999 @@
|
||||
#ifndef __ELFBASE_H__
|
||||
#define __ELFBASE_H__
|
||||
#pragma pack(push, 4)
|
||||
|
||||
//=========================================================================
|
||||
struct elf_ident_t
|
||||
{
|
||||
uint32 magic;
|
||||
#if __MF__
|
||||
# define ELF_MAGIC 0x7F454C46 // big endian \x7FELF
|
||||
#else
|
||||
# define ELF_MAGIC 0x464C457F // litte endian \x7FELF
|
||||
#endif
|
||||
uint8 elf_class;
|
||||
#define ELFCLASSNONE 0 // Invalid class
|
||||
#define ELFCLASS32 1 // 32bit object
|
||||
#define ELFCLASS64 2 // 64bit object
|
||||
uint8 bytesex;
|
||||
#define ELFDATANONE 0 // Invalid data encoding
|
||||
#define ELFDATA2LSB 1 // low byte first
|
||||
#define ELFDATA2MSB 2 // high byte first
|
||||
uint8 version; // file version
|
||||
uint8 osabi; // Operating System/ABI indication
|
||||
#define ELFOSABI_NONE 0 // UNIX System V ABI
|
||||
#define ELFOSABI_HPUX 1 // HP-UX operating system
|
||||
#define ELFOSABI_NETBSD 2 // NetBSD
|
||||
#define ELFOSABI_LINUX 3 // GNU/Linux
|
||||
#define ELFOSABI_HURD 4 // GNU/Hurd
|
||||
#define ELFOSABI_SOLARIS 6 // Solaris
|
||||
#define ELFOSABI_AIX 7 // AIX
|
||||
#define ELFOSABI_IRIX 8 // IRIX
|
||||
#define ELFOSABI_FREEBSD 9 // FreeBSD
|
||||
#define ELFOSABI_TRU64 10 // TRU64 UNIX
|
||||
#define ELFOSABI_MODESTO 11 // Novell Modesto
|
||||
#define ELFOSABI_OPENBSD 12 // OpenBSD
|
||||
#define ELFOSABI_OPENVMS 13 // OpenVMS
|
||||
#define ELFOSABI_NSK 14 // Hewlett-Packard Non-Stop Kernel
|
||||
#define ELFOSABI_AROS 15 // Amiga Research OS
|
||||
#define ELFOSABI_C6000_ELFABI 64 // Texas Instruments TMS320C6 bare-metal
|
||||
#define ELFOSABI_C6000_LINUX 65 // TI TMS320C6 MMU-less Linux platform
|
||||
#define ELFOSABI_ARM 97 // ARM
|
||||
#define ELFOSABI_CELLOSLV2 102 // PS3 lv2 OS
|
||||
#define ELFOSABI_NACL 123 // ChromeOS Native Client
|
||||
#define ELFOSABI_STANDALONE 255 // Standalone (embedded) application
|
||||
uint8 abiversion; // ABI version
|
||||
uint8 pad[7];
|
||||
|
||||
bool is_valid() const { return magic == ELF_MAGIC; }
|
||||
bool is_msb() const { return bytesex == ELFDATA2MSB; }
|
||||
bool is_64() const { return elf_class == ELFCLASS64; }
|
||||
};
|
||||
|
||||
struct Elf32_Ehdr
|
||||
{
|
||||
elf_ident_t e_ident;
|
||||
uint16 e_type; // enum ET
|
||||
uint16 e_machine; // enum EM
|
||||
uint32 e_version; // enum EV
|
||||
uint32 e_entry; // virtual start address
|
||||
uint32 e_phoff; // off to program header table's (pht)
|
||||
uint32 e_shoff; // off to section header table's (sht)
|
||||
uint32 e_flags; // EF_machine_flag
|
||||
uint16 e_ehsize; // header's size
|
||||
uint16 e_phentsize; // size of pht element
|
||||
uint16 e_phnum; // entry counter in pht
|
||||
uint16 e_shentsize; // size of sht element
|
||||
uint16 e_shnum; // entry count in sht
|
||||
uint16 e_shstrndx; // sht index in name table
|
||||
};
|
||||
|
||||
|
||||
enum elf_ET
|
||||
{
|
||||
ET_NONE = 0, // No file type
|
||||
ET_REL = 1, // Relocatable file
|
||||
ET_EXEC = 2, // Executable file
|
||||
ET_DYN = 3, // Share object file
|
||||
ET_CORE = 4, // Core file
|
||||
ET_LOOS = 0xfe00u, // OS specific
|
||||
ET_HIOS = 0xfeffu, // OS specific
|
||||
ET_LOPROC = 0xff00u, // Processor specific
|
||||
ET_HIPROC = 0xffffu // Processor specific
|
||||
};
|
||||
|
||||
enum elf_EM
|
||||
{
|
||||
EM_NONE = 0, // No machine
|
||||
EM_M32 = 1, // AT & T WE 32100
|
||||
EM_SPARC = 2, // Sparc
|
||||
EM_386 = 3, // Intel 80386
|
||||
EM_68K = 4, // Motorola 68000
|
||||
EM_88K = 5, // Motorola 88000
|
||||
EM_486 = 6,
|
||||
//ATTENTION!!! in documentation present next values
|
||||
// EM_860 = 6, // Intel 80860
|
||||
// EM_MIPS = 7, // MIPS RS3000
|
||||
//in linux RS3000 = 8, !!!
|
||||
// taken from linux
|
||||
EM_860 = 7,
|
||||
EM_MIPS = 8, // Mips 3000 (officialy, big-endian only)
|
||||
EM_S370 = 9, // IBM System370
|
||||
EM_MIPS_RS3_BE = 10, // MIPS R3000 Big Endian
|
||||
// EM_SPARC_64 = 11, // SPARC v9
|
||||
EM_PARISC = 15, // HPPA
|
||||
EM_VPP550 = 17, // Fujitsu VPP500
|
||||
EM_SPARC32PLUS = 18, // Sun's v8plus
|
||||
EM_I960 = 19, // Intel 960
|
||||
EM_PPC = 20, // Power PC
|
||||
EM_PPC64 = 21, // 64-bit PowerPC
|
||||
EM_S390 = 22, // IBM S/390
|
||||
EM_SPU = 23, // Cell Broadband Engine Synergistic Processor Unit
|
||||
EM_CISCO7200 = 25, // Cisco 7200 Series Router (MIPS)
|
||||
EM_CISCO3620 = 30, // Cisco 3620/3640 Router (MIPS, IDT R4700)
|
||||
EM_V800 = 36, // NEC V800 series
|
||||
EM_FR20 = 37, // Fujitsu FR20
|
||||
EM_RH32 = 38, // TRW RH32
|
||||
EM_MCORE = 39, // Motorola M*Core (May also be taken by Fujitsu MMA)
|
||||
EM_ARM = 40, // ARM
|
||||
EM_OLD_ALPHA = 41, // Digital Alpha
|
||||
EM_SH = 42, // Renesas (formerly Hitachi) / SuperH SH
|
||||
EM_SPARC64 = 43, // Sparc v9 64-bit
|
||||
EM_TRICORE = 44, // Siemens Tricore embedded processor
|
||||
EM_ARC = 45, // ARC Cores
|
||||
EM_H8300 = 46, // Renesas (formerly Hitachi) H8/300
|
||||
EM_H8300H = 47, // Renesas (formerly Hitachi) H8/300H
|
||||
EM_H8S = 48, // Renesas (formerly Hitachi) H8S
|
||||
EM_H8500 = 49, // Renesas (formerly Hitachi) H8/500
|
||||
EM_IA64 = 50, // Intel Itanium IA64
|
||||
EM_MIPS_X = 51, // Stanford MIPS-X
|
||||
EM_COLDFIRE = 52, // Motorola Coldfire
|
||||
EM_6812 = 53, // Motorola MC68HC12
|
||||
EM_MMA = 54, // Fujitsu Multimedia Accelerator
|
||||
EM_PCP = 55, // Siemens PCP
|
||||
EM_NCPU = 56, // Sony nCPU embedded RISC processor
|
||||
EM_NDR1 = 57, // Denso NDR1 microprocesspr
|
||||
EM_STARCORE = 58, // Motorola Star*Core processor
|
||||
EM_ME16 = 59, // Toyota ME16 processor
|
||||
EM_ST100 = 60, // STMicroelectronics ST100 processor
|
||||
EM_TINYJ = 61, // Advanced Logic Corp. TinyJ embedded processor
|
||||
EM_X86_64 = 62, // Advanced Micro Devices X86-64 processor
|
||||
EM_PDSP = 63, // Sony DSP Processor
|
||||
EM_PDP10 = 64, // DEC PDP-10
|
||||
EM_PDP11 = 65, // DEC PDP-11
|
||||
EM_FX66 = 66, // Siemens FX66 microcontroller
|
||||
EM_ST9 = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
|
||||
EM_ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller
|
||||
EM_68HC16 = 69, // Motorola MC68HC16
|
||||
EM_6811 = 70, // Motorola MC68HC11
|
||||
EM_68HC08 = 71, // Motorola MC68HC08
|
||||
EM_68HC05 = 72, // Motorola MC68HC05
|
||||
EM_SVX = 73, // Silicon Graphics SVx
|
||||
EM_ST19 = 74, // STMicroelectronics ST19 8-bit cpu
|
||||
EM_VAX = 75, // Digital VAX
|
||||
EM_CRIS = 76, // Axis Communications 32-bit embedded processor
|
||||
EM_JAVELIN = 77, // Infineon Technologies 32-bit embedded cpu
|
||||
EM_FIREPATH = 78, // Element 14 64-bit DSP processor
|
||||
EM_ZSP = 79, // LSI Logic's 16-bit DSP processor
|
||||
EM_MMIX = 80, // Donald Knuth's educational 64-bit processor
|
||||
EM_HUANY = 81, // Harvard's machine-independent format
|
||||
EM_PRISM = 82, // SiTera Prism
|
||||
EM_AVR = 83, // Atmel AVR 8-bit microcontroller
|
||||
EM_FR = 84, // Fujitsu FR Family
|
||||
EM_D10V = 85, // Mitsubishi D10V
|
||||
EM_D30V = 86, // Mitsubishi D30V
|
||||
EM_V850 = 87, // NEC v850 (GNU compiler)
|
||||
|
||||
EM_NECV850E = 0x70FC, // ^
|
||||
EM_NECV850 = 0x70FF, // |
|
||||
EM_NECV850E2 = 0x71EA, // |
|
||||
EM_NECV850ES = 0x73CE, // |
|
||||
EM_NECV850E2R1 = 0x73FD, // |This group is used by the Renesas CA850 toolchain
|
||||
EM_NECV850E2R2 = 0x73FE, // |
|
||||
EM_NECV850E2R3 = 0x73FF, // |
|
||||
EM_NECV850E2R4 = 0x7400, // |
|
||||
EM_NECV850E3V5 = 0x74FB, // v
|
||||
|
||||
EM_CYGNUS_V850 = 0x9080,// V850 backend magic number. Written in the absense of an ABI.
|
||||
|
||||
EM_M32R = 88, // Renesas M32R (formerly Mitsubishi M32R)
|
||||
EM_MN10300 = 89, // Matsushita MN10300
|
||||
EM_MN10200 = 90, // Matsushita MN10200
|
||||
EM_PJ = 91, // picoJava
|
||||
EM_OPENRISC = 92, // OpenRISC 32-bit embedded processor
|
||||
EM_ARCOMPACT = 93, // ARC Cores (ARCompact ISA)
|
||||
EM_XTENSA = 94, // Tensilica Xtensa Architecture
|
||||
EM_VIDEOCORE = 95, // Alphamosaic VideoCore processor
|
||||
EM_TMM_GPP = 96, // Thompson Multimedia General Purpose Processor
|
||||
EM_NS32K = 97, // National Semiconductor 32000 series
|
||||
EM_TPC = 98, // Tenor Network TPC processor
|
||||
EM_SNP1K = 99, // Trebia SNP 1000 processor
|
||||
EM_ST200 = 100, // STMicroelectronics ST200 microcontroller
|
||||
EM_IP2K = 101, // Ubicom IP2022 micro controller
|
||||
EM_MAX = 102, // MAX Processor
|
||||
EM_CR = 103, // National Semiconductor CompactRISC
|
||||
EM_F2MC16 = 104, // Fujitsu F2MC16
|
||||
EM_MSP430 = 105, // TI msp430 micro controller
|
||||
EM_BLACKFIN = 106, // ADI Blackfin
|
||||
EM_SE_C33 = 107, // S1C33 Family of Seiko Epson processors
|
||||
EM_SEP = 108, // Sharp embedded microprocessor
|
||||
EM_ARCA = 109, // Arca RISC Microprocessor
|
||||
EM_UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
|
||||
EM_EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU
|
||||
EM_DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor
|
||||
EM_ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor
|
||||
EM_CRX = 114, // National Semiconductor CRX
|
||||
EM_XGATE = 115, // Motorola XGATE embedded processor
|
||||
EM_C166 = 116, // Infineon C16x/XC16x processor
|
||||
EM_M16C = 117, // Renesas M16C series microprocessors
|
||||
EM_DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal Controller
|
||||
EM_CE = 119, // Freescale Communication Engine RISC core
|
||||
EM_M32C = 120, // Renesas M32C series microprocessors
|
||||
EM_TSK3000 = 131, // Altium TSK3000 core
|
||||
EM_RS08 = 132, // Freescale RS08 embedded processor
|
||||
EM_ECOG2 = 134, // Cyan Technology eCOG2 microprocessor
|
||||
EM_SCORE = 135, // Sunplus Score
|
||||
EM_DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor
|
||||
EM_VIDEOCORE3 = 137, // Broadcom VideoCore III processor
|
||||
EM_LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
|
||||
EM_SE_C17 = 139, // Seiko Epson C17 family
|
||||
EM_TI_C6000 = 140, // Texas Instruments TMS320C6000 family
|
||||
EM_MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
|
||||
EM_CYPRESS_M8C = 161, // Cypress M8C microprocessor
|
||||
EM_R32C = 162, // Renesas R32C series microprocessors
|
||||
EM_TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family
|
||||
EM_QDSP6 = 164, // QUALCOMM DSP6 Processor
|
||||
EM_8051 = 165, // Intel 8051 and variants
|
||||
EM_STXP7X = 166, // STMicroelectronics STxP7x family
|
||||
EM_NDS32 = 167, // Andes Technology compact code size embedded RISC processor family
|
||||
EM_ECOG1 = 168, // Cyan Technology eCOG1X family
|
||||
EM_ECOG1X = 168, // Cyan Technology eCOG1X family
|
||||
EM_MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
|
||||
EM_XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor
|
||||
EM_MANIK = 171, // M2000 Reconfigurable RISC Microprocessor
|
||||
EM_CRAYNV2 = 172, // Cray Inc. NV2 vector architecture
|
||||
EM_RX = 173, // Renesas RX family
|
||||
EM_METAG = 174, // Imagination Technologies META processor architecture
|
||||
EM_MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture
|
||||
EM_ECOG16 = 176, // Cyan Technology eCOG16 family
|
||||
EM_CR16 = 177, // National Semiconductor CompactRISC 16-bit processor
|
||||
EM_ETPU = 178, // Freescale Extended Time Processing Unit
|
||||
EM_SLE9X = 179, // Infineon Technologies SLE9X core
|
||||
EM_L1OM = 180, // Intel L1OM (Larrabee)
|
||||
EM_K1OM = 181, // Intel K1OM
|
||||
EM_INTEL182 = 182, // Reserved by Intel
|
||||
EM_AARCH64 = 183, // ARM 64-bit architecture
|
||||
EM_ARM184 = 184, // Reserved by ARM
|
||||
EM_AVR32 = 185, // Atmel Corporation 32-bit microprocessor family
|
||||
EM_STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller
|
||||
EM_TILE64 = 187, // Tilera TILE64 multicore architecture family
|
||||
EM_TILEPRO = 188, // Tilera TILEPro multicore architecture family
|
||||
EM_MICROBLAZE = 189, // Xilinx MicroBlaze 32-bit RISC soft processor core
|
||||
EM_CUDA = 190, // NVIDIA CUDA architecture
|
||||
EM_TILEGX = 191, // Tilera TILE-Gx multicore architecture family
|
||||
EM_CLOUDSHIELD = 192, // CloudShield architecture family
|
||||
EM_COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family
|
||||
EM_COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family
|
||||
EM_ARC_COMPACT2 = 195, //Synopsys ARCompact V2
|
||||
EM_OPEN8 = 196, // Open8 8-bit RISC soft processor core
|
||||
EM_RL78 = 197, // Renesas RL78 family
|
||||
EM_VIDEOCORE5 = 198, // Broadcom VideoCore V processor
|
||||
EM_78K0R = 199, // Renesas 78K0R family
|
||||
EM_56800EX = 200, // Freescale 56800EX Digital Signal Controller
|
||||
EM_BA1 = 201, // Beyond BA1 CPU architecture
|
||||
EM_BA2 = 202, // Beyond BA2 CPU architecture
|
||||
EM_XCORE = 203, // XMOS xCORE processor family
|
||||
|
||||
EM_CYGNUS_POWERPC = 0x9025, // Cygnus PowerPC ELF backend
|
||||
EM_ALPHA = 0x9026, // DEC Alpha
|
||||
EM_S390_OLD = 0xa390 // old S/390 backend magic number. Written in the absence of an ABI.
|
||||
};
|
||||
|
||||
enum elf_EV
|
||||
{
|
||||
EV_NONE = 0, // None version
|
||||
EV_CURRENT = 1 // Current version
|
||||
// in linux header
|
||||
// EV_NUM = 2
|
||||
};
|
||||
|
||||
// special section indexes
|
||||
enum elh_SHN
|
||||
{
|
||||
SHN_UNDEF = 0, // undefined/missing/...
|
||||
SHN_LORESERVE = 0xff00,
|
||||
SHN_LOPROC = 0xff00,
|
||||
SHN_HIPROC = 0xff1f,
|
||||
SHN_ABS = 0xfff1, // absolute value
|
||||
SHN_COMMON = 0xfff2, // common values (fortran/c)
|
||||
SHN_XINDEX = 0xffff, // the escape value
|
||||
SHN_HIRESERVE = 0xffff
|
||||
};
|
||||
//==========
|
||||
|
||||
struct Elf32_Shdr
|
||||
{
|
||||
uint32 sh_name; // index in string table
|
||||
uint32 sh_type; // enum SHT
|
||||
uint32 sh_flags; // enum SHF
|
||||
uint32 sh_addr; // address in memory (or 0)
|
||||
uint32 sh_offset; // offset in file
|
||||
uint32 sh_size; // section size in bytes
|
||||
uint32 sh_link; // index in symbol table
|
||||
uint32 sh_info; // extra information
|
||||
uint32 sh_addralign; // 0 & 1 => no alignment
|
||||
uint32 sh_entsize; // size symbol table or eq.
|
||||
};
|
||||
|
||||
|
||||
enum elf_SHT
|
||||
{
|
||||
SHT_NULL = 0, // inactive - no assoc. section
|
||||
SHT_PROGBITS = 1, // internal program information
|
||||
SHT_SYMTAB = 2, // symbol table (static)
|
||||
SHT_STRTAB = 3, // string table
|
||||
SHT_RELA = 4, // relocation entries
|
||||
SHT_HASH = 5, // symbol hash table
|
||||
SHT_DYNAMIC = 6, // inf. for dynamic linking
|
||||
SHT_NOTE = 7, // additional info
|
||||
SHT_NOBITS = 8, // no placed in file
|
||||
SHT_REL = 9, // relocation entries without explicit address
|
||||
SHT_SHLIB = 10, // RESERVED
|
||||
SHT_DYNSYM = 11, // Dynamic Symbol Table
|
||||
SHT_COMDAT = 12, // COMDAT group directory -> SHT_HP_COMDAT */
|
||||
// abi 3
|
||||
SHT_INIT_ARRAY = 14, // Array of ptrs to init functions
|
||||
SHT_FINI_ARRAY = 15, // Array of ptrs to finish functions
|
||||
SHT_PREINIT_ARRAY = 16, // Array of ptrs to pre-init funcs
|
||||
SHT_GROUP = 17, // Section contains a section group
|
||||
SHT_SYMTAB_SHNDX = 18, // Indicies for SHN_XINDEX entries
|
||||
// SHT_NUM = 12,
|
||||
SHT_LOOS = 0x60000000ul,
|
||||
SHT_HIOS = 0x6ffffffful,
|
||||
SHT_LOPROC = 0x70000000ul,
|
||||
SHT_HIPROC = 0x7ffffffful,
|
||||
SHT_LOUSER = 0x80000000ul,
|
||||
SHT_HIUSER = 0xfffffffful,
|
||||
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
// 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,
|
||||
SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes.
|
||||
SHT_GNU_HASH = 0x6ffffff6, // GNU style dynamic hash table.
|
||||
SHT_GNU_LIBLIST = 0x6ffffff7, // List of prelink dependencies.
|
||||
SHT_GNU_verdef = 0x6ffffffd, // Versions defined by file.
|
||||
SHT_GNU_verneed = 0x6ffffffe, // Versions needed by file.
|
||||
SHT_GNU_versym = 0x6fffffff, // Symbol versions.
|
||||
|
||||
// http://docs.oracle.com/cd/E53394_01/html/E54813/chapter6-94076.html#OSLLGchapter6-73445
|
||||
SHT_SUNW_ancillary = 0x6fffffee,
|
||||
SHT_SUNW_capchain = 0x6fffffef,
|
||||
SHT_SUNW_capinfo = 0x6ffffff0,
|
||||
SHT_SUNW_symsort = 0x6ffffff1,
|
||||
SHT_SUNW_tlssort = 0x6ffffff2,
|
||||
SHT_SUNW_LDYNSYM = 0x6ffffff3,
|
||||
SHT_SUNW_dof = 0x6ffffff4,
|
||||
SHT_SUNW_cap = 0x6ffffff5,
|
||||
SHT_SUNW_SIGNATURE = 0x6ffffff6,
|
||||
SHT_SUNW_ANNOTATE = 0x6ffffff7,
|
||||
SHT_SUNW_DEBUGSTR = 0x6ffffff8,
|
||||
SHT_SUNW_DEBUG = 0x6ffffff9,
|
||||
SHT_SUNW_move = 0x6ffffffa,
|
||||
SHT_SUNW_COMDAT = 0x6ffffffb,
|
||||
SHT_SUNW_syminfo = 0x6ffffffc,
|
||||
SHT_SUNW_verdef = 0x6ffffffd,
|
||||
SHT_SUNW_verneed = 0x6ffffffe,
|
||||
SHT_SUNW_versym = 0x6fffffff,
|
||||
|
||||
// http://llvm.org/doxygen/namespacellvm_1_1ELF.html
|
||||
SHT_ANDROID_REL = 0x60000001,
|
||||
SHT_ANDROID_RELA = 0x60000002,
|
||||
};
|
||||
|
||||
// section by index 0 ==
|
||||
// { 0, SHT_NULL, 0, 0, 0, 0, SHN_UNDEF, 0, 0, 0 };
|
||||
|
||||
enum elf_SHF
|
||||
{
|
||||
SHF_WRITE = (1 << 0), // writable data
|
||||
SHF_ALLOC = (1 << 1), // occupies memory
|
||||
SHF_EXECINSTR = (1 << 2), // machine instruction
|
||||
|
||||
SHF_MERGE = (1 << 4), // can be merged
|
||||
SHF_STRINGS = (1 << 5), // contains nul-terminated strings
|
||||
SHF_INFO_LINK = (1 << 6), // sh_info contains SHT index
|
||||
SHF_LINK_ORDER = (1 << 7), // preserve order after combining
|
||||
SHF_OS_NONCONFORMING = (1 << 8), // non-standard os specific handling required
|
||||
SHF_GROUP = (1 << 9), // section is memory of a group
|
||||
SHF_TLS = (1 << 10), // section holds thread-local data
|
||||
SHF_COMPRESSED = (1 << 11), // section containing compressed data
|
||||
|
||||
SHF_MASKOS = 0x0ff00000, // os specific
|
||||
SHF_MASKPROC = 0xf0000000, // processor specific
|
||||
};
|
||||
|
||||
enum elf_GRP
|
||||
{
|
||||
GRP_COMDAT = 0x00000001, // This is a COMDAT group.
|
||||
GRP_MASKOS = 0x0ff00000, // OS-specific flags
|
||||
GRP_MASKPROC = 0xf0000000, // Processor-specific flags
|
||||
};
|
||||
|
||||
// COMDAT selection criteria.
|
||||
// (value of sh_info of a SHT_COMDAT section)
|
||||
// ref: OS/2 Application Binary Interface for PowerPC (32-bit)
|
||||
enum elf_COMDAT
|
||||
{
|
||||
COMDAT_NONE = 0, // Invalid selection criteria.
|
||||
COMDAT_NOMATCH =1, // Only one instance of a SHT_COMDAT section of the
|
||||
// given name is allowed.
|
||||
COMDAT_PICKANY =2, // Pick any instance of a SHT_COMDAT section of the
|
||||
// given name.
|
||||
COMDAT_SAMESIZE =3, // Pick any instance of a SHT_COMDAT section of the
|
||||
// given name but all instances of SHT_COMDAT
|
||||
// sections of the given name must have the same size.
|
||||
};
|
||||
|
||||
struct Elf32_Sym
|
||||
{
|
||||
uint32 st_name; // index in string table
|
||||
uint32 st_value; // absolute value or addr
|
||||
uint32 st_size; // 0-unknow or no, elsewere symbol size in bytes
|
||||
uchar st_info; // type and attribute (thee below)
|
||||
uchar st_other; // ==0
|
||||
uint16 st_shndx; // index in section header table
|
||||
};
|
||||
|
||||
#define ELF_ST_BIND(i) ((i)>>4)
|
||||
#define ELF_ST_TYPE(i) ((i)&0xf)
|
||||
#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
|
||||
/* This macro disassembles and assembles a symbol's visibility into
|
||||
the st_other field. The STV_ defines specificy the actual visibility. */
|
||||
#define ELF_ST_VISIBILITY(v) ((v) & 0x3)
|
||||
|
||||
enum elf_ST_BIND
|
||||
{
|
||||
STB_LOCAL = 0,
|
||||
STB_GLOBAL = 1,
|
||||
STB_WEAK = 2,
|
||||
STB_LOOS = 10, //OS-specific
|
||||
STB_GNU_UNIQUE = 10, // Symbol is unique in namespace
|
||||
STB_HIOS = 12,
|
||||
STB_LOPROC = 13, //processor-
|
||||
STB_HIPROC = 15, // specific
|
||||
STB_INVALID = 254
|
||||
};
|
||||
|
||||
enum elf_ST_TYPE
|
||||
{
|
||||
STT_NOTYPE = 0,
|
||||
STT_OBJECT = 1, // associated with data object
|
||||
STT_FUNC = 2, // associated with function or execut. code
|
||||
STT_SECTION = 3,
|
||||
STT_FILE = 4, // name of source file
|
||||
STT_COMMON = 5, // Uninitialized common section
|
||||
STT_TLS = 6, // TLS-data object
|
||||
STT_LOOS = 10, //OS-
|
||||
STT_HIOS = 12, // specific
|
||||
STT_LOPROC = 13, //processor-
|
||||
STT_HIPROC = 15, // specific
|
||||
STT_GNU_IFUNC = 10, // Symbol is an indirect code object
|
||||
};
|
||||
|
||||
enum elf_ST_VISIBILITY
|
||||
{
|
||||
STV_DEFAULT = 0, /* Visibility is specified by binding type */
|
||||
STV_INTERNAL = 1, /* OS specific version of STV_HIDDEN */
|
||||
STV_HIDDEN = 2, /* Can only be seen inside currect component */
|
||||
STV_PROTECTED = 3, /* Treat as STB_LOCAL inside current component */
|
||||
};
|
||||
|
||||
/* Special values for the st_other field in the symbol table. These
|
||||
are used in an Irix 5 dynamic symbol table. */
|
||||
enum elf_ST_OTHER
|
||||
{
|
||||
STO_DEFAULT = STV_DEFAULT,
|
||||
STO_INTERNAL = STV_INTERNAL,
|
||||
STO_HIDDEN = STV_HIDDEN,
|
||||
STO_PROTECTED = STV_PROTECTED,
|
||||
/* This bit is used on Irix to indicate a symbol whose definition
|
||||
is optional - if, at final link time, it cannot be found, no
|
||||
error message should be produced. */
|
||||
STO_OPTIONAL = (1 << 2),
|
||||
};
|
||||
|
||||
// relocation
|
||||
struct Elf32_Rel
|
||||
{
|
||||
uint32 r_offset; // virtual address
|
||||
uint32 r_info; // type of relocation
|
||||
};
|
||||
|
||||
#define ELF32_R_SYM(i) ((i)>>8)
|
||||
#define ELF32_R_TYPE(i) ((unsigned char)(i))
|
||||
#define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
|
||||
|
||||
struct Elf32_Rela
|
||||
{
|
||||
uint32 r_offset;
|
||||
uint32 r_info;
|
||||
int32 r_addend; // constant to compute
|
||||
};
|
||||
|
||||
struct Elf32_Chdr
|
||||
{
|
||||
uint32 ch_type;
|
||||
uint32 ch_size;
|
||||
uint32 ch_addralign;
|
||||
};
|
||||
|
||||
//=================Loading & dynamic linking========================
|
||||
// program header
|
||||
struct Elf32_Phdr
|
||||
{
|
||||
uint32 p_type; //Segment type. see below
|
||||
uint32 p_offset; //from beginning of file at 1 byte of segment resides
|
||||
uint32 p_vaddr; //virtual addr of 1 byte
|
||||
uint32 p_paddr; //reserved for system
|
||||
uint32 p_filesz; //may be 0
|
||||
uint32 p_memsz; //my be 0
|
||||
uint32 p_flags; // for PT_LOAD access mask (PF_xxx)
|
||||
uint32 p_align; //0/1-no,
|
||||
};
|
||||
|
||||
enum elf_SEGFLAGS
|
||||
{
|
||||
PF_X = (1 << 0), // Segment is executable
|
||||
PF_W = (1 << 1), // Segment is writable
|
||||
PF_R = (1 << 2), // Segment is readable
|
||||
|
||||
// PaX flags (for PT_PAX_FLAGS)
|
||||
PF_PAGEEXEC = (1 << 4), // Enable PAGEEXEC
|
||||
PF_NOPAGEEXEC = (1 << 5), // Disable PAGEEXEC
|
||||
PF_SEGMEXEC = (1 << 6), // Enable SEGMEXEC
|
||||
PF_NOSEGMEXEC = (1 << 7), // Disable SEGMEXEC
|
||||
PF_MPROTECT = (1 << 8), // Enable MPROTECT
|
||||
PF_NOMPROTECT = (1 << 9), // Disable MPROTECT
|
||||
PF_RANDEXEC = (1 << 10), // Enable RANDEXEC
|
||||
PF_NORANDEXEC = (1 << 11), // Disable RANDEXEC
|
||||
PF_EMUTRAMP = (1 << 12), // Enable EMUTRAMP
|
||||
PF_NOEMUTRAMP = (1 << 13), // Disable EMUTRAMP
|
||||
PF_RANDMMAP = (1 << 14), // Enable RANDMMAP
|
||||
PF_NORANDMMAP = (1 << 15), // Disable RANDMMAP
|
||||
|
||||
PF_MASKOS = 0x0FF00000, // OS-specific reserved bits
|
||||
PF_MASKPROC = 0xF0000000, // Processor-specific reserved bits
|
||||
};
|
||||
|
||||
enum elf_SEGTYPE
|
||||
{
|
||||
PT_NULL = 0, //ignore entries in program table
|
||||
PT_LOAD = 1, //loadable segmen described in _filesz & _memsz
|
||||
PT_DYNAMIC = 2, //dynamic linking information
|
||||
PT_INTERP = 3, //path name to interpreter (loadable)
|
||||
PT_NOTE = 4, //auxilarry information
|
||||
PT_SHLIB = 5, //reserved. Has no specified semantics
|
||||
PT_PHDR = 6, //location & size program header table
|
||||
PT_TLS = 7, //Thread local storage segment
|
||||
PT_LOOS = 0x60000000ul, // OS-
|
||||
PT_HIOS = 0x6ffffffful, // specific
|
||||
PT_LOPROC = 0x70000000ul, // processor-
|
||||
PT_HIPROC = 0x7ffffffful, // specific
|
||||
//
|
||||
PT_PAX_FLAGS = (PT_LOOS + 0x5041580), // PaX flags
|
||||
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
// The remaining values are not in the standard.
|
||||
PT_GNU_EH_FRAME = 0x6474e550, // Frame unwind information.
|
||||
PT_GNU_STACK = 0x6474e551, // Stack flags.
|
||||
PT_GNU_RELRO = 0x6474e552, // Read only after relocation.
|
||||
|
||||
// http://docs.oracle.com/cd/E53394_01/html/E54813/chapter6-83432.html#OSLLGchapter6-69880
|
||||
PT_SUNW_UNWIND = 0x6464e550,
|
||||
PT_SUNW_EH_FRAME = 0x6474e550,
|
||||
PT_SUNWBSS = 0x6ffffffa,
|
||||
PT_SUNWSTACK = 0x6ffffffb,
|
||||
PT_SUNWDTRACE = 0x6ffffffc,
|
||||
PT_SUNWCAP = 0x6ffffffd,
|
||||
};
|
||||
|
||||
//=================Dynamic section===============================
|
||||
struct Elf32_Dyn
|
||||
{
|
||||
int32 d_tag; //see below
|
||||
union
|
||||
{
|
||||
uint32 d_val; //integer value with various interpretation
|
||||
uint32 d_ptr; //programm virtual adress
|
||||
} d_un;
|
||||
};
|
||||
//extern Elf32_Dyn _DYNAMIC[];
|
||||
|
||||
enum elf_DTAG
|
||||
{
|
||||
DT_NULL = 0, //(-) end ofd _DYNAMIC array
|
||||
DT_NEEDED = 1, //(v) str-table offset name to needed library
|
||||
DT_PLTRELSZ = 2, //(v) tot.size in bytes of relocation entries
|
||||
DT_PLTGOT = 3, //(p) see below
|
||||
DT_HASH = 4, //(p) addr. of symbol hash table
|
||||
DT_STRTAB = 5, //(p) addr of string table
|
||||
DT_SYMTAB = 6, //(p) addr of symbol table
|
||||
DT_RELA = 7, //(p) addr of relocation table
|
||||
DT_RELASZ = 8, //(v) size in bytes of DT_RELA table
|
||||
DT_RELAENT = 9, //(v) size in bytes of DT_RELA entry
|
||||
DT_STRSZ = 10, //(v) size in bytes of string table
|
||||
DT_SYMENT = 11, //(v) size in byte of symbol table entry
|
||||
DT_INIT = 12, //(p) addr. of initialization function
|
||||
DT_FINI = 13, //(p) addr. of termination function
|
||||
DT_SONAME = 14, //(v) offs in str.-table - name of shared object
|
||||
DT_RPATH = 15, //(v) offs in str-table - search patch
|
||||
DT_SYMBOLIC = 16, //(-) start search of shared object
|
||||
DT_REL = 17, //(p) similar to DT_RELA
|
||||
DT_RELSZ = 18, //(v) tot.size in bytes of DT_REL
|
||||
DT_RELENT = 19, //(v) size in bytes of DT_REL entry
|
||||
DT_PLTREL = 20, //(v) type of relocation (DT_REL or DT_RELA)
|
||||
DT_DEBUG = 21, //(p) not specified
|
||||
DT_TEXTREL = 22, //(-) segment permisson
|
||||
DT_JMPREL = 23, //(p) addr of dlt procedure (if present)
|
||||
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,
|
||||
#define DF_ORIGIN 0x01
|
||||
#define DF_SYMBOLIC 0x02
|
||||
#define DF_TEXTREL 0x04
|
||||
#define DF_BIND_NOW 0x08
|
||||
#define DF_STATIC_TLS 0x10
|
||||
DT_ENCODING = 31,
|
||||
DT_PREINIT_ARRAY = 32,
|
||||
DT_PREINIT_ARRAYSZ = 33,
|
||||
DT_LOOS = 0x60000000ul, // OS-specific
|
||||
DT_HIOS = 0x6ffffffful, //
|
||||
|
||||
// http://docs.oracle.com/cd/E53394_01/html/E54813/chapter6-42444.html#OSLLGchapter6-tbl-52
|
||||
DT_SUNW_AUXILIARY = 0x6000000d,
|
||||
DT_SUNW_RTLDINF = 0x6000000e,
|
||||
DT_SUNW_FILTER = 0x6000000e,
|
||||
DT_SUNW_CAP = 0x60000010,
|
||||
DT_SUNW_SYMTAB = 0x60000011,
|
||||
DT_SUNW_SYMSZ = 0x60000012,
|
||||
DT_SUNW_ENCODING = 0x60000013,
|
||||
DT_SUNW_SORTENT = 0x60000013,
|
||||
DT_SUNW_SYMSORT = 0x60000014,
|
||||
DT_SUNW_SYMSORTSZ = 0x60000015,
|
||||
DT_SUNW_TLSSORT = 0x60000016,
|
||||
DT_SUNW_TLSSORTSZ = 0x60000017,
|
||||
DT_SUNW_CAPINFO = 0x60000018,
|
||||
DT_SUNW_STRPAD = 0x60000019,
|
||||
DT_SUNW_CAPCHAIN = 0x6000001a,
|
||||
DT_SUNW_LDMACH = 0x6000001b,
|
||||
DT_SUNW_CAPCHAINENT = 0x6000001d,
|
||||
DT_SUNW_CAPCHAINSZ = 0x6000001f,
|
||||
DT_SUNW_PARENT = 0x60000021,
|
||||
DT_SUNW_ASLR = 0x60000023,
|
||||
DT_SUNW_RELAX = 0x60000025,
|
||||
DT_SUNW_NXHEAP = 0x60000029,
|
||||
DT_SUNW_NXSTACK = 0x6000002b,
|
||||
|
||||
// https://github.com/amplab/ray-core/tree/master/src/tools/relocation_packer
|
||||
DT_ANDROID_REL = 0x6000000f,
|
||||
DT_ANDROID_RELSZ = 0x60000010,
|
||||
DT_ANDROID_RELA = 0x60000011,
|
||||
DT_ANDROID_RELASZ = 0x60000012,
|
||||
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
// Some of the values below are also present the Oracle documentation.
|
||||
// All of these types are supported both for GNU and Solaris.
|
||||
DT_VALRNGLO = 0x6ffffd00ul,
|
||||
DT_GNU_PRELINKED = 0x6ffffdf5ul,
|
||||
DT_GNU_CONFLICTSZ = 0x6ffffdf6ul,
|
||||
DT_GNU_LIBLISTSZ = 0x6ffffdf7ul,
|
||||
DT_CHECKSUM = 0x6ffffdf8ul,
|
||||
DT_PLTPADSZ = 0x6ffffdf9ul,
|
||||
DT_MOVEENT = 0x6ffffdfaul,
|
||||
DT_MOVESZ = 0x6ffffdfbul,
|
||||
DT_FEATURE = 0x6ffffdfcul,
|
||||
#define DTF_1_PARINIT 0x00000001
|
||||
#define DTF_1_CONFEXP 0x00000002
|
||||
DT_POSFLAG_1 = 0x6ffffdfdul,
|
||||
#define DF_P1_LAZYLOAD 0x00000001
|
||||
#define DF_P1_GROUPPERM 0x00000002
|
||||
DT_SYMINSZ = 0x6ffffdfeul,
|
||||
DT_SYMINENT = 0x6ffffdfful,
|
||||
DT_VALRNGHI = 0x6ffffdfful,
|
||||
DT_ADDRRNGLO = 0x6ffffe00ul,
|
||||
DT_GNU_HASH = 0x6ffffef5ul, // GNU-style hash table.
|
||||
DT_TLSDESC_PLT = 0x6ffffef6ul,
|
||||
DT_TLSDESC_GOT = 0x6ffffef7ul,
|
||||
DT_GNU_CONFLICT = 0x6ffffef8ul, // Start of conflict section
|
||||
DT_GNU_LIBLIST = 0x6ffffef9ul,
|
||||
DT_CONFIG = 0x6ffffefaul,
|
||||
DT_DEPAUDIT = 0x6ffffefbul,
|
||||
DT_AUDIT = 0x6ffffefcul,
|
||||
DT_PLTPAD = 0x6ffffefdul,
|
||||
DT_MOVETAB = 0x6ffffefeul,
|
||||
DT_SYMINFO = 0x6ffffefful,
|
||||
DT_ADDRRNGHI = 0x6ffffefful,
|
||||
DT_RELACOUNT = 0x6ffffff9ul,
|
||||
DT_RELCOUNT = 0x6ffffffaul,
|
||||
DT_FLAGS_1 = 0x6ffffffbul,
|
||||
#define DF_1_NOW 0x00000001
|
||||
#define DF_1_GLOBAL 0x00000002
|
||||
#define DF_1_GROUP 0x00000004
|
||||
#define DF_1_NODELETE 0x00000008
|
||||
#define DF_1_LOADFLTR 0x00000010
|
||||
#define DF_1_INITFIRST 0x00000020
|
||||
#define DF_1_NOOPEN 0x00000040
|
||||
#define DF_1_ORIGIN 0x00000080
|
||||
#define DF_1_DIRECT 0x00000100
|
||||
#define DF_1_TRANS 0x00000200
|
||||
#define DF_1_INTERPOSE 0x00000400
|
||||
#define DF_1_NODEFLIB 0x00000800
|
||||
#define DF_1_NODUMP 0x00001000
|
||||
#define DF_1_CONFALT 0x00002000
|
||||
#define DF_1_ENDFILTEE 0x00004000
|
||||
#define DF_1_DISPRELDNE 0x00008000
|
||||
#define DF_1_DISPRELPND 0x00010000
|
||||
#define DF_1_NODIRECT 0x00020000
|
||||
#define DF_1_IGNMULDEF 0x00040000
|
||||
#define DF_1_NOKSYMS 0x00080000
|
||||
#define DF_1_NOHDR 0x00100000
|
||||
#define DF_1_EDITED 0x00200000
|
||||
#define DF_1_NORELOC 0x00400000
|
||||
#define DF_1_SYMINTPOSE 0x00800000
|
||||
#define DF_1_GLOBAUDIT 0x01000000
|
||||
#define DF_1_SINGLETON 0x02000000
|
||||
#define DF_1_STUB 0x04000000
|
||||
#define DF_1_PIE 0x08000000
|
||||
#define DF_1_KMOD 0x10000000
|
||||
#define DF_1_WEAKFILTER 0x20000000
|
||||
#define DF_1_NOCOMMON 0x40000000
|
||||
DT_VERDEF = 0x6ffffffcul,
|
||||
DT_VERDEFNUM = 0x6ffffffdul,
|
||||
DT_VERNEED = 0x6ffffffeul,
|
||||
DT_VERNEEDNUM = 0x6ffffffful,
|
||||
DT_VERSYM = 0x6ffffff0ul,
|
||||
|
||||
//
|
||||
DT_LOPROC = 0x70000000ul, //(?) processor-
|
||||
DT_HIPROC = 0x7ffffffful, //(?) specific
|
||||
|
||||
//
|
||||
DT_AUXILIARY = 0x7ffffffdul,
|
||||
DT_USED = 0x7ffffffeul,
|
||||
DT_FILTER = 0x7ffffffful,
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// ELF Notes
|
||||
|
||||
enum
|
||||
{
|
||||
NT_GNU_ABI_TAG = 1,
|
||||
NT_GNU_HWCAP = 2,
|
||||
NT_GNU_BUILD_ID = 3,
|
||||
NT_GNU_GOLD_VERSION = 4,
|
||||
NT_GNU_PROPERTY_TYPE_0 = 5,
|
||||
};
|
||||
|
||||
#define NT_PRSTATUS 1
|
||||
#define NT_FPREGSET 2
|
||||
#define NT_PRPSINFO 3
|
||||
#define NT_TASKSTRUCT 4
|
||||
#define NT_AUXV 6
|
||||
#define NT_PRXFPREG 0x46e62b7f
|
||||
#define NT_PPC_VMX 0x100
|
||||
#define NT_PPC_VSX 0x102
|
||||
#define NT_PPC_TAR 0x103
|
||||
#define NT_PPC_PPR 0x104
|
||||
#define NT_PPC_DSCR 0x105
|
||||
#define NT_PPC_EBB 0x106
|
||||
#define NT_PPC_PMU 0x107
|
||||
#define NT_PPC_TM_CGPR 0x108
|
||||
#define NT_PPC_TM_CFPR 0x109
|
||||
#define NT_PPC_TM_CVMX 0x10a
|
||||
#define NT_PPC_TM_CVSX 0x10b
|
||||
#define NT_PPC_TM_SPR 0x10c
|
||||
#define NT_PPC_TM_CTAR 0x10d
|
||||
#define NT_PPC_TM_CPPR 0x10e
|
||||
#define NT_PPC_TM_CDSCR 0x10f
|
||||
#define NT_386_TLS 0x200
|
||||
#define NT_386_IOPERM 0x201
|
||||
#define NT_X86_XSTATE 0x202
|
||||
#define NT_S390_HIGH_GPRS 0x300
|
||||
#define NT_S390_TIMER 0x301
|
||||
#define NT_S390_TODCMP 0x302
|
||||
#define NT_S390_TODPREG 0x303
|
||||
#define NT_S390_CTRS 0x304
|
||||
#define NT_S390_PREFIX 0x305
|
||||
#define NT_S390_LAST_BREAK 0x306
|
||||
#define NT_S390_SYSTEM_CALL 0x307
|
||||
#define NT_S390_TDB 0x308
|
||||
#define NT_S390_VXRS_LOW 0x309
|
||||
#define NT_S390_VXRS_HIGH 0x30a
|
||||
#define NT_S390_GS_CB 0x30b
|
||||
#define NT_S390_GS_BC 0x30c
|
||||
#define NT_ARM_VFP 0x400
|
||||
#define NT_ARM_TLS 0x401
|
||||
#define NT_ARM_HW_BREAK 0x402
|
||||
#define NT_ARM_HW_WATCH 0x403
|
||||
#define NT_ARM_SVE 0x405
|
||||
#define NT_SIGINFO 0x53494749
|
||||
#define NT_FILE 0x46494c45
|
||||
|
||||
#define NT_PSTATUS 10
|
||||
#define NT_FPREGS 12
|
||||
#define NT_PSINFO 13
|
||||
#define NT_LWPSTATUS 16
|
||||
#define NT_LWPSINFO 17
|
||||
#define NT_WIN32PSTATUS 18
|
||||
|
||||
//===============================elf64 types=============================
|
||||
struct Elf64_Ehdr
|
||||
{
|
||||
elf_ident_t e_ident;
|
||||
uint16 e_type;
|
||||
uint16 e_machine;
|
||||
uint32 e_version;
|
||||
uint64 e_entry; // Entry point virtual address
|
||||
uint64 e_phoff; // Program header table file offset
|
||||
uint64 e_shoff; // Section header table file offset
|
||||
uint32 e_flags;
|
||||
uint16 e_ehsize;
|
||||
uint16 e_phentsize;
|
||||
uint16 e_phnum;
|
||||
uint16 e_shentsize;
|
||||
uint16 e_shnum;
|
||||
uint16 e_shstrndx;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Ehdr);
|
||||
|
||||
struct Elf64_Shdr
|
||||
{
|
||||
uint32 sh_name; // Section name, index in string tbl
|
||||
uint32 sh_type; // Type of section
|
||||
uint64 sh_flags; // Miscellaneous section attributes
|
||||
uint64 sh_addr; // Section virtual addr at execution
|
||||
uint64 sh_offset; // Section file offset
|
||||
uint64 sh_size; // Size of section in bytes
|
||||
uint32 sh_link; // Index of another section
|
||||
uint32 sh_info; // Additional section information
|
||||
uint64 sh_addralign; // Section alignment
|
||||
uint64 sh_entsize; // Entry size if section holds table
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Shdr);
|
||||
|
||||
//
|
||||
struct Elf64_Sym
|
||||
{
|
||||
uint32 st_name; // Symbol name, index in string tbl
|
||||
uint8 st_info; // Type and binding attributes
|
||||
uint8 st_other; // No defined meaning, 0
|
||||
uint16 st_shndx; // Associated section index
|
||||
uint64 st_value; // Value of the symbol
|
||||
uint64 st_size; // Associated symbol size
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Sym);
|
||||
|
||||
struct Elf64_Rel
|
||||
{
|
||||
uint64 r_offset; // Location at which to apply the action
|
||||
uint64 r_info; // index and type of relocation
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Rel);
|
||||
|
||||
struct Elf64_Rela
|
||||
{
|
||||
uint64 r_offset; // Location at which to apply the action
|
||||
uint64 r_info; // index and type of relocation
|
||||
int64 r_addend; // Constant addend used to compute value
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Rela);
|
||||
|
||||
struct Elf64_Chdr
|
||||
{
|
||||
uint32 ch_type;
|
||||
uint32 ch_reserved;
|
||||
uint64 ch_size;
|
||||
uint64 ch_addralign;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Chdr);
|
||||
|
||||
|
||||
//#define ELF64_R_SYM(i) ((i) >> 32)
|
||||
//#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
|
||||
//#define ELF64_R_INFO(s,t) (((bfd_vma) (s) << 32) + (bfd_vma) (t))
|
||||
#define ELF64_R_SYM(i) uint32((i) >> 32)
|
||||
#define ELF64_R_TYPE(i) uint32(i)
|
||||
|
||||
|
||||
struct Elf64_Phdr
|
||||
{
|
||||
uint32 p_type;
|
||||
uint32 p_flags;
|
||||
uint64 p_offset; // Segment file offset
|
||||
uint64 p_vaddr; // Segment virtual address
|
||||
uint64 p_paddr; // Segment physical address
|
||||
uint64 p_filesz; // Segment size in file
|
||||
uint64 p_memsz; // Segment size in memory
|
||||
uint64 p_align; // Segment alignment, file & memory
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Phdr);
|
||||
|
||||
struct Elf64_Dyn
|
||||
{
|
||||
uint64 d_tag; // entry tag value
|
||||
uint64 d_un;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf64_Dyn);
|
||||
//extern Elf64_Dyn _DYNAMIC[];
|
||||
|
||||
//=======================================================================
|
||||
// Version information types
|
||||
|
||||
struct Elf_Verdef
|
||||
{
|
||||
uint16 vd_version;
|
||||
uint16 vd_flags;
|
||||
uint16 vd_ndx;
|
||||
uint16 vd_cnt;
|
||||
uint32 vd_hash;
|
||||
uint32 vd_aux;
|
||||
uint32 vd_next;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf_Verdef);
|
||||
|
||||
// Flags for vd_flags
|
||||
#define VER_FLG_BASE 0x1
|
||||
#define VER_FLG_WEAK 0x2
|
||||
#define VER_FLG_INFO 0x4
|
||||
|
||||
struct Elf_Verdaux
|
||||
{
|
||||
uint32 vda_name;
|
||||
uint32 vda_next;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf_Verdaux);
|
||||
|
||||
struct Elf_Verneed
|
||||
{
|
||||
uint16 vn_version;
|
||||
uint16 vn_cnt;
|
||||
uint32 vn_file;
|
||||
uint32 vn_aux;
|
||||
uint32 vn_next;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf_Verneed);
|
||||
|
||||
struct Elf_Vernaux
|
||||
{
|
||||
uint32 vna_hash;
|
||||
uint16 vna_flags;
|
||||
uint16 vna_other;
|
||||
uint32 vna_name;
|
||||
uint32 vna_next;
|
||||
};
|
||||
DECLARE_TYPE_AS_MOVABLE(Elf_Vernaux);
|
||||
|
||||
//=======================================================================
|
||||
// Definitions for other modules
|
||||
|
||||
#define ELFNODE "$ elfnode" // value: Elf64_Ehdr
|
||||
#define ELF_PHT_TAG 'p' // supval(idx): Elf64_Phdr
|
||||
#define ELF_SHT_TAG 's' // supval(idx): Elf64_Shdr
|
||||
#define GOTNODE "$ got" // altval(0): GOT address + 1
|
||||
// altval(-1): size of the local GOT part (MIPS only)
|
||||
#define TLSNODE "$ tls" // altval(0): the TLS template address + 1
|
||||
// altval(-1): size of the TLS template
|
||||
// see tlsinfo2_t::create_tls_template()
|
||||
#define ATTRNODE "$ attributes" // hashval(vendorname) - nodeidx of netnode with attribute list
|
||||
// in that node:
|
||||
// supval(tag): string value
|
||||
// altval(tag): integer value + 1
|
||||
// Tag_compatibility uses both
|
||||
// Tag_also_compatible_with (for 'aeabi') stores sub-tag number in default altval
|
||||
// and its value in supval('c') or altval('c')
|
||||
#define ELFSEGMMAPPINGS "$ elfsegmmap" // Holds a list of mappings for segments, conceptually of the form:
|
||||
// (wanted_start_ea, wanted_size, mapped_start_ea)
|
||||
// Note: Only the segments whose mapped EA is *not* the EA that the
|
||||
// binary file advertises for that segment will be present in
|
||||
// this netnode, not all segments.
|
||||
// This netnode should be iterated on using altfirst/altnext.
|
||||
//
|
||||
// idx: wanted_start_ea
|
||||
// altval(idx): mapped_start_ea
|
||||
// altval(idx, 's'): wanted_size
|
||||
|
||||
#define ATTR_VENDOR_EABI "aeabi"
|
||||
#define ATTR_VENDOR_GNU "gnu"
|
||||
#define ATTR_VENDOR_ARM "ARM"
|
||||
|
||||
#pragma pack(pop)
|
||||
#endif // __ELFBASE_H__
|
||||
548
idasdk75/ldr/elf/elfr_arm.h
Normal file
548
idasdk75/ldr/elf/elfr_arm.h
Normal file
@@ -0,0 +1,548 @@
|
||||
#ifndef __ELFR_ARM_H__
|
||||
#define __ELFR_ARM_H__
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#ifndef __ELFBASE_H__
|
||||
#include "elfbase.h"
|
||||
#endif
|
||||
|
||||
// relocation field - word32 with HIGH BYTE FIRST!!!
|
||||
// A- from Elf32_Rela
|
||||
// B- Loading address of shared object (REAL section when symbol defined)
|
||||
// (not) G- offset into global objet table
|
||||
// (not) GOT- adress of global object table
|
||||
// (not) L- linkage table entry
|
||||
// P- place of storage unit (computed using r_offset)
|
||||
// S- value of symbol
|
||||
enum elf_RTYPE_arm
|
||||
{
|
||||
|
||||
R_ARM_NONE = 0, //No reloc
|
||||
R_ARM_PC24 = 1, // S-P+A (relative 26 bit branch)
|
||||
R_ARM_ABS32 = 2, // S+A
|
||||
R_ARM_REL32 = 3, // S-P+A
|
||||
R_ARM_LDR_PC_G0 = 4, // S-P+A
|
||||
R_ARM_ABS16 = 5, // S+A
|
||||
R_ARM_ABS12 = 6, // S+A
|
||||
R_ARM_THM_ABS5 = 7, // S+A
|
||||
R_ARM_ABS8 = 8, // S+A
|
||||
R_ARM_SBREL32 = 9, // S-B+A
|
||||
R_ARM_THM_CALL = 10, // S-P+A
|
||||
R_ARM_THM_PC8 = 11, // S-P+A
|
||||
R_ARM_BREL_ADJ = 12, // S-B+A
|
||||
R_ARM_TLS_DESC = 13, //
|
||||
R_ARM_THM_SWI8 = 14, // S+A (obsolete)
|
||||
R_ARM_XPC25 = 15, // S-P+A (obsolete)
|
||||
R_ARM_THM_XPC22 = 16, // S-P+A (obsolete)
|
||||
R_ARM_TLS_DTPMOD32 = 17, /* ID of module containing symbol */
|
||||
R_ARM_TLS_DTPOFF32 = 18, /* Offset in TLS block */
|
||||
R_ARM_TLS_TPOFF32 = 19, /* Offset in static TLS block */
|
||||
// linux-specific
|
||||
R_ARM_COPY = 20, // none (copy symbol at runtime)
|
||||
R_ARM_GLOB_DAT = 21, // S (create .got entry)
|
||||
R_ARM_JUMP_SLOT = 22, // S (create .plt entry)
|
||||
R_ARM_RELATIVE = 23, // B+A (adjust by programm base)
|
||||
R_ARM_GOTOFF32 = 24, // S+A-GOT (32bit offset to .got)
|
||||
R_ARM_BASE_PREL = 25, // B+A-P
|
||||
R_ARM_GOT_BREL = 26, // G+A-GOT (32bit .got entry)
|
||||
R_ARM_PLT32 = 27, // L+A-P (32bit .plt entry)
|
||||
|
||||
R_ARM_CALL = 28,
|
||||
R_ARM_JUMP24 = 29,
|
||||
R_ARM_THM_JUMP24 = 30, // ((S + A) | T) - P
|
||||
R_ARM_BASE_ABS = 31, // B + A
|
||||
R_ARM_ALU_PCREL7_0 = 32,
|
||||
R_ARM_ALU_PCREL15_8 = 33,
|
||||
R_ARM_ALU_PCREL23_15 = 34,
|
||||
R_ARM_LDR_SBREL_11_0 = 35,
|
||||
R_ARM_ALU_SBREL_19_12 = 36,
|
||||
R_ARM_ALU_SBREL_27_20 = 37,
|
||||
R_ARM_TARGET1 = 38,
|
||||
R_ARM_ROSEGREL32 = 39,
|
||||
R_ARM_V4BX = 40,
|
||||
R_ARM_TARGET2 = 41,
|
||||
R_ARM_PREL31 = 42,
|
||||
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
|
||||
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, // G+A
|
||||
R_ARM_GOT_PREL = 96, // G+A-P
|
||||
R_ARM_GOT_BREL12 = 97, // G+A-GOT
|
||||
R_ARM_GOTOFF12 = 98, // S+A-GOT
|
||||
R_ARM_GOTRELAX = 99,
|
||||
R_ARM_GNU_VTENTRY = 100,
|
||||
R_ARM_GNU_VTINHERIT = 101,
|
||||
|
||||
R_ARM_THM_PC11 = 102, /* Cygnus extension to abi: Thumb unconditional branch. */
|
||||
R_ARM_THM_PC9 = 103, /* Cygnus extension to abi: Thumb conditional branch. */
|
||||
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
|
||||
R_ARM_THM_GOT_BREL12 = 131, // GOT entry relative to GOT origin, 12 bit (Thumb32 LDR).
|
||||
R_ARM_THM_ALU_ABS_G0_NC = 132,
|
||||
R_ARM_THM_ALU_ABS_G1_NC = 133,
|
||||
R_ARM_THM_ALU_ABS_G2_NC = 134,
|
||||
R_ARM_THM_ALU_ABS_G3_NC = 135,
|
||||
|
||||
// 136 - 139 Unallocated
|
||||
// 140 - 159 Dynamic Reserved for future allocation
|
||||
|
||||
R_ARM_IRELATIVE = 160,
|
||||
|
||||
// 161 - 255 Unallocated
|
||||
|
||||
//
|
||||
//ATT: R_ARM_RXPC25 used ONLY in OLD_ABI (+ 15 OTHER relocs!)
|
||||
// dynamic sections only
|
||||
R_ARM_RXPC25 = 249, // (BLX) call between segments
|
||||
//
|
||||
R_ARM_RSBREL32 = 250, // (Word) SBrelative offset
|
||||
R_ARM_THM_RPC22 = 251, // (Thumb BL/BLX) call between segments
|
||||
R_ARM_RREL32 = 252, // (Word) inter-segment offset
|
||||
R_ARM_RABS32 = 253, // (Word) Target segment displacement
|
||||
R_ARM_RPC24 = 254, // (BL/BLX) call between segment
|
||||
R_ARM_RBASE = 255 // segment being relocated
|
||||
};
|
||||
|
||||
// X is the result of a relocation operation, before any masking or bit-selection
|
||||
// Page(expr) is the page address of the expression expr, defined as (expr & ~0xFFF)
|
||||
// GOT is the address of the Global Offset Table
|
||||
// GDAT(S+A) represents a 64-bit entry in the GOT for address S+A
|
||||
// G(expr) is the address of the GOT entry for the expression expr
|
||||
// Delta(S) if S is a normal symbol, resolves to the difference between
|
||||
// the static link address of S and the execution address of S.
|
||||
// If S is the null symbol (ELF symbol index 0), resolves to the difference
|
||||
// between the static link address of P and the execution address of P.
|
||||
// Indirect(expr) represents the result of calling expr as a function.
|
||||
// The result is the return value from the function that is returned in r0.
|
||||
// [msb:lsb] is a bit-mask operation representing the selection of bits in a value
|
||||
enum elf_RTYPE_aarch64
|
||||
{
|
||||
R_AARCH64_NONE = 0x100,
|
||||
|
||||
//ILP32 relocations
|
||||
R_AARCH64_P32_ABS32 = 1,/* Direct 32 bit. */
|
||||
R_AARCH64_P32_COPY = 180,/* Copy symbol at runtime. */
|
||||
R_AARCH64_P32_GLOB_DAT = 181,/* Create GOT entry. */
|
||||
R_AARCH64_P32_JUMP_SLOT = 182,/* Create PLT entry. */
|
||||
R_AARCH64_P32_RELATIVE = 183,/* Adjust by program base. */
|
||||
R_AARCH64_P32_TLS_DTPMOD = 184,/* Module number, 32 bit. */
|
||||
R_AARCH64_P32_TLS_DTPREL = 185,/* Module-relative offset, 32 bit. */
|
||||
R_AARCH64_P32_TLS_TPREL = 186,/* TP-relative offset, 32 bit. */
|
||||
R_AARCH64_P32_TLSDESC = 187,/* TLS Descriptor. */
|
||||
R_AARCH64_P32_IRELATIVE = 188,/* STT_GNU_IFUNC relocation. */
|
||||
|
||||
// 4.6.5 Static Data relocations
|
||||
R_AARCH64_ABS64 = 0x101, // S + A
|
||||
R_AARCH64_ABS32 = 0x102, // S + A
|
||||
R_AARCH64_ABS16 = 0x103,
|
||||
R_AARCH64_PREL64 = 0x104,
|
||||
R_AARCH64_PREL32 = 0x105,
|
||||
R_AARCH64_PREL16 = 0x106,
|
||||
|
||||
// 4.6.6 Static AArch64 relocations
|
||||
R_AARCH64_MOVW_UABS_G0 = 0x107,
|
||||
R_AARCH64_MOVW_UABS_G0_NC = 0x108,
|
||||
R_AARCH64_MOVW_UABS_G1 = 0x109,
|
||||
R_AARCH64_MOVW_UABS_G1_NC = 0x10a,
|
||||
R_AARCH64_MOVW_UABS_G2 = 0x10b,
|
||||
R_AARCH64_MOVW_UABS_G2_NC = 0x10c,
|
||||
R_AARCH64_MOVW_UABS_G3 = 0x10d,
|
||||
R_AARCH64_MOVW_SABS_G0 = 0x10e,
|
||||
R_AARCH64_MOVW_SABS_G1 = 0x10f,
|
||||
R_AARCH64_MOVW_SABS_G2 = 0x110,
|
||||
|
||||
R_AARCH64_LD_PREL_LO19 = 0x111,
|
||||
R_AARCH64_ADR_PREL_LO21 = 0x112,
|
||||
R_AARCH64_ADR_PREL_PG_HI21 = 0x113, // Page(S+A) - Page(P); Set an ADRP immediate value to bits [32:12] of the X
|
||||
R_AARCH64_ADR_PREL_PG_HI21_NC = 0x114,
|
||||
R_AARCH64_ADD_ABS_LO12_NC = 0x115, // S+A; Set an ADD immediate value to bits [11:0] of X
|
||||
R_AARCH64_LDST8_ABS_LO12_NC = 0x116,
|
||||
|
||||
R_AARCH64_TSTBR14 = 0x117,
|
||||
R_AARCH64_CONDBR19 = 0x118,
|
||||
R_AARCH64_JUMP26 = 0x11a, // S+A-P; Set a B immediate field to bits [27:2] of X
|
||||
R_AARCH64_CALL26 = 0x11b, // S+A-P; Set a CALL immediate field to bits [27:2] of X
|
||||
|
||||
R_AARCH64_LDST16_ABS_LO12_NC = 0x11c,
|
||||
R_AARCH64_LDST32_ABS_LO12_NC = 0x11d,
|
||||
R_AARCH64_LDST64_ABS_LO12_NC = 0x11e, // S+A; Set the LD/ST immediate value to bits [11:3] of X
|
||||
|
||||
R_AARCH64_MOVW_PREL_G0 = 0x11f,
|
||||
R_AARCH64_MOVW_PREL_G0_NC = 0x120,
|
||||
R_AARCH64_MOVW_PREL_G1 = 0x121,
|
||||
R_AARCH64_MOVW_PREL_G1_NC = 0x122,
|
||||
R_AARCH64_MOVW_PREL_G2 = 0x123,
|
||||
R_AARCH64_MOVW_PREL_G2_NC = 0x124,
|
||||
R_AARCH64_MOVW_PREL_G3 = 0x125,
|
||||
|
||||
R_AARCH64_LDST128_ABS_LO12_NC = 0x12b,
|
||||
|
||||
R_AARCH64_MOVW_GOTOFF_G0 = 0x12c,
|
||||
R_AARCH64_MOVW_GOTOFF_G0_NC = 0x12d,
|
||||
R_AARCH64_MOVW_GOTOFF_G1 = 0x12e,
|
||||
R_AARCH64_MOVW_GOTOFF_G1_NC = 0x12f,
|
||||
R_AARCH64_MOVW_GOTOFF_G2 = 0x130,
|
||||
R_AARCH64_MOVW_GOTOFF_G2_NC = 0x131,
|
||||
R_AARCH64_MOVW_GOTOFF_G3 = 0x132,
|
||||
|
||||
R_AARCH64_GOTREL64 = 0x133,
|
||||
R_AARCH64_GOTREL32 = 0x134,
|
||||
|
||||
R_AARCH64_GOT_LD_PREL19 = 0x135,
|
||||
R_AARCH64_LD64_GOTOFF_LO15 = 0x136,
|
||||
R_AARCH64_ADR_GOT_PAGE = 0x137, // Page(G(GDAT(S+A)))-Page(P); Set the immediate value of an ADRP to bits [32:12] of X
|
||||
R_AARCH64_LD64_GOT_LO12_NC = 0x138, // G(GDAT(S+A)); Set the LD/ST immediate field to bits [11:3] of X
|
||||
R_AARCH64_LD64_GOTPAGE_LO15 = 0x139,
|
||||
|
||||
R_AARCH64_TLSGD_ADR_PREL21 = 0x200,
|
||||
R_AARCH64_TLSGD_ADR_PAGE21 = 0x201,
|
||||
R_AARCH64_TLSGD_ADD_LO12_NC = 0x202,
|
||||
R_AARCH64_TLSGD_MOVW_G1 = 0x203,
|
||||
R_AARCH64_TLSGD_MOVW_G0_NC = 0x204,
|
||||
|
||||
R_AARCH64_TLSLD_ADR_PREL21 = 0x205,
|
||||
R_AARCH64_TLSLD_ADR_PAGE21 = 0x206,
|
||||
R_AARCH64_TLSLD_ADD_LO12_NC = 0x207,
|
||||
R_AARCH64_TLSLD_MOVW_G1 = 0x208,
|
||||
R_AARCH64_TLSLD_MOVW_G0_NC = 0x209,
|
||||
R_AARCH64_TLSLD_LD_PREL19 = 0x20a,
|
||||
R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 0x20b,
|
||||
R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 0x20c,
|
||||
R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 0x20d,
|
||||
R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 0x20e,
|
||||
R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 0x20f,
|
||||
R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 0x210,
|
||||
R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 0x211,
|
||||
R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 0x212,
|
||||
R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 0x213,
|
||||
R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 0x214,
|
||||
R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 0x215,
|
||||
R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 0x216,
|
||||
R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 0x217,
|
||||
R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 0x218,
|
||||
R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 0x219,
|
||||
R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 0x21a,
|
||||
|
||||
R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 0x21b,
|
||||
R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 0x21c,
|
||||
R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 0x21d,
|
||||
R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 0x21e,
|
||||
R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 0x21f,
|
||||
|
||||
R_AARCH64_TLSLE_MOVW_TPREL_G2 = 0x220,
|
||||
R_AARCH64_TLSLE_MOVW_TPREL_G1 = 0x221,
|
||||
R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 0x222,
|
||||
R_AARCH64_TLSLE_MOVW_TPREL_G0 = 0x223,
|
||||
R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 0x224,
|
||||
R_AARCH64_TLSLE_ADD_TPREL_HI12 = 0x225,
|
||||
R_AARCH64_TLSLE_ADD_TPREL_LO12 = 0x226,
|
||||
R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 0x227,
|
||||
R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 0x228,
|
||||
R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 0x229,
|
||||
R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 0x22a,
|
||||
R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 0x22b,
|
||||
R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 0x22c,
|
||||
R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 0x22d,
|
||||
R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 0x22e,
|
||||
R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 0x22f,
|
||||
|
||||
R_AARCH64_TLSDESC_LD_PREL19 = 0x230,
|
||||
R_AARCH64_TLSDESC_ADR_PREL21 = 0x231,
|
||||
R_AARCH64_TLSDESC_ADR_PAGE21 = 0x232, // R_AARCH64_TLSDESC_ADR_PAGE
|
||||
R_AARCH64_TLSDESC_LD64_LO12 = 0x233, // R_AARCH64_TLSDESC_LD64_LO12_NC
|
||||
R_AARCH64_TLSDESC_ADD_LO12 = 0x234, // R_AARCH64_TLSDESC_ADD_LO12_NC
|
||||
R_AARCH64_TLSDESC_OFF_G1 = 0x235,
|
||||
R_AARCH64_TLSDESC_OFF_G0_NC = 0x236,
|
||||
R_AARCH64_TLSDESC_LDR = 0x237,
|
||||
R_AARCH64_TLSDESC_ADD = 0x238,
|
||||
R_AARCH64_TLSDESC_CALL = 0x239,
|
||||
|
||||
R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 0x23a,
|
||||
R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 0x23b,
|
||||
|
||||
R_AARCH64_TLSLD_LDST128_DTPREL_Lo12 = 0x23c,
|
||||
R_AARCH64_TLSLD_LDST128_DTPREL_Lo12_NC= 0x23d,
|
||||
|
||||
// 4.6.11 Dynamic relocations
|
||||
R_AARCH64_COPY = 0x400,
|
||||
R_AARCH64_GLOB_DAT = 0x401,
|
||||
R_AARCH64_JUMP_SLOT = 0x402,
|
||||
R_AARCH64_RELATIVE = 0x403,
|
||||
R_AARCH64_TLS_DTPREL64 = 0x404,
|
||||
R_AARCH64_TLS_DTPMOD64 = 0x405,
|
||||
R_AARCH64_TLS_TPREL64 = 0x406,
|
||||
R_AARCH64_TLSDESC = 0x407,
|
||||
R_AARCH64_IRELATIVE = 0x408,
|
||||
};
|
||||
|
||||
// Flags:
|
||||
#define EF_ARM_RELEXEC 0x00000001 // dynamic only how to relocation
|
||||
#define EF_ARM_HASENTRY 0x00000002 // e_entry is real start address
|
||||
|
||||
// GNU flags (EABI version = 0)
|
||||
#define EF_ARM_INTERWORK 0x00000004 // interworking enabled
|
||||
#define EF_ARM_APCS_26 0x00000008 // APCS-26 used (otherwise APCS-32)
|
||||
#define EF_ARM_APCS_FLOAT 0x00000010 // floats passed in float registers
|
||||
#define EF_ARM_PIC 0x00000020 // Position-independent code
|
||||
#define EF_ARM_ALIGN8 0x00000040 // 8-bit struct alignment
|
||||
#define EF_ARM_NEW_ABI 0x00000080 // New ABI
|
||||
#define EF_ARM_OLD_ABI 0x00000100 // Old ABI
|
||||
#define EF_ARM_SOFT_FLOAT 0x00000200 // software FP
|
||||
#define EF_ARM_VFP_FLOAT 0x00000400 // VFP float format
|
||||
#define EF_ARM_MAVERICK_FLOAT 0x00000800 // Maverick float format
|
||||
|
||||
// ARM flags:
|
||||
#define EF_ARM_SYMSARESORTED 0x00000004 // Each subsection of the symbol table is sorted by symbol value (NB conflicts with EF_INTERWORK)
|
||||
#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 // Symbols in dynamic symbol tables that are defined in sections
|
||||
// included in program segment n have st_shndx = n + 1. (NB conflicts with EF_APCS26)
|
||||
#define EF_ARM_MAPSYMSFIRST 0x00000010 // Mapping symbols precede other local symbols in the symbol
|
||||
// table (NB conflicts with EF_APCS_FLOAT)
|
||||
#define EF_ARM_LE8 0x00400000 // LE-8 code
|
||||
#define EF_ARM_BE8 0x00800000 // BE-8 code for ARMv6 or later
|
||||
#define EF_ARM_EABIMASK 0xFF000000 // ARM EABI version
|
||||
|
||||
/* Additional symbol types for Thumb. */
|
||||
#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */
|
||||
#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */
|
||||
|
||||
// patching GOT loading,
|
||||
// discard auxiliary values in plt/got
|
||||
// can present offset bypass segment
|
||||
#define ELF_RPL_ARM_DEFAULT (ELF_RPL_GL | ELF_DIS_OFFW | ELF_DIS_GPLT)
|
||||
|
||||
enum elf_SHT_ARM
|
||||
{
|
||||
SHT_ARM_EXIDX = 0x70000001, // Exception Index table
|
||||
SHT_ARM_PREEMPTMAP = 0x70000002, // BPABI DLL dynamic linking pre-emption map
|
||||
SHT_ARM_ATTRIBUTES = 0x70000003, // Object file compatibility attributes
|
||||
SHT_ARM_DEBUGOVERLAY = 0x70000004, //
|
||||
SHT_ARM_OVERLAYSECTION = 0x70000005, //
|
||||
};
|
||||
|
||||
enum elf_PT_ARM
|
||||
{
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility information
|
||||
PT_ARM_EXIDX = 0x70000001, // Exception unwind tables
|
||||
};
|
||||
|
||||
enum elf_PT_AARCH64
|
||||
{
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
PT_AARCH64_ARCHEXT = 0x70000000, // Platform architecture compatibility information
|
||||
PT_AARCH64_UNWIND = 0x70000001, // Exception unwind tables
|
||||
};
|
||||
|
||||
enum eabi_tags_t
|
||||
{
|
||||
Tag_NULL,
|
||||
Tag_File, // (=1) <uint32: byte-size> <attribute>*
|
||||
Tag_Section, // (=2) <uint32: byte-size> <section number>* 0 <attribute>*
|
||||
Tag_Symbol, // (=3) <unit32: byte-size> <symbol number>* 0 <attribute>*
|
||||
Tag_CPU_raw_name, // (=4), NTBS
|
||||
Tag_CPU_name, // (=5), NTBS
|
||||
Tag_CPU_arch, // (=6), uleb128
|
||||
Tag_CPU_arch_profile, // (=7), uleb128
|
||||
Tag_ARM_ISA_use, // (=8), uleb128
|
||||
Tag_THUMB_ISA_use, // (=9), uleb128
|
||||
Tag_FP_arch, // (=10), uleb128 (formerly Tag_VFP_arch = 10)
|
||||
Tag_VFP_arch = Tag_FP_arch,
|
||||
Tag_WMMX_arch, // (=11), uleb128
|
||||
Tag_NEON_arch, // (=12), uleb128
|
||||
Tag_PCS_config, // (=13), uleb128
|
||||
Tag_ABI_PCS_R9_use, // (=14), uleb128
|
||||
Tag_ABI_PCS_RW_data, // (=15), uleb128
|
||||
Tag_ABI_PCS_RO_data, // (=16), uleb128
|
||||
Tag_ABI_PCS_GOT_use, // (=17), uleb128
|
||||
Tag_ABI_PCS_wchar_t, // (=18), uleb128
|
||||
Tag_ABI_FP_rounding, // (=19), uleb128
|
||||
Tag_ABI_FP_denormal, // (=20), uleb128
|
||||
Tag_ABI_FP_exceptions, // (=21), uleb128
|
||||
Tag_ABI_FP_user_exceptions, // (=22), uleb128
|
||||
Tag_ABI_FP_number_model, // (=23), uleb128
|
||||
Tag_ABI_align_needed, // (=24), uleb128
|
||||
Tag_ABI_align8_needed = Tag_ABI_align_needed,
|
||||
Tag_ABI_align_preserved, // (=25), uleb128
|
||||
Tag_ABI_align8_preserved = Tag_ABI_align_preserved,
|
||||
Tag_ABI_enum_size, // (=26), uleb128
|
||||
Tag_ABI_HardFP_use, // (=27), uleb128
|
||||
Tag_ABI_VFP_args, // (=28), uleb128
|
||||
Tag_ABI_WMMX_args, // (=29), uleb128
|
||||
Tag_ABI_optimization_goals, // (=30), uleb128
|
||||
Tag_ABI_FP_optimization_goals, // (=31), uleb128
|
||||
Tag_compatibility, // (=32), uleb128: flag, NTBS: vendor-name
|
||||
Tag_CPU_unaligned_access=34, // (=34), uleb128
|
||||
Tag_FP_HP_extension=36, // (=36), uleb128 (formerly Tag_VFP_HP_extension = 36)
|
||||
Tag_VFP_HP_extension = Tag_FP_HP_extension,
|
||||
Tag_ABI_FP_16bit_format=38, // (=38), uleb128
|
||||
Tag_MPextension_use=42, // (=42), uleb128
|
||||
Tag_DIV_use=44, // (=44), uleb128
|
||||
Tag_nodefaults=64, // (=64), uleb128: ignored (write as 0)
|
||||
Tag_also_compatible_with, // (=65), NTBS: data; ULEB128-encoded tag followed by a value of that tag.
|
||||
Tag_T2EE_use, // (=66), uleb128
|
||||
Tag_conformance, // (=67), string: ABI-version
|
||||
Tag_Virtualization_use, // (=68), uleb128
|
||||
Tag_MPextension_use_legacy=70, // (=70),
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class arm_arch_specific_t : public arch_specific_t
|
||||
{
|
||||
public:
|
||||
enum isa_t
|
||||
{
|
||||
isa_arm = 1,
|
||||
isa_thumb
|
||||
};
|
||||
typedef void isa_handler_t(
|
||||
reader_t &reader,
|
||||
sym_rel &symbol,
|
||||
isa_t isa,
|
||||
bool force);
|
||||
private:
|
||||
typedef std::map<uint64, isa_t> section_isa_ranges_t;
|
||||
typedef std::map<elf_shndx_t, section_isa_ranges_t> isa_ranges_t;
|
||||
|
||||
isa_ranges_t isa_ranges;
|
||||
std::set<ea_t> forced_isas;
|
||||
|
||||
isa_handler_t *isa_handler = nullptr;
|
||||
ea_t debug_segbase = 0;
|
||||
bool has_mapsym = false;
|
||||
bool track_mapsym = false;
|
||||
bool be8_code = false;
|
||||
bool thumb_entry = false;
|
||||
|
||||
void notify_isa(reader_t &reader, sym_rel &symbol, isa_t isa, bool force)
|
||||
{
|
||||
if ( isa_handler != NULL )
|
||||
isa_handler(reader, symbol, isa, force);
|
||||
}
|
||||
|
||||
isa_t get_isa(const sym_rel &symbol) const;
|
||||
void set_isa(const sym_rel &symbol, isa_t isa);
|
||||
|
||||
friend void arm_isa_handler(
|
||||
reader_t &reader,
|
||||
sym_rel &symbol,
|
||||
arm_arch_specific_t::isa_t isa,
|
||||
bool force);
|
||||
|
||||
public:
|
||||
virtual ~arm_arch_specific_t() {}
|
||||
virtual void on_start_symbols(reader_t &reader) override;
|
||||
virtual void on_symbol_read(reader_t &reader, sym_rel &sym) override;
|
||||
bool is_mapping_symbol(const char *name) const;
|
||||
bool has_mapping_symbols() const { return has_mapsym; }
|
||||
|
||||
// Tracking mapping symbols can be useful for
|
||||
// determining whether a certain function is using
|
||||
// the Thumb or ARM ISA.
|
||||
// In some ELF files, the only way to know what ISA
|
||||
// certain functions are in is by looking at some
|
||||
// mapping symbols (i.e., '$a', '$t').
|
||||
// By default, tracking of such symbols in an
|
||||
// instance of this class is _not_ enabled.
|
||||
void set_mapping_symbols_tracking(bool track) { track_mapsym = track; }
|
||||
bool is_mapping_symbols_tracking() const { return track_mapsym; }
|
||||
|
||||
void set_isa_handler(isa_handler_t *ih, ea_t dea)
|
||||
{
|
||||
isa_handler = ih;
|
||||
debug_segbase = dea;
|
||||
}
|
||||
|
||||
void set_thumb_entry() { thumb_entry = true; }
|
||||
bool get_thumb_entry() const { return thumb_entry; }
|
||||
void set_be8(bool be8) { be8_code = be8; }
|
||||
bool is_be8() { return be8_code; }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Specific flags that will be set on sym_rel instances.
|
||||
enum arm_sym_rel_flags
|
||||
{
|
||||
thumb_function = 1
|
||||
};
|
||||
|
||||
#endif
|
||||
86
idasdk75/ldr/elf/elfr_avr.h
Normal file
86
idasdk75/ldr/elf/elfr_avr.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef __ELFR_AVR_H__
|
||||
#define __ELFR_AVR_H__
|
||||
|
||||
#ifndef __ELFBASE_H__
|
||||
#include "elfbase.h"
|
||||
#endif
|
||||
|
||||
enum elf_RTYPE_avr
|
||||
{
|
||||
R_AVR_NONE = 0,
|
||||
R_AVR_32 = 1,
|
||||
R_AVR_7_PCREL = 2,
|
||||
R_AVR_13_PCREL = 3,
|
||||
R_AVR_16 = 4,
|
||||
R_AVR_16PM = 5,
|
||||
R_AVR_LO8_LDI = 6,
|
||||
R_AVR_HI8_LDI = 7,
|
||||
R_AVR_HH8_LDI = 8,
|
||||
R_AVR_LO8_LDI_NEG = 9,
|
||||
R_AVR_HI8_LDI_NEG = 10,
|
||||
R_AVR_HH8_LDI_NEG = 11,
|
||||
R_AVR_LO8_LDI_PM = 12,
|
||||
R_AVR_HI8_LDI_PM = 13,
|
||||
R_AVR_HH8_LDI_PM = 14,
|
||||
R_AVR_LO8_LDI_PM_NEG = 15,
|
||||
R_AVR_HI8_LDI_PM_NEG = 16,
|
||||
R_AVR_HH8_LDI_PM_NEG = 17,
|
||||
R_AVR_CALL = 18,
|
||||
// *nix obj's specific
|
||||
R_AVR_LDI = 19,
|
||||
R_AVR_6 = 20,
|
||||
R_AVR_6_ADIW = 21,
|
||||
R_AVR_MS8_LDI = 22,
|
||||
R_AVR_MS8_LDI_NEG = 23,
|
||||
R_AVR_LO8_LDI_GS = 24,
|
||||
R_AVR_HI8_LDI_GS = 25,
|
||||
R_AVR_8 = 26,
|
||||
R_AVR_8_LO8 = 27,
|
||||
R_AVR_8_HI8 = 28,
|
||||
R_AVR_8_HLO8 = 29,
|
||||
R_AVR_DIFF8 = 30,
|
||||
R_AVR_DIFF16 = 31,
|
||||
R_AVR_DIFF32 = 32,
|
||||
R_AVR_LDS_STS_16 = 33,
|
||||
R_AVR_PORT6 = 34,
|
||||
R_AVR_PORT5 = 35,
|
||||
R_AVR_32_PCREL = 36,
|
||||
};
|
||||
|
||||
// Flags:
|
||||
// If bit #7 is set, it is assumed that the elf file uses local symbols
|
||||
// as reference for the relocations so that linker relaxation is possible.
|
||||
#define EF_AVR_LINKRELAX_PREPARED 0x80
|
||||
|
||||
// Processor specific flags for the ELF header e_flags field.
|
||||
#define EF_AVR_MACH 0x7F
|
||||
#define E_AVR_MACH_AVR1 1
|
||||
#define E_AVR_MACH_AVR2 2
|
||||
#define E_AVR_MACH_AVR25 25
|
||||
#define E_AVR_MACH_AVR3 3
|
||||
#define E_AVR_MACH_AVR31 31
|
||||
#define E_AVR_MACH_AVR35 35
|
||||
#define E_AVR_MACH_AVR4 4
|
||||
#define E_AVR_MACH_AVR5 5
|
||||
#define E_AVR_MACH_AVR51 51
|
||||
#define E_AVR_MACH_AVR6 6
|
||||
#define E_AVR_MACH_XMEGA1 101
|
||||
#define E_AVR_MACH_XMEGA2 102
|
||||
#define E_AVR_MACH_XMEGA3 103
|
||||
#define E_AVR_MACH_XMEGA4 104
|
||||
#define E_AVR_MACH_XMEGA5 105
|
||||
#define E_AVR_MACH_XMEGA6 106
|
||||
#define E_AVR_MACH_XMEGA7 107
|
||||
|
||||
// netnode flag's and constant
|
||||
#define AVR_INFO_NODENAME "$ atmel"
|
||||
#define ELF_AVR_TAG 'f'
|
||||
#define ELF_AVR_LDI_NEG 1
|
||||
#define ELF_AVR_RAM_OFF 2
|
||||
#define ELF_AVR_EEP_OFF 3
|
||||
#define ELF_AVR_ABS_OFF 4
|
||||
#define ELF_AVR_RAMBASE 0x800000
|
||||
#define ELF_AVR_EEPROMBASE 0x810000
|
||||
#define ELF_AVR_ABSBASE 0x1000000
|
||||
|
||||
#endif
|
||||
272
idasdk75/ldr/elf/elfr_ia64.h
Normal file
272
idasdk75/ldr/elf/elfr_ia64.h
Normal file
@@ -0,0 +1,272 @@
|
||||
#ifndef __ELFR_IA64_H__
|
||||
#define __ELFR_IA64_H__
|
||||
|
||||
#ifndef __ELFBASE_H__
|
||||
#include "elfbase.h"
|
||||
#endif
|
||||
|
||||
/* Bits in the e_flags field of the Elf64_Ehdr: */
|
||||
#define EF_IA_64_MASKOS 0x00ff000f /* os-specific flags */
|
||||
#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
|
||||
#define EFA_IA_64 0x00000000
|
||||
/* ??? These four definitions are not part of the SVR4 ABI.
|
||||
They were present in David's initial code drop, so it is probable
|
||||
that they are used by HP/UX. */
|
||||
#define EF_IA_64_TRAPNIL (1 << 0) /* Trap NIL pointer dereferences. */
|
||||
#define EF_IA_64_LAZYSWAP (1 << 1) /* Lazy Swap algorithm */
|
||||
#define EF_IA_64_EXT (1 << 2) /* Program uses arch. extensions. */
|
||||
#define EF_IA_64_BE (1 << 3) /* PSR BE bit set (big-endian). */
|
||||
#define EFA_IA_64_EAS2_3 0x23000000 /* IA64 EAS 2.3. */
|
||||
|
||||
#define EF_IA_64_ABI64 (1 << 4) /* 64-bit ABI. */
|
||||
/* Not used yet. */
|
||||
#define EF_IA_64_REDUCEDFP (1 << 5) /* Only FP6-FP11 used. */
|
||||
#define EF_IA_64_CONS_GP (1 << 6) /* gp as program wide constant. */
|
||||
#define EF_IA_64_NOFUNCDESC_CONS_GP (1 << 7) /* And no function descriptors. */
|
||||
/* Not used yet. */
|
||||
#define EF_IA_64_ABSOLUTE (1 << 8) /* Load at absolute addresses. */
|
||||
|
||||
/*============================================================================
|
||||
The R_EM_* macros are the IA_64 relocation types
|
||||
============================================================================*/
|
||||
/*
|
||||
** These are "real" Tahoe relocations. The offset in a relocation
|
||||
** applied to a data location is the actual byte address of the
|
||||
** 32-/64-bit field to relocate. The value of (offset & ~3) in
|
||||
** an instruction relocation is the byte offset of the bundle
|
||||
** the instruction lives in; the value of (offset & 3) signifies:
|
||||
** 0: first instruction slot in bundle
|
||||
** 1: second instruction slot in bundle
|
||||
** 2: third instruction slot in bundle
|
||||
**
|
||||
** Little piece of info: the first (hex) digit specifies the
|
||||
** expression type, while the second specifies the format of
|
||||
** the data word being relocated.
|
||||
*/
|
||||
|
||||
// relocation field - word32 with HIGH BYTE FIRST!!!
|
||||
// A- from Elf32_Rela
|
||||
// B- Loading address of shared object
|
||||
// G- offset into global objet table
|
||||
// GOT- adress of global object table
|
||||
// L- linkage table entry
|
||||
// P- plase of storage unit (computed using r_offset)
|
||||
// S- value of symbol
|
||||
enum elf_RTYPE_ia64
|
||||
{
|
||||
R_IA64_NONE = 0x00, /* none */
|
||||
|
||||
R_IA64_IMM14 = 0x21, /* symbol + addend, add imm14 */
|
||||
R_IA64_IMM22 = 0x22, /* symbol + addend, add imm22 */
|
||||
R_IA64_IMM64 = 0x23, /* symbol + addend, mov imm64 */
|
||||
R_IA64_DIR32MSB = 0x24, /* symbol + addend, data4 MSB */
|
||||
R_IA64_DIR32LSB = 0x25, /* symbol + addend, data4 LSB */
|
||||
R_IA64_DIR64MSB = 0x26, /* symbol + addend, data8 MSB */
|
||||
R_IA64_DIR64LSB = 0x27, /* symbol + addend, data8 LSB */
|
||||
|
||||
R_IA64_GPREL22 = 0x2a, /* @gprel(sym + add), add imm22 */
|
||||
R_IA64_GPREL64I = 0x2b, /* @gprel(sym + add), mov imm64 */
|
||||
R_IA64_GPREL32MSB = 0x2c, /* @gprel(sym + add), data4 MSB ## */
|
||||
R_IA64_GPREL32LSB = 0x2d, /* @gprel(sym + add), data4 LSB ## */
|
||||
R_IA64_GPREL64MSB = 0x2e, /* @gprel(sym + add), data8 MSB */
|
||||
R_IA64_GPREL64LSB = 0x2f, /* @gprel(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_LTOFF22 = 0x32, /* @ltoff(sym + add), add imm22 */
|
||||
R_IA64_LTOFF64I = 0x33, /* @ltoff(sym + add), mov imm64 */
|
||||
|
||||
R_IA64_PLTOFF22 = 0x3a, /* @pltoff(sym + add), add imm22 */
|
||||
R_IA64_PLTOFF64I = 0x3b, /* @pltoff(sym + add), mov imm64 */
|
||||
R_IA64_PLTOFF64MSB = 0x3e, /* @pltoff(sym + add), data8 MSB */
|
||||
R_IA64_PLTOFF64LSB = 0x3f, /* @pltoff(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_FPTR64I = 0x43, /* @fptr(sym + add), mov imm64 */
|
||||
R_IA64_FPTR32MSB = 0x44, /* @fptr(sym + add), data4 MSB */
|
||||
R_IA64_FPTR32LSB = 0x45, /* @fptr(sym + add), data4 LSB */
|
||||
R_IA64_FPTR64MSB = 0x46, /* @fptr(sym + add), data8 MSB */
|
||||
R_IA64_FPTR64LSB = 0x47, /* @fptr(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_PCREL60B = 0x48, /* @pcrel(sym + add), brl */
|
||||
R_IA64_PCREL21B = 0x49, /* @pcrel(sym + add), ptb, call */
|
||||
R_IA64_PCREL21M = 0x4a, /* @pcrel(sym + add), chk.s */
|
||||
R_IA64_PCREL21F = 0x4b, /* @pcrel(sym + add), fchkf */
|
||||
R_IA64_PCREL32MSB = 0x4c, /* @pcrel(sym + add), data4 MSB */
|
||||
R_IA64_PCREL32LSB = 0x4d, /* @pcrel(sym + add), data4 LSB */
|
||||
R_IA64_PCREL64MSB = 0x4e, /* @pcrel(sym + add), data8 MSB */
|
||||
R_IA64_PCREL64LSB = 0x4f, /* @pcrel(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_LTOFF_FPTR22 = 0x52, /* @ltoff(@fptr(s+a)), imm22 */
|
||||
R_IA64_LTOFF_FPTR64I = 0x53, /* @ltoff(@fptr(s+a)), imm64 */
|
||||
R_IA64_LTOFF_FPTR32MSB = 0x54, /* @ltoff(@fptr(s+a)), 4 MSB */
|
||||
R_IA64_LTOFF_FPTR32LSB = 0x55, /* @ltoff(@fptr(s+a)), 4 LSB */
|
||||
R_IA64_LTOFF_FPTR64MSB = 0x56, /* @ltoff(@fptr(s+a)), 8 MSB ##*/
|
||||
R_IA64_LTOFF_FPTR64LSB = 0x57, /* @ltoff(@fptr(s+a)), 8 LSB ##*/
|
||||
|
||||
R_IA64_SEGBASE = 0x58, /* set segment base for @segrel ## */
|
||||
R_IA64_SEGREL32MSB = 0x5c, /* @segrel(sym + add), data4 MSB */
|
||||
R_IA64_SEGREL32LSB = 0x5d, /* @segrel(sym + add), data4 LSB */
|
||||
R_IA64_SEGREL64MSB = 0x5e, /* @segrel(sym + add), data8 MSB */
|
||||
R_IA64_SEGREL64LSB = 0x5f, /* @segrel(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_SECREL32MSB = 0x64, /* @secrel(sym + add), data4 MSB */
|
||||
R_IA64_SECREL32LSB = 0x65, /* @secrel(sym + add), data4 LSB */
|
||||
R_IA64_SECREL64MSB = 0x66, /* @secrel(sym + add), data8 MSB */
|
||||
R_IA64_SECREL64LSB = 0x67, /* @secrel(sym + add), data8 LSB */
|
||||
|
||||
R_IA64_REL32MSB = 0x6c, /* data 4 + REL */
|
||||
R_IA64_REL32LSB = 0x6d, /* data 4 + REL */
|
||||
R_IA64_REL64MSB = 0x6e, /* data 8 + REL */
|
||||
R_IA64_REL64LSB = 0x6f, /* data 8 + REL */
|
||||
|
||||
R_IA64_LTV32MSB = 0x74, /* symbol + addend, data4 MSB */
|
||||
R_IA64_LTV32LSB = 0x75, /* symbol + addend, data4 LSB */
|
||||
R_IA64_LTV64MSB = 0x76, /* symbol + addend, data8 MSB */
|
||||
R_IA64_LTV64LSB = 0x77, /* symbol + addend, data8 LSB */
|
||||
|
||||
R_IA64_PCREL21BI = 0x79, /* @pcrel(sym + add), ptb, call */
|
||||
R_IA64_PCREL22 = 0x7a, /* @pcrel(sym + add), imm22 */
|
||||
R_IA64_PCREL64I = 0x7b, /* @pcrel(sym + add), imm64 */
|
||||
|
||||
R_IA64_IPLTMSB = 0x80, /* dynamic reloc, imported PLT, MSB */
|
||||
R_IA64_IPLTLSB = 0x81, /* dynamic reloc, imported PLT, LSB */
|
||||
R_IA64_EPLTMSB = 0x82, /* dynamic reloc, exported PLT, ## */
|
||||
R_IA64_EPLTLSB = 0x83, /* dynamic reloc, exported PLT, ## */
|
||||
R_IA64_COPY = 0x84, /* dynamic reloc, data copy ## */
|
||||
R_IA64_SUB = 0x85, /* Addend and symbol difference */
|
||||
R_IA64_LTOFF22X = 0x86, /* LTOFF22, relaxable. */
|
||||
R_IA64_LDXMOV = 0x87, /* Use of LTOFF22X. */
|
||||
|
||||
R_IA64_TPREL14 = 0x91, /* @tprel(sym+add), add imm14 */
|
||||
R_IA64_TPREL22 = 0x92, /* sym-TP+add, add imm22 ## */
|
||||
R_IA64_TPREL64I = 0x93, /* @tprel(sym+add), add imm64 */
|
||||
R_IA64_TPREL64MSB = 0x96, /* sym-TP+add, data8 MSB ## */
|
||||
R_IA64_TPREL64LSB = 0x97, /* sym-TP+add, data8 LSB ## */
|
||||
|
||||
R_IA64_LTOFF_TP22 = 0x9a, /* @ltoff(sym-TP+add), add imm22 ## */
|
||||
|
||||
R_IA64_DTPMOD64MSB = 0xa6, /* @dtpmod(sym+add), data8 MSB */
|
||||
R_IA64_DTPMOD64LSB = 0xa7, /* @dtpmod(sym+add), data8 LSB */
|
||||
R_IA64_LTOFF_DTPMOD22 = 0xaa, /* @ltoff(@dtpmod(s+a)), imm22 */
|
||||
|
||||
R_IA64_DTPREL14 = 0xb1, /* @dtprel(sym+add), imm14 */
|
||||
R_IA64_DTPREL22 = 0xb2, /* @dtprel(sym+add), imm22 */
|
||||
R_IA64_DTPREL64I = 0xb3, /* @dtprel(sym+add), imm64 */
|
||||
R_IA64_DTPREL32MSB = 0xb4, /* @dtprel(sym+add), data4 MSB */
|
||||
R_IA64_DTPREL32LSB = 0xb5, /* @dtprel(sym+add), data4 LSB */
|
||||
R_IA64_DTPREL64MSB = 0xb6, /* @dtprel(sym+add), data8 MSB */
|
||||
R_IA64_DTPREL64LSB = 0xb7, /* @dtprel(sym+add), data8 LSB */
|
||||
|
||||
R_IA64_LTOFF_DTPREL22 = 0xba, /* @ltoff(@dtprel(s+a)), imm22 */
|
||||
|
||||
R_IA64_MAX_RELOC_CODE = 0xba
|
||||
|
||||
};
|
||||
|
||||
// convert plt PIC => noPIC,
|
||||
// patching GOT loading,
|
||||
// discard auxiliary values in plt/got
|
||||
#define ELF_RPL_IA64_DEFAULT (ELF_RPL_PLP | ELF_RPL_GL)
|
||||
|
||||
|
||||
enum elf_SHT_IA64
|
||||
{
|
||||
SHT_IA_64_EXT = 0x70000000, /* extension bits */
|
||||
SHT_IA_64_UNWIND = 0x70000001, /* unwind bits */
|
||||
};
|
||||
|
||||
/*============================================================================
|
||||
The PT_* macros are the values of p_type in ElfXX_Phdr.
|
||||
============================================================================*/
|
||||
enum elf_PT_IA64
|
||||
{
|
||||
|
||||
PT_HP_TLS = (PT_LOOS + 0x0), /* TLS */
|
||||
PT_HP_CORE_NONE = (PT_LOOS + 0x1), /* core file information */
|
||||
PT_HP_CORE_VERSION = (PT_LOOS + 0x2),
|
||||
PT_HP_CORE_KERNEL = (PT_LOOS + 0x3),
|
||||
PT_HP_CORE_COMM = (PT_LOOS + 0x4),
|
||||
PT_HP_CORE_PROC = (PT_LOOS + 0x5),
|
||||
PT_HP_CORE_LOADABLE = (PT_LOOS + 0x6),
|
||||
PT_HP_CORE_STACK = (PT_LOOS + 0x7),
|
||||
PT_HP_CORE_SHM = (PT_LOOS + 0x8),
|
||||
PT_HP_CORE_MMF = (PT_LOOS + 0x9),
|
||||
PT_HP_PARALLEL = (PT_LOOS + 0x10), /* parallel information header */
|
||||
PT_HP_FASTBIND = (PT_LOOS + 0x11), /* fastbind data segment */
|
||||
PT_HP_OPT_ANNOT = (PT_LOOS + 0x12), /* dynamic opt. annotations */
|
||||
PT_HP_HSL_ANNOT = (PT_LOOS + 0x13), /* HSL annotations */
|
||||
PT_HP_STACK = (PT_LOOS + 0x14), /* executable stack */
|
||||
PT_HP_CORE_UTSNAME = (PT_LOOS + 0x15), /* Extended utsname() core struct */
|
||||
PT_HP_LINKER_FOOTPRINT = (PT_LOOS + 0x16), /* linker footprint */
|
||||
|
||||
PT_IA_64_ARCHEXT = (PT_LOPROC + 0), /* arch. extension bits */
|
||||
PT_IA_64_UNWIND = (PT_LOPROC + 1), /* IA64 unwind bits */
|
||||
};
|
||||
|
||||
/*============================================================================
|
||||
The PF_* macros are the segment flag bits in p_flags of ElfXX_Phdr.
|
||||
============================================================================*/
|
||||
enum elf_PF_IA64
|
||||
{
|
||||
PF_HP_ENABLE_RECOVER = 0x00020000, /* enable recovery mode */
|
||||
PF_HP_CODE = 0x00040000, /* code hint */
|
||||
PF_HP_MODIFY = 0x00080000, /* modify hint */
|
||||
PF_HP_PAGE_SIZE = 0x00100000, /* use explicit page size */
|
||||
PF_HP_FAR_SHARED = 0x00200000, /* far shared data */
|
||||
PF_HP_NEAR_SHARED = 0x00400000, /* near shared data */
|
||||
PF_HP_LAZYSWAP = 0x00800000, /* lazy swap allocation */
|
||||
PF_IA_64_NORECOV = 0x80000000, /* segment contains code that uses
|
||||
speculative instructions w/o
|
||||
recovery code. */
|
||||
};
|
||||
|
||||
/*============================================================================
|
||||
The NOTE_* macros are the note types for SHT_NOTE sections
|
||||
============================================================================*/
|
||||
|
||||
#define NOTE_HP_COMPILER 1 /* Compiler identification string */
|
||||
#define NOTE_HP_COPYRIGHT 2 /* Copyright string */
|
||||
#define NOTE_HP_VERSION 3 /* Version string */
|
||||
#define NOTE_HP_SRCFILE_INFO 4 /* Source file info for performance tools */
|
||||
#define NOTE_HP_LINKER 5 /* Linker identification string */
|
||||
#define NOTE_HP_INSTRUMENTED 6 /* instrumentation data */
|
||||
#define NOTE_HP_UX_OPTIONS 7 /* elf hdr extension fields */
|
||||
|
||||
/*============================================================================
|
||||
The DT_* defines are the allowed values of d_tag in ElfXX_dyn.
|
||||
These are the Dynamic Array types.
|
||||
============================================================================*/
|
||||
|
||||
/* (i)gnore (m)andatory */
|
||||
/* (o)ptional */
|
||||
/* d_un Exec DLL */
|
||||
/* ---- ---- --- */
|
||||
enum elf_DT_IA64
|
||||
{
|
||||
DT_HP_LOAD_MAP = (DT_LOOS + 0x0), /* d_ptr m - */
|
||||
DT_HP_DLD_FLAGS = (DT_LOOS + 0x1), /* d_val m - */
|
||||
DT_HP_DLD_HOOK = (DT_LOOS + 0x2), /* d_ptr m - */
|
||||
DT_HP_UX10_INIT = (DT_LOOS + 0x3), /* d_ptr o o */
|
||||
DT_HP_UX10_INITSZ = (DT_LOOS + 0x4), /* d_ptr o o */
|
||||
DT_HP_PREINIT = (DT_LOOS + 0x5), /* d_ptr o - */
|
||||
DT_HP_PREINITSZ = (DT_LOOS + 0x6), /* d_ptr o - */
|
||||
DT_HP_NEEDED = (DT_LOOS + 0x7), /* d_val o o */
|
||||
DT_HP_TIME_STAMP = (DT_LOOS + 0x8), /* d_val o o */
|
||||
DT_HP_CHECKSUM = (DT_LOOS + 0x9), /* d_val o o */
|
||||
DT_HP_GST_SIZE = (DT_LOOS + 0xa), /* d_val o - */
|
||||
DT_HP_GST_VERSION = (DT_LOOS + 0xb), /* d_val o o */
|
||||
DT_HP_GST_HASHVAL = (DT_LOOS + 0xc), /* d_ptr o o */
|
||||
DT_HP_EPLTREL = (DT_LOOS + 0xd), /* d_ptr o o */
|
||||
DT_HP_EPLTRELSZ = (DT_LOOS + 0xe), /* d_ptr o o */
|
||||
DT_HP_FILTERED = (DT_LOOS + 0xf), /* d_val - o */
|
||||
DT_HP_FILTER_TLS = (DT_LOOS + 0x10),/* d_val - o */
|
||||
DT_HP_COMPAT_FILTERED = (DT_LOOS + 0x11),/* d_val - o */
|
||||
DT_HP_LAZYLOAD = (DT_LOOS + 0x12),/* d_val o - */
|
||||
DT_HP_BIND_NOW_COUNT = (DT_LOOS + 0x13),/* d_val o o */
|
||||
DT_PLT = (DT_LOOS + 0x14),/* d_ptr o o */
|
||||
DT_PLT_SIZE = (DT_LOOS + 0x15),/* d_val o o */
|
||||
DT_DLT = (DT_LOOS + 0x16),/* d_ptr o o */
|
||||
DT_DLT_SIZE = (DT_LOOS + 0x17),/* d_val o o */
|
||||
DT_HP_SYM_CHECKSUM = (DT_LOOS + 0x18),/* d_val o o */
|
||||
DT_IA_64_PLT_RESERVE = 0x70000000,
|
||||
};
|
||||
|
||||
#endif
|
||||
434
idasdk75/ldr/elf/elfr_mips.h
Normal file
434
idasdk75/ldr/elf/elfr_mips.h
Normal file
@@ -0,0 +1,434 @@
|
||||
#ifndef __ELFR_MIP_H__
|
||||
#define __ELFR_MIP_H__
|
||||
|
||||
#ifndef __ELFBASE_H__
|
||||
#include "elfbase.h"
|
||||
#endif
|
||||
|
||||
#include "elf.h"
|
||||
|
||||
//
|
||||
// e_flags
|
||||
//
|
||||
|
||||
#define EF_MIPS_NOREORDER 0x00000001 // At least one .noreorder directive appears in the source.
|
||||
#define EF_MIPS_PIC 0x00000002 // File contains position independent code.
|
||||
#define EF_MIPS_CPIC 0x00000004 // Code in file uses the standard calling sequence for calling osition independent code.
|
||||
#define EF_MIPS_UGEN_ALLOC 0x00000008
|
||||
#define EF_MIPS_UCODE 0x00000010 // Code in file uses UCODE (obsolete)
|
||||
#define EF_MIPS_ABI2 0x00000020 // Code in file uses new ABI (-n32 on Irix 6).
|
||||
#define EF_MIPS_DYNAMIC 0x00000040 // MIPS dynamic
|
||||
#define EF_MIPS_OPTIONS_FIRST 0x00000080
|
||||
#define EF_MIPS_32BITMODE 0x00000100 // Indicates code compiled for a 64-bit machine in 32-bit mode. (regs are 32-bits wide.)
|
||||
#define EF_MIPS_FP64 0x00000200 // 32-bit machine but FP registers are 64-bit (gcc -mfp64)
|
||||
#define EF_MIPS_NAN2008 0x00000400 // Uses IEE 754-2008 NaN encoding
|
||||
#define EF_MIPS_ARCH 0xF0000000 // Four bit MIPS architecture field.
|
||||
#define E_MIPS_ARCH_1 0x00000000 // -mips1 code.
|
||||
#define E_MIPS_ARCH_2 0x10000000 // -mips2 code.
|
||||
#define E_MIPS_ARCH_3 0x20000000 // -mips3 code.
|
||||
#define E_MIPS_ARCH_4 0x30000000 // -mips4 code.
|
||||
#define E_MIPS_ARCH_5 0x40000000 // -mips5 code.
|
||||
#define E_MIPS_ARCH_32 0x50000000 // -mips32 code.
|
||||
#define E_MIPS_ARCH_64 0x60000000 // -mips64 code.
|
||||
#define E_MIPS_ARCH_32R2 0x70000000 // -mips32r2
|
||||
#define E_MIPS_ARCH_64R2 0x80000000 // -mips64r2
|
||||
#define E_MIPS_ARCH_32R6 0x90000000 // -mips32r6
|
||||
#define E_MIPS_ARCH_64R6 0xA0000000 // -mips64r6
|
||||
#define EF_MIPS_ABI 0x0000F000 // The ABI of the file. Also see EF_MIPS_ABI2 above.
|
||||
#define E_MIPS_ABI_O32 0x00001000 // The original o32 abi.
|
||||
#define E_MIPS_ABI_O64 0x00002000 // O32 extended to work on 64 bit architectures
|
||||
#define E_MIPS_ABI_EABI32 0x00003000 // EABI in 32 bit mode
|
||||
#define E_MIPS_ABI_EABI64 0x00004000 // EABI in 64 bit mode
|
||||
#define EF_MIPS_ARCH_ASE 0x0F000000 // Architectural Extensions used by this file
|
||||
#define EF_MIPS_ARCH_ASE_MDMX 0x08000000 // Use MDMX multimedia extensions
|
||||
#define EF_MIPS_ARCH_ASE_M16 0x04000000 // Use MIPS-16 ISA extensions
|
||||
#define EF_MIPS_ARCH_ASE_MICROMIPS 0x02000000 // Use microMIPS ISA extensions
|
||||
|
||||
/* Machine variant if we know it. This field was invented at Cygnus,
|
||||
but it is hoped that other vendors will adopt it. If some standard
|
||||
is developed, this code should be changed to follow it. */
|
||||
|
||||
#define EF_MIPS_MACH 0x00FF0000
|
||||
|
||||
/* Cygnus is choosing values between 80 and 9F;
|
||||
00 - 7F should be left for a future standard;
|
||||
the rest are open. */
|
||||
|
||||
#define E_MIPS_MACH_3900 0x00810000 // R3900/Toshiba TX39
|
||||
#define E_MIPS_MACH_4010 0x00820000 //
|
||||
#define E_MIPS_MACH_4100 0x00830000
|
||||
#define E_MIPS_MACH_4650 0x00850000
|
||||
#define E_MIPS_MACH_4120 0x00870000
|
||||
#define E_MIPS_MACH_4111 0x00880000
|
||||
#define E_MIPS_MACH_MIPS32_4K 0x00890000
|
||||
#define E_MIPS_MACH_SB1 0x008A0000 // SiByte SB-1
|
||||
#define E_MIPS_MACH_OCTEON 0x008B0000 // Cavium Networks OCTEON
|
||||
#define E_MIPS_MACH_XLR 0x008C0000 // RMI XLR
|
||||
#define E_MIPS_MACH_OCTEON2 0x008D0000 // Cavium Networks OCTEON 2
|
||||
#define E_MIPS_MACH_OCTEON3 0x008E0000 // Cavium Networks OCTEON 3
|
||||
#define E_MIPS_MACH_5400 0x00910000
|
||||
#define E_MIPS_MACH_5900 0x00920000 // r5900 (Sony Playstation 2 Emotion Engine)
|
||||
#define E_MIPS_MACH_5500 0x00980000
|
||||
#define E_MIPS_MACH_9000 0x00990000
|
||||
#define E_MIPS_MACH_LS2E 0x00A00000 // Loongson/Godson 2E
|
||||
#define E_MIPS_MACH_LS2F 0x00A10000 // Loongson/Godson 2F
|
||||
#define E_MIPS_MACH_ALLEGREX 0x00A20000 // Allegrex (Sony PlayStation Portable)
|
||||
#define E_MIPS_MACH_LS3A 0x00A20000 // Loongson/Godson 3A
|
||||
|
||||
//
|
||||
// p_flags
|
||||
//
|
||||
|
||||
#define PF_MIPS_LOCAL 0x10000000 // special p_flags
|
||||
|
||||
// relocation field - word32 with HIGH BYTE FIRST!!!
|
||||
// A- from Elf32_Rela
|
||||
// B- Loading address of shared object
|
||||
// G- offset into global objet table
|
||||
// GOT- adress of global object table
|
||||
// L- linkage table entry
|
||||
// P- plase of storage unit (computed using r_offset)
|
||||
// S- value of symbol
|
||||
enum elf_RTYPE_mips
|
||||
{
|
||||
R_MIPS_NONE = 0, //No reloc
|
||||
R_MIPS_16 = 1,
|
||||
R_MIPS_32 = 2, //S+A-P Direct32
|
||||
R_MIPS_REL = 3, //S+A Relative32
|
||||
R_MIPS_26 = 4, //S+A Relative26
|
||||
R_MIPS_HI16 = 5,
|
||||
R_MIPS_LO16 = 6,
|
||||
R_MIPS_GPREL = 7, //S+A Relative16
|
||||
R_MIPS_LITERAL = 8,
|
||||
R_MIPS_GOT = 9,
|
||||
R_MIPS_PC16 = 10,
|
||||
R_MIPS_CALL = 11, //Call16
|
||||
R_MIPS_GPREL32 = 12,
|
||||
|
||||
R_MIPS_SHIFT5 = 16,
|
||||
R_MIPS_SHIFT6 = 17,
|
||||
R_MIPS_64 = 18,
|
||||
R_MIPS_GOT_DISP = 19,
|
||||
R_MIPS_GOT_PAGE = 20,
|
||||
R_MIPS_GOT_OFST = 21,
|
||||
R_MIPS_GOT_HI16 = 22,
|
||||
R_MIPS_GOT_LO16 = 23,
|
||||
R_MIPS_SUB = 24,
|
||||
R_MIPS_INSERT_A = 25,
|
||||
R_MIPS_INSERT_B = 26,
|
||||
R_MIPS_DELETE = 27,
|
||||
R_MIPS_HIGHER = 28,
|
||||
R_MIPS_HIGHEST = 29,
|
||||
R_MIPS_CALL_HI16 = 30,
|
||||
R_MIPS_CALL_LO16 = 31,
|
||||
R_MIPS_SCN_DISP = 32,
|
||||
R_MIPS_REL16 = 33,
|
||||
R_MIPS_ADD_IMMEDIATE = 34,
|
||||
R_MIPS_PJUMP = 35,
|
||||
R_MIPS_RELGOT = 36,
|
||||
R_MIPS_JALR = 37,
|
||||
R_MIPS_TLS_DTPMOD32 = 38,
|
||||
R_MIPS_TLS_DTPREL32 = 39,
|
||||
R_MIPS_TLS_DTPMOD64 = 40,
|
||||
R_MIPS_TLS_DTPREL64 = 41,
|
||||
R_MIPS_TLS_GD = 42,
|
||||
R_MIPS_TLS_LDM = 43,
|
||||
R_MIPS_TLS_DTPREL_HI16 = 44,
|
||||
R_MIPS_TLS_DTPREL_LO16 = 45,
|
||||
R_MIPS_TLS_GOTTPREL = 46,
|
||||
R_MIPS_TLS_TPREL32 = 47,
|
||||
R_MIPS_TLS_TPREL64 = 48,
|
||||
R_MIPS_TLS_TPREL_HI16 = 49,
|
||||
R_MIPS_TLS_TPREL_LO16 = 50,
|
||||
|
||||
R_MIPS_GLOB_DAT = 51,
|
||||
R_MIPS_PC21_S2 = 60,
|
||||
R_MIPS_PC26_S2 = 61,
|
||||
R_MIPS_PC18_S3 = 62,
|
||||
R_MIPS_PC19_S2 = 63,
|
||||
R_MIPS_PCHI16 = 64,
|
||||
R_MIPS_PCLO16 = 65,
|
||||
|
||||
R_MIPS16_26 = 100,
|
||||
R_MIPS16_GPREL = 101,
|
||||
R_MIPS16_GOT16 = 102,
|
||||
R_MIPS16_CALL16 = 103,
|
||||
R_MIPS16_HI16 = 104,
|
||||
R_MIPS16_LO16 = 105,
|
||||
|
||||
R_MIPS16_TLS_GD = 106,
|
||||
R_MIPS16_TLS_LDM = 107,
|
||||
R_MIPS16_TLS_DTPREL_HI16= 108,
|
||||
R_MIPS16_TLS_DTPREL_LO16= 109,
|
||||
R_MIPS16_TLS_GOTTPREL = 110,
|
||||
R_MIPS16_TLS_TPREL_HI16 = 111,
|
||||
R_MIPS16_TLS_TPREL_LO16 = 112,
|
||||
R_MIPS16_PC16_S1 = 113,
|
||||
|
||||
// For these two:
|
||||
// http://sourceware.org/ml/binutils/2008-07/txt00000.txt
|
||||
R_MIPS_COPY = 126,
|
||||
R_MIPS_JUMP_SLOT = 127,
|
||||
|
||||
R_MIPS_PC32 = 248,
|
||||
R_MIPS_EH = 249,
|
||||
R_MIPS_GNU_REL16_S2 = 250,
|
||||
R_MIPS_GNU_VTINHERIT = 253,
|
||||
R_MIPS_GNU_VTENTRY = 254,
|
||||
|
||||
// artificial types for the complex 32bit relocs
|
||||
R_MIPS_GPDISP_LO16 = 200,
|
||||
R_MIPS_GPDISP_HI16 = 201,
|
||||
};
|
||||
|
||||
enum elf_ET_MIPS
|
||||
{
|
||||
ET_IRX = 0xFF80u, // IRX file for PS2's IOP
|
||||
ET_PSPEXEC = 0xFFA0u // Sony PSP executable file
|
||||
};
|
||||
|
||||
enum elf_PHT_MIPS
|
||||
{
|
||||
PT_MIPS_IOPMOD = 0x70000080, // Sony PS2 IOP module extension
|
||||
PT_MIPS_EEMOD = 0x70000090, // Sony PS2 EE module extension
|
||||
PT_MIPS_PSPREL = 0x700000A0, // Sony PRX relocations (ELF-style)
|
||||
PT_MIPS_PSPREL2 = 0x700000A1, // Sony PRX relocations (packed)
|
||||
|
||||
// From binutils-2.27/elfcpp/elfcpp.h
|
||||
PT_MIPS_REGINFO = 0x70000000, // Register usage information. Identifies one .reginfo section.
|
||||
PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
|
||||
PT_MIPS_OPTIONS = 0x70000002, // .MIPS.options section.
|
||||
PT_MIPS_ABIFLAGS = 0x70000003, // .MIPS.abiflags section.
|
||||
};
|
||||
|
||||
enum elf_DTAG_MIPS
|
||||
{
|
||||
DT_MIPS_RLD_VERSION = 0x70000001, /* 32 bit version number for runtime linker interface. */
|
||||
DT_MIPS_TIME_STAMP = 0x70000002, /* Time stamp. */
|
||||
DT_MIPS_ICHECKSUM = 0x70000003, /* Checksum of external strings and common sizes. */
|
||||
DT_MIPS_IVERSION = 0x70000004, /* Index of version string in string table. */
|
||||
DT_MIPS_FLAGS = 0x70000005, /* 32 bits of flags. */
|
||||
DT_MIPS_BASE_ADDRESS = 0x70000006, /* Base address of the segment. */
|
||||
DT_MIPS_MSYM = 0x70000007, /* adress of the msym table */
|
||||
DT_MIPS_CONFLICT = 0x70000008, /* Address of .conflict section. */
|
||||
DT_MIPS_LIBLIST = 0x70000009, /* Address of .liblist section. */
|
||||
DT_MIPS_LOCAL_GOTNO = 0x7000000a, /* Number of local global offset table entries. */
|
||||
DT_MIPS_CONFLICTNO = 0x7000000b, /* Number of entries in the .conflict section. */
|
||||
DT_MIPS_LIBLISTNO = 0x70000010, /* Number of entries in the .liblist section. */
|
||||
DT_MIPS_SYMTABNO = 0x70000011, /* Number of entries in the .dynsym section. */
|
||||
DT_MIPS_UNREFEXTNO = 0x70000012, /* Index of first external dynamic symbol not referenced locally. */
|
||||
DT_MIPS_GOTSYM = 0x70000013, /* Index of first dynamic symbol in global offset table. */
|
||||
DT_MIPS_HIPAGENO = 0x70000014, /* Number of page table entries in global offset table. */
|
||||
DT_MIPS_RLD_MAP = 0x70000016, /* Address of run time loader map, used for debugging. */
|
||||
DT_MIPS_DELTA_CLASS = 0x70000017, /* Delta C++ class definition. */
|
||||
DT_MIPS_DELTA_CLASS_NO = 0x70000018, /* Number of entries in DT_MIPS_DELTA_CLASS. */
|
||||
DT_MIPS_DELTA_INSTANCE = 0x70000019, /* Delta C++ class instances. */
|
||||
DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a, /* Number of entries in DT_MIPS_DELTA_INSTANCE. */
|
||||
DT_MIPS_DELTA_RELOC = 0x7000001b, /* Delta relocations. */
|
||||
DT_MIPS_DELTA_RELOC_NO = 0x7000001c, /* Number of entries in DT_MIPS_DELTA_RELOC. */
|
||||
DT_MIPS_DELTA_SYM = 0x7000001d, /* Delta symbols that Delta relocations refer to. */
|
||||
DT_MIPS_DELTA_SYM_NO = 0x7000001e, /* Number of entries in DT_MIPS_DELTA_SYM. */
|
||||
DT_MIPS_DELTA_CLASSSYM = 0x70000020, /* Delta symbols that hold class declarations. */
|
||||
DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021, /* Number of entries in DT_MIPS_DELTA_CLASSSYM. */
|
||||
DT_MIPS_CXX_FLAGS = 0x70000022, /* Flags indicating information about C++ flavor. */
|
||||
DT_MIPS_PIXIE_INIT = 0x70000023, /* Pixie information (???). */
|
||||
DT_MIPS_SYMBOL_LIB = 0x70000024, /* Address of .MIPS.symlib */
|
||||
DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025, /* The GOT index of the first PTE for a segment */
|
||||
DT_MIPS_LOCAL_GOTIDX = 0x70000026, /* The GOT index of the first PTE for a local symbol */
|
||||
DT_MIPS_HIDDEN_GOTIDX = 0x70000027, /* The GOT index of the first PTE for a hidden symbol */
|
||||
DT_MIPS_PROTECTED_GOTIDX = 0x70000028, /* The GOT index of the first PTE for a protected symbol */
|
||||
DT_MIPS_OPTIONS = 0x70000029, /* Address of `.MIPS.options'. */
|
||||
DT_MIPS_INTERFACE = 0x7000002a, /* Address of `.interface'. */
|
||||
DT_MIPS_DYNSTR_ALIGN = 0x7000002b, /* ??? */
|
||||
DT_MIPS_INTERFACE_SIZE = 0x7000002c, /* Size of the .interface section. */
|
||||
DT_MIPS_RLD_TEXT_RESOLVE_ADDR= 0x7000002d, /* Size of rld_text_resolve function stored in the GOT. */
|
||||
DT_MIPS_PERF_SUFFIX = 0x7000002e, /* Default suffix of DSO to be added by rld on dlopen() calls. */
|
||||
DT_MIPS_COMPACT_SIZE = 0x7000002f, /* Size of compact relocation section (O32). */
|
||||
DT_MIPS_GP_VALUE = 0x70000030, /* GP value for auxiliary GOTs. */
|
||||
DT_MIPS_AUX_DYNAMIC = 0x70000031, /* Address of auxiliary .dynamic. */
|
||||
DT_MIPS_PLTGOT = 0x70000032, /* Address of the base of the PLTGOT */
|
||||
DT_MIPS_RWPLT = 0x70000034, /* Points to the base of a writable PLT. */
|
||||
};
|
||||
|
||||
enum elf_SHN_MIPS
|
||||
{
|
||||
SHN_MIPS_ACOMMON = 0xff00, // Defined and allocated common symbol. Value is virtual address.
|
||||
SHN_MIPS_TEXT = 0xff01, // Defined and allocated text symbol. Value is virtual address.
|
||||
SHN_MIPS_DATA = 0xff02, // Defined and allocated data symbol. Value is virtual address.
|
||||
SHN_MIPS_SCOMMON = 0xff03, // Small common symbol.
|
||||
SHN_MIPS_SUNDEFINED = 0xff04 // Small undefined symbol.
|
||||
};
|
||||
|
||||
enum elf_SHF_MIPS
|
||||
{
|
||||
SHF_MIPS_GPREL = 0x10000000, // Section must be part of global data area.
|
||||
SHF_MIPS_MERGE = 0x20000000, // Section data should be merged to eliminate duplication
|
||||
SHF_MIPS_ADDR = 0x40000000, // Section data is addresses by default. Address size to be inferred from section entry size.
|
||||
SHF_MIPS_STRING = 0x80000000, // Section data is string data by default
|
||||
SHF_MIPS_NOSTRIP = 0x08000000, // Section data may not be stripped
|
||||
SHF_MIPS_LOCAL = 0x04000000, // Section data local to process
|
||||
SHF_MIPS_NAMES = 0x02000000, // Linker must generate implicit hidden weak names
|
||||
SHF_MIPS_NODUPE = 0x01000000, // Section contains text/data which may be replicated in other sections. Linker must retain only one copy.
|
||||
};
|
||||
|
||||
enum elf_SHT_MIPS
|
||||
{
|
||||
SHT_MIPS_LIBLIST = 0x70000000, // contains the set of dynamic shared objects used when statically linking.
|
||||
SHT_MIPS_MSYM = 0x70000001, //unknown Irix5 usage
|
||||
SHT_MIPS_CONFLICT = 0x70000002, // list of confliction symbols
|
||||
SHT_MIPS_GPTAB = 0x70000003, // Section contains the global pointer table.
|
||||
SHT_MIPS_UCODE = 0x70000004, //microcode information
|
||||
SHT_MIPS_DEBUG = 0x70000005, //start of debugging information
|
||||
SHT_MIPS_REGINFO = 0x70000006, // Section contains register usage information.
|
||||
SHT_MIPS_RELD = 0x70000009, // Dynamic relocation?
|
||||
SHT_MIPS_IFACE = 0x7000000B, // Subprogram interface information
|
||||
SHT_MIPS_CONTENT = 0x7000000C, // Section content classification
|
||||
SHT_MIPS_OPTIONS = 0x7000000D, // General options
|
||||
SHT_MIPS_DELTASYM = 0x7000001B, // Delta C++: symbol table
|
||||
SHT_MIPS_DELTAINST = 0x7000001C, // Delta C++: instance table
|
||||
SHT_MIPS_DELTACLASS = 0x7000001D, // Delta C++: class table
|
||||
SHT_MIPS_DWARF = 0x7000001E, // DWARF debugging section.
|
||||
SHT_MIPS_DELTADECL = 0x7000001F, // Delta C++: declarations
|
||||
SHT_MIPS_SYMBOL_LIB = 0x70000020, //unknown Irix6 usage
|
||||
SHT_MIPS_EVENTS = 0x70000021, // Events section.
|
||||
SHT_MIPS_TRANSLATE = 0x70000022, // ???
|
||||
SHT_MIPS_PIXIE = 0x70000023, // Special pixie sections
|
||||
SHT_MIPS_XLATE = 0x70000024, // Address translation table
|
||||
SHT_MIPS_XLATE_DEBUG = 0x70000025, // SGI internal address translation table
|
||||
SHT_MIPS_WHIRL = 0x70000026, // Intermediate code
|
||||
SHT_MIPS_EH_REGION = 0x70000027, // C++ exception handling region info
|
||||
SHT_MIPS_XLATE_OLD = 0x70000028, // Obsolete
|
||||
SHT_MIPS_PDR_EXCEPTION = 0x70000029, // Runtime procedure descriptor table exception information (ucode)
|
||||
SHT_MIPS_IOPMOD = 0x70000080, // .ipmod section for PS2 IRXs
|
||||
SHT_MIPS_PSPREL = 0x700000A0, // PSP executable relocation section
|
||||
// VU overlay table (PS2?)
|
||||
SHT_DVP_OVERLAY_TABLE = 0x7FFFF420,
|
||||
SHT_DVP_OVERLAY = 0x7FFFF421,
|
||||
};
|
||||
|
||||
// Special values for the st_other field in the symbol table.
|
||||
enum elf_STO_MIPS
|
||||
{
|
||||
// Two topmost bits denote the MIPS ISA for .text symbols:
|
||||
// + 00 -- standard MIPS code,
|
||||
// + 10 -- microMIPS code,
|
||||
// + 11 -- MIPS16 code; requires the following two bits to be set too.
|
||||
// Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.
|
||||
STO_MIPS_ISA = 0xc0,
|
||||
|
||||
// The MIPS psABI was updated in 2008 with support for PLTs and copy
|
||||
// relocs. There are therefore two types of nonzero SHN_UNDEF functions:
|
||||
// PLT entries and traditional MIPS lazy binding stubs. We mark the former
|
||||
// with STO_MIPS_PLT to distinguish them from the latter.
|
||||
STO_MIPS_PLT = 0x8,
|
||||
|
||||
// This value is used to mark PIC functions in an object that mixes
|
||||
// PIC and non-PIC. Note that this bit overlaps with STO_MIPS16,
|
||||
// although MIPS16 symbols are never considered to be MIPS_PIC.
|
||||
STO_MIPS_PIC = 0x20,
|
||||
|
||||
// This value is used for a mips16 .text symbol.
|
||||
STO_MIPS16 = 0xf0,
|
||||
|
||||
// This value is used for a microMIPS .text symbol. To distinguish from
|
||||
// STO_MIPS16, we set top two bits to be 10 to denote STO_MICROMIPS. The
|
||||
// mask is STO_MIPS_ISA.
|
||||
STO_MICROMIPS = 0x80
|
||||
};
|
||||
|
||||
// .MIPS.options descriptor kinds
|
||||
enum elf_ODK_MIPS
|
||||
{
|
||||
ODK_NULL = 0, // Undefined
|
||||
ODK_REGINFO = 1, // Register usage information
|
||||
ODK_EXCEPTIONS = 2, // Exception processing options
|
||||
ODK_PAD = 3, // Section padding options
|
||||
ODK_HWPATCH = 4, // Hardware patches applied
|
||||
ODK_FILL = 5, // Linker fill value
|
||||
ODK_TAGS = 6, // Space for tool identification
|
||||
ODK_HWAND = 7, // Hardware AND patches applied
|
||||
ODK_HWOR = 8, // Hardware OR patches applied
|
||||
ODK_GP_GROUP = 9, // GP group to use for text/data sections
|
||||
ODK_IDENT = 10, // ID information
|
||||
ODK_PAGESIZE = 11, // Page size information
|
||||
};
|
||||
|
||||
// PSP-specific encoding of r_info field
|
||||
// segment in which the relocation resides
|
||||
// i.e. relocation is at pht[ofs_base].p_vaddr + r_offset
|
||||
#define ELF32_R_OFS_BASE(i) (((i)>>8) & 0xFF)
|
||||
// segment number with the target
|
||||
// i.e. the final address should be adjusted with pht[ofs_base].p_vaddr
|
||||
#define ELF32_R_ADDR_BASE(i) (((i)>>16) & 0xFF)
|
||||
|
||||
|
||||
// MIPS ELF 64 relocation info access macros.
|
||||
// they assume BE byte order of the packed r_type field
|
||||
#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
|
||||
#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
|
||||
#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
|
||||
#define ELF64_MIPS_R_TYPE(i) ((i) & 0xff)
|
||||
|
||||
// Values found in the r_ssym field of a relocation entry.
|
||||
// No relocation.
|
||||
#define RSS_UNDEF 0
|
||||
// Value of GP.
|
||||
#define RSS_GP 1
|
||||
// Value of GP in object being relocated.
|
||||
#define RSS_GP0 2
|
||||
// Address of location being relocated.
|
||||
#define RSS_LOC 3
|
||||
|
||||
// MIPS .msym table entry
|
||||
struct Elf32_Msym
|
||||
{
|
||||
uint32 ms_hash_value; //Contains the hash value computed from the name of the corresponding dynamic symbol
|
||||
uint32 ms_info; //Contains both the dynamic relocation index and the symbol flags field.
|
||||
};
|
||||
|
||||
#define ELF32_MS_REL_INDEX(i) ((i) >> 8)
|
||||
#define ELF32_MS_FLAGS(i) ((i) & 0xff)
|
||||
#define ELF32_MS_INFO(r,f) (((r) << 8) + ((f) & 0xff))
|
||||
|
||||
//MIPS .liblist entry
|
||||
typedef struct
|
||||
{
|
||||
uint32 l_name; //Records the name of a shared library dependency.
|
||||
//The value is a string table index. This name can be a
|
||||
//full pathname, relative pathname, or file name.
|
||||
uint32 l_time_stamp;//Records the time stamp of a shared library dependency.
|
||||
uint32 l_checksum; //Records the checksum of a shared library dependency.
|
||||
uint32 l_version; //Records the interface version of a shared library dependency.
|
||||
//The value is a string table index.
|
||||
uint32 l_flags;
|
||||
} Elf64_Lib;
|
||||
|
||||
// bits for l_flags:
|
||||
#define LL_NONE 0
|
||||
#define LL_EXACT_MATCH 0x1 //Requires that the run-time dynamic shared library file match
|
||||
//exactly the shared library file used at static link time.
|
||||
#define LL_IGNORE_INT_VER 0x2 //Ignores any version incompatibility between the dynamic
|
||||
// shared library file and the shared library file used at link time.
|
||||
#define LL_REQUIRE_MINOR 0x4 //Marks shared library dependencies that should be loaded with
|
||||
//a suffix appended to the name. The DT_SO_SUFFIX entry in
|
||||
//the .dynamic section records the name of this suffix. This is
|
||||
//used by object instrumentation tools to distinguish
|
||||
//instrumented shared libraries.
|
||||
#define LL_EXPORTS 0x8 //Marks entries for shared libraries that are not loaded as direct
|
||||
//dependencies of an object.
|
||||
#define LL_DELAY_LOAD 0x10
|
||||
#define LL_DELTA 0x20
|
||||
|
||||
//.reginfo section
|
||||
struct Elf32_RegInfo
|
||||
{
|
||||
uint32 ri_gprmask;
|
||||
uint32 ri_cprmask[4];
|
||||
uint32 ri_gp_value;
|
||||
};
|
||||
|
||||
void set_mips_compact_encoding(ea_t ea, bool enable);
|
||||
void relocate_psp_section(Elf64_Shdr *rsh, linput_t *li);
|
||||
inline bool is_psp_file(reader_t &reader) { return reader.get_header().e_machine == EM_MIPS && reader.get_header().e_type == ET_PSPEXEC; }
|
||||
|
||||
#endif
|
||||
383
idasdk75/ldr/elf/elfr_ppc.h
Normal file
383
idasdk75/ldr/elf/elfr_ppc.h
Normal file
@@ -0,0 +1,383 @@
|
||||
#ifndef __ELFR_PPC_H__
|
||||
#define __ELFR_PPC_H__
|
||||
|
||||
#ifndef __ELFBASE_H__
|
||||
#include "elfbase.h"
|
||||
#endif
|
||||
|
||||
#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
|
||||
#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag */
|
||||
#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag */
|
||||
|
||||
// PowerPC 64 ABI version
|
||||
#define EF_PPC64_ABI_MASK 3 // original function descriptor using ABI
|
||||
#define EF_PPC64_UNK_ABI 0 // unspecified or not using any features
|
||||
// affected by the differences
|
||||
#define EF_PPC64_AIX_ABI 1 // original function descriptor using ABI
|
||||
#define EF_PPC64_V2_ABI 2 // revised ABI without function descriptors
|
||||
|
||||
enum elf_ET_PPC
|
||||
{
|
||||
ET_PS3PRX = 0xFFA4, // Sony PS3 PRX
|
||||
};
|
||||
|
||||
enum elf_SHT_PPC
|
||||
{
|
||||
SHT_PS3PRX_RELA = 0x700000A4, // Sony PS3 PRX relocations
|
||||
};
|
||||
|
||||
enum elf_PHT_PPC
|
||||
{
|
||||
PHT_PS3PRX_RELA = 0x700000A4, // Sony PS3 PRX relocations
|
||||
};
|
||||
|
||||
enum elf_DT_PPC
|
||||
{
|
||||
DT_PPC_GOT = (DT_LOPROC + 0x0), // address of _GLOBAL_OFFSET_TABLE_
|
||||
};
|
||||
|
||||
// relocation field - word32 with HIGH BYTE FIRST!!!
|
||||
// A- from Elf32_Rela
|
||||
// B- Loading address of shared object
|
||||
// G- offset into global objet table
|
||||
// GOT- adress of global object table
|
||||
// L- linkage table entry
|
||||
// P- plase of storage unit (computed using r_offset)
|
||||
// S- value of symbol
|
||||
enum elf_RTYPE_ppc
|
||||
{
|
||||
R_PPC_NONE = 0, //No reloc
|
||||
R_PPC_ADDR32 = 1, //S+A-P Direct 32 bit
|
||||
R_PPC_ADDR24 = 2,
|
||||
R_PPC_ADDR16 = 3,
|
||||
R_PPC_ADDR16_LO = 4,
|
||||
R_PPC_ADDR16_HI = 5,
|
||||
R_PPC_ADDR16_HA = 6,
|
||||
R_PPC_ADDR14 = 7,
|
||||
R_PPC_ADDR14_BRTAKEN = 8,
|
||||
R_PPC_ADDR14_BRNTAKEN = 9,
|
||||
R_PPC_REL24 = 10, //S+A relative 24 bit
|
||||
R_PPC_REL14 = 11,
|
||||
R_PPC_REL14_BRTAKEN = 12,
|
||||
R_PPC_REL14_BRNTAKEN = 13,
|
||||
R_PPC_GOT16 = 14,
|
||||
R_PPC_GOT16_LO = 15,
|
||||
R_PPC_GOT16_HI = 16,
|
||||
R_PPC_GOT16_HA = 17,
|
||||
R_PPC_PLTREL24 = 18,
|
||||
R_PPC_COPY = 19,
|
||||
R_PPC_GLOB_DAT = 20,
|
||||
R_PPC_JMP_SLOT = 21,
|
||||
R_PPC_RELATIVE = 22,
|
||||
R_PPC_LOCAL24PC = 23,
|
||||
R_PPC_UADDR32 = 24,
|
||||
R_PPC_UADDR16 = 25,
|
||||
R_PPC_REL32 = 26,
|
||||
R_PPC_PLT32 = 27,
|
||||
R_PPC_PLTREL32 = 28,
|
||||
R_PPC_PLT16_LO = 29,
|
||||
R_PPC_PLT16_HI = 30,
|
||||
R_PPC_PLT16_HA = 31,
|
||||
R_PPC_SDAREL16 = 32,
|
||||
R_PPC_SECTOFF = 33,
|
||||
R_PPC_SECTOFF_LO = 34,
|
||||
R_PPC_SECTOFF_HI = 35,
|
||||
R_PPC_SECTOFF_HA = 36,
|
||||
R_PPC_ADDR30 = 37, // word30 (S + A - P) >> 2
|
||||
|
||||
|
||||
// some undocumented relocs used by freescale
|
||||
// some seem to be the same as official VLE relocs below
|
||||
// NB! they conflict with some PPC64 relocations
|
||||
R_PPC_FVLE_REL8 = 38, // same as R_PPC_VLE_REL8?
|
||||
R_PPC_FVLE_REL15 = 39, // same as R_PPC_VLE_REL15?
|
||||
R_PPC_FVLE_REL24 = 40, // same as R_PPC_VLE_REL24?
|
||||
R_PPC_FVLE_ADDR8 = 44, // ??
|
||||
R_PPC_FVLE_ADDR4 = 45, // ??
|
||||
R_PPC_FVLE_SDA = 47, // same as R_PPC_VLE_SDA21?
|
||||
R_PPC_FVLE_LO16A = 49, // same as R_PPC_VLE_LO16A?
|
||||
R_PPC_FVLE_HI16A = 50, // same as R_PPC_VLE_HI16A?
|
||||
R_PPC_FVLE_HA16A = 51, // same as R_PPC_VLE_HA16A?
|
||||
R_PPC_FVLE_LO16D = 56, // same as R_PPC_VLE_LO16D?
|
||||
R_PPC_FVLE_HI16D = 57, // same as R_PPC_VLE_HI16D?
|
||||
R_PPC_FVLE_HA16D = 58, // same as R_PPC_VLE_HA16D?
|
||||
|
||||
/* Relocs added to support TLS. */
|
||||
R_PPC_TLS = 67,
|
||||
R_PPC_DTPMOD32 = 68,
|
||||
R_PPC_TPREL16 = 69,
|
||||
R_PPC_TPREL16_LO = 70,
|
||||
R_PPC_TPREL16_HI = 71,
|
||||
R_PPC_TPREL16_HA = 72,
|
||||
R_PPC_TPREL32 = 73,
|
||||
R_PPC_DTPREL16 = 74,
|
||||
R_PPC_DTPREL16_LO = 75,
|
||||
R_PPC_DTPREL16_HI = 76,
|
||||
R_PPC_DTPREL16_HA = 77,
|
||||
R_PPC_DTPREL32 = 78,
|
||||
R_PPC_GOT_TLSGD16 = 79,
|
||||
R_PPC_GOT_TLSGD16_LO = 80,
|
||||
R_PPC_GOT_TLSGD16_HI = 81,
|
||||
R_PPC_GOT_TLSGD16_HA = 82,
|
||||
R_PPC_GOT_TLSLD16 = 83,
|
||||
R_PPC_GOT_TLSLD16_LO = 84,
|
||||
R_PPC_GOT_TLSLD16_HI = 85,
|
||||
R_PPC_GOT_TLSLD16_HA = 86,
|
||||
R_PPC_GOT_TPREL16 = 87,
|
||||
R_PPC_GOT_TPREL16_LO = 88,
|
||||
R_PPC_GOT_TPREL16_HI = 89,
|
||||
R_PPC_GOT_TPREL16_HA = 90,
|
||||
R_PPC_GOT_DTPREL16 = 91,
|
||||
R_PPC_GOT_DTPREL16_LO = 92,
|
||||
R_PPC_GOT_DTPREL16_HI = 93,
|
||||
R_PPC_GOT_DTPREL16_HA = 94,
|
||||
R_PPC_TLSGD = 95,
|
||||
R_PPC_TLSLD = 96,
|
||||
|
||||
R_PPC_EMB_NADDR32 = 101, // word32 (A - S)
|
||||
R_PPC_EMB_NADDR16 = 102, // half16* (A - S)
|
||||
R_PPC_EMB_NADDR16_LO = 103, // half16 #lo(A - S)
|
||||
R_PPC_EMB_NADDR16_HI = 104, // half16 #hi(A - S)
|
||||
R_PPC_EMB_NADDR16_HA = 105, // half16 #ha(A - S)
|
||||
R_PPC_EMB_SDA_I16 = 106, // half16* T
|
||||
R_PPC_EMB_SDA2_I16 = 107, // half16* U
|
||||
R_PPC_EMB_SDA2REL = 108, // half16* S + A - _SDA2_BASE_
|
||||
R_PPC_EMB_SDA21 = 109, // low21 Y || (X + A)
|
||||
R_PPC_EMB_MRKREF = 110, // none See below
|
||||
R_PPC_EMB_RELSEC16 = 111, // half16* V + A
|
||||
R_PPC_EMB_RELST_LO = 112, // half16 #lo(W + A)
|
||||
R_PPC_EMB_RELST_HI = 113, // half16 #hi(W + A)
|
||||
R_PPC_EMB_RELST_HA = 114, // half16 #ha(W + A)
|
||||
R_PPC_EMB_BIT_FLD = 115, // word32* See below
|
||||
R_PPC_EMB_RELSDA = 116, // half16* X + A. See below
|
||||
R_PPC_EMB_RELOC_120 = 120, // half16* S + A
|
||||
R_PPC_EMB_RELOC_121 = 121, // half16* Same calculation as U, except that the value 0 is used instead of _SDA2_BASE_.
|
||||
|
||||
/* The R_PPC_DIAB_SDA21_xx relocation modes work like the R_PPC_EMB_SDA21 mode
|
||||
* and the R_PPC_DIAB_RELSDA_xx relocation modes work like the R_PPC_EMB_RELSDA mode
|
||||
* with the following exceptions:
|
||||
* If the symbol is in .data, .sdata, .bss, .sbss the symbol is DATA relative
|
||||
(r13 base pointer/_SDA_BASE_ base address)
|
||||
* If the symbol is in .text, .sdata2, .sbss2 the symbol is CODE relative
|
||||
(r2 base pointer/_SDA_BASE2_ base address)
|
||||
* Otherwise the symbol is absolute (r0 base pointer/0 base address)
|
||||
*/
|
||||
R_PPC_DIAB_SDA21_LO = 180, // half21 Y || #lo(X + A)
|
||||
R_PPC_DIAB_SDA21_HI = 181, // half21 Y || #hi(X + A)
|
||||
R_PPC_DIAB_SDA21_HA = 182, // half21 Y || #ha(X + A)
|
||||
R_PPC_DIAB_RELSDA_LO = 183, // half16 #lo(X + A)
|
||||
R_PPC_DIAB_RELSDA_HI = 184, // half16 #hi(X + A)
|
||||
R_PPC_DIAB_RELSDA_HA = 185, // half16 #ha(X + A)
|
||||
R_PPC_DIAB_IMTO = 186,
|
||||
R_PPC_DIAB_IMT = 187,
|
||||
R_PPC_DIAB_ADDR0 = 188,
|
||||
R_PPC_DIAB_OVERRIDE0 = 189,
|
||||
R_PPC_DIAB_VTBL32 = 190,
|
||||
R_PPC_DIAB_LAST = 191,
|
||||
|
||||
R_PPC_EMB_SPE_DOUBLE = 201, // mid5* (#lo(S + A)) >> 3
|
||||
R_PPC_EMB_SPE_WORD = 202, // mid5* (#lo(S + A)) >> 2
|
||||
R_PPC_EMB_SPE_HALF = 203, // mid5* (#lo(S + A)) >> 1
|
||||
R_PPC_EMB_SPE_DOUBLE_SDAREL = 204, // mid5* (#lo(S + A - _SDA_BASE_)) >> 3
|
||||
R_PPC_EMB_SPE_WORD_SDAREL = 205, // mid5* (#lo(S + A - _SDA_BASE_)) >> 2
|
||||
R_PPC_EMB_SPE_HALF_SDAREL = 206, // mid5* (#lo(S + A - _SDA_BASE_)) >> 1
|
||||
R_PPC_EMB_SPE_DOUBLE_SDA2REL = 207, // mid5* (#lo(S + A - _SDA2_BASE_)) >> 3
|
||||
R_PPC_EMB_SPE_WORD_SDA2REL = 208, // mid5* (#lo(S + A - _SDA2_BASE_)) >> 2
|
||||
R_PPC_EMB_SPE_HALF_SDA2REL = 209, // mid5* (#lo(S + A - _SDA2_BASE_)) >> 1
|
||||
R_PPC_EMB_SPE_DOUBLE_SDA0REL = 210, // mid5* (#lo(S + A)) >> 3
|
||||
R_PPC_EMB_SPE_WORD_SDA0REL = 211, // mid5* (#lo(S + A)) >> 2
|
||||
R_PPC_EMB_SPE_HALF_SDA0REL = 212, // mid5* (#lo(S + A)) >> 1
|
||||
R_PPC_EMB_SPE_DOUBLE_SDA = 213, // mid10* Y || ((#lo(X + A)) >> 3)
|
||||
R_PPC_EMB_SPE_WORD_SDA = 214, // mid10* Y || ((#lo(X + A)) >> 2)
|
||||
R_PPC_EMB_SPE_HALF_SDA = 215, // mid10* Y || ((#lo(X + A)) >> 1)
|
||||
|
||||
R_PPC_VLE_REL8 = 216, // bdh8 (S + A - P) >> 1
|
||||
R_PPC_VLE_REL15 = 217, // bdh15 (S + A - P) >> 1
|
||||
R_PPC_VLE_REL24 = 218, // bdh24 (S + A - P) >> 1
|
||||
R_PPC_VLE_LO16A = 219, // split16a #lo(S + A)
|
||||
R_PPC_VLE_LO16D = 220, // split16d #lo(S + A)
|
||||
R_PPC_VLE_HI16A = 221, // split16a #hi(S + A)
|
||||
R_PPC_VLE_HI16D = 222, // split16d #hi(S + A)
|
||||
R_PPC_VLE_HA16A = 223, // split16a #ha(S + A)
|
||||
R_PPC_VLE_HA16D = 224, // split16d #ha(S + A)
|
||||
R_PPC_VLE_SDA21 = 225, // low21, split20 Y || (X + A)
|
||||
R_PPC_VLE_SDA21_LO = 226, // low21, split20 Y || #lo(X + A)
|
||||
R_PPC_VLE_SDAREL_LO16A = 227, // split16a #lo(X + A)
|
||||
R_PPC_VLE_SDAREL_LO16D = 228, // split16d #lo(X + A)
|
||||
R_PPC_VLE_SDAREL_HI16A = 229, // split16a #hi(X + A)
|
||||
R_PPC_VLE_SDAREL_HI16D = 230, // split16d #hi(X + A)
|
||||
R_PPC_VLE_SDAREL_HA16A = 231, // split16a #ha(X + A)
|
||||
R_PPC_VLE_SDAREL_HA16D = 232, // split16d #ha(X + A)
|
||||
|
||||
R_PPC_REL16DX_HA = 246,
|
||||
|
||||
R_PPC_IRELATIVE = 248, // GNU extension to support local ifunc.
|
||||
/* GNU relocs used in PIC code sequences. */
|
||||
R_PPC_REL16 = 249, // half16* S + A - P
|
||||
R_PPC_REL16_LO = 250, // half16 #lo(S + A - P)
|
||||
R_PPC_REL16_HI = 251, // half16 #hi(S + A - P)
|
||||
R_PPC_REL16_HA = 252, // half16 #la(S + A - P)
|
||||
|
||||
R_PPC_GNU_VTINHERIT = 253,
|
||||
R_PPC_GNU_VTENTRY = 254,
|
||||
/* This is a phony reloc to handle any old fashioned TOC16 references
|
||||
that may still be in object files. */
|
||||
R_PPC_TOC16 = 255,
|
||||
|
||||
// PowerPC64 relocations. Many (but not all) of them are the same as for PPC32
|
||||
R_PPC64_NONE = R_PPC_NONE,
|
||||
R_PPC64_ADDR32 = R_PPC_ADDR32, /* 32bit absolute address. */
|
||||
R_PPC64_ADDR24 = R_PPC_ADDR24, /* 26bit address, word aligned. */
|
||||
R_PPC64_ADDR16 = R_PPC_ADDR16, /* 16bit absolute address. */
|
||||
R_PPC64_ADDR16_LO = R_PPC_ADDR16_LO, /* lower 16bits of abs. address. */
|
||||
R_PPC64_ADDR16_HI = R_PPC_ADDR16_HI, /* high 16bits of abs. address. */
|
||||
R_PPC64_ADDR16_HA = R_PPC_ADDR16_HA, /* adjusted high 16bits. */
|
||||
R_PPC64_ADDR14 = R_PPC_ADDR14, /* 16bit address, word aligned. */
|
||||
R_PPC64_ADDR14_BRTAKEN = R_PPC_ADDR14_BRTAKEN,
|
||||
R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN,
|
||||
R_PPC64_REL24 = R_PPC_REL24, /* PC relative 26 bit, word aligned. */
|
||||
R_PPC64_REL14 = R_PPC_REL14, /* PC relative 16 bit. */
|
||||
R_PPC64_REL14_BRTAKEN = R_PPC_REL14_BRTAKEN,
|
||||
R_PPC64_REL14_BRNTAKEN = R_PPC_REL14_BRNTAKEN,
|
||||
R_PPC64_GOT16 = R_PPC_GOT16,
|
||||
R_PPC64_GOT16_LO = R_PPC_GOT16_LO,
|
||||
R_PPC64_GOT16_HI = R_PPC_GOT16_HI,
|
||||
R_PPC64_GOT16_HA = R_PPC_GOT16_HA,
|
||||
R_PPC64_PLTREL24 = R_PPC_PLTREL24,
|
||||
R_PPC64_COPY = R_PPC_COPY,
|
||||
R_PPC64_GLOB_DAT = R_PPC_GLOB_DAT,
|
||||
R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT,
|
||||
R_PPC64_RELATIVE = R_PPC_RELATIVE,
|
||||
R_PPC64_LOCAL24PC = R_PPC_LOCAL24PC,
|
||||
R_PPC64_UADDR32 = R_PPC_UADDR32,
|
||||
R_PPC64_UADDR16 = R_PPC_UADDR16,
|
||||
R_PPC64_REL32 = R_PPC_REL32,
|
||||
R_PPC64_PLT32 = R_PPC_PLT32,
|
||||
R_PPC64_PLTREL32 = R_PPC_PLTREL32,
|
||||
R_PPC64_PLT16_LO = R_PPC_PLT16_LO,
|
||||
R_PPC64_PLT16_HI = R_PPC_PLT16_HI,
|
||||
R_PPC64_PLT16_HA = R_PPC_PLT16_HA,
|
||||
R_PPC64_SDAREL16 = R_PPC_SDAREL16,
|
||||
R_PPC64_SECTOFF = R_PPC_SECTOFF,
|
||||
R_PPC64_SECTOFF_LO = R_PPC_SECTOFF_LO,
|
||||
R_PPC64_SECTOFF_HI = R_PPC_SECTOFF_HI,
|
||||
R_PPC64_SECTOFF_HA = R_PPC_SECTOFF_HA,
|
||||
|
||||
R_PPC64_ADDR30 = 37, /* word30 (S + A - P) >> 2. */
|
||||
R_PPC64_ADDR64 = 38, /* doubleword64 S + A. */
|
||||
R_PPC64_ADDR16_HIGHER = 39, /* half16 #higher(S + A). */
|
||||
R_PPC64_ADDR16_HIGHERA = 40, /* half16 #highera(S + A). */
|
||||
R_PPC64_ADDR16_HIGHEST = 41, /* half16 #highest(S + A). */
|
||||
R_PPC64_ADDR16_HIGHESTA = 42, /* half16 #highesta(S + A). */
|
||||
R_PPC64_UADDR64 = 43, /* doubleword64 S + A. */
|
||||
R_PPC64_REL64 = 44, /* doubleword64 S + A - P. */
|
||||
R_PPC64_PLT64 = 45, /* doubleword64 L + A. */
|
||||
R_PPC64_PLTREL64 = 46, /* doubleword64 L + A - P. */
|
||||
R_PPC64_TOC16 = 47, /* half16* S + A - .TOC. */
|
||||
R_PPC64_TOC16_LO = 48, /* half16 #lo(S + A - .TOC.). */
|
||||
R_PPC64_TOC16_HI = 49, /* half16 #hi(S + A - .TOC.). */
|
||||
R_PPC64_TOC16_HA = 50, /* half16 #ha(S + A - .TOC.). */
|
||||
R_PPC64_TOC = 51, /* doubleword64 .TOC. */
|
||||
R_PPC64_PLTGOT16 = 52, /* half16* M + A. */
|
||||
R_PPC64_PLTGOT16_LO = 53, /* half16 #lo(M + A). */
|
||||
R_PPC64_PLTGOT16_HI = 54, /* half16 #hi(M + A). */
|
||||
R_PPC64_PLTGOT16_HA = 55, /* half16 #ha(M + A). */
|
||||
|
||||
R_PPC64_ADDR16_DS = 56, /* half16ds* (S + A) >> 2. */
|
||||
R_PPC64_ADDR16_LO_DS = 57, /* half16ds #lo(S + A) >> 2. */
|
||||
R_PPC64_GOT16_DS = 58, /* half16ds* (G + A) >> 2. */
|
||||
R_PPC64_GOT16_LO_DS = 59, /* half16ds #lo(G + A) >> 2. */
|
||||
R_PPC64_PLT16_LO_DS = 60, /* half16ds #lo(L + A) >> 2. */
|
||||
R_PPC64_SECTOFF_DS = 61, /* half16ds* (R + A) >> 2. */
|
||||
R_PPC64_SECTOFF_LO_DS = 62, /* half16ds #lo(R + A) >> 2. */
|
||||
R_PPC64_TOC16_DS = 63, /* half16ds* (S + A - .TOC.) >> 2. */
|
||||
R_PPC64_TOC16_LO_DS = 64, /* half16ds #lo(S + A - .TOC.) >> 2. */
|
||||
R_PPC64_PLTGOT16_DS = 65, /* half16ds* (M + A) >> 2. */
|
||||
R_PPC64_PLTGOT16_LO_DS = 66, /* half16ds #lo(M + A) >> 2. */
|
||||
|
||||
/* PowerPC64 relocations defined for the TLS access ABI. */
|
||||
R_PPC64_TLS = 67, /* none (sym+add)@tls */
|
||||
R_PPC64_DTPMOD64 = 68, /* doubleword64 (sym+add)@dtpmod */
|
||||
R_PPC64_TPREL16 = 69, /* half16* (sym+add)@tprel */
|
||||
R_PPC64_TPREL16_LO = 70, /* half16 (sym+add)@tprel@l */
|
||||
R_PPC64_TPREL16_HI = 71, /* half16 (sym+add)@tprel@h */
|
||||
R_PPC64_TPREL16_HA = 72, /* half16 (sym+add)@tprel@ha */
|
||||
R_PPC64_TPREL64 = 73, /* doubleword64 (sym+add)@tprel */
|
||||
R_PPC64_DTPREL16 = 74, /* half16* (sym+add)@dtprel */
|
||||
R_PPC64_DTPREL16_LO = 75, /* half16 (sym+add)@dtprel@l */
|
||||
R_PPC64_DTPREL16_HI = 76, /* half16 (sym+add)@dtprel@h */
|
||||
R_PPC64_DTPREL16_HA = 77, /* half16 (sym+add)@dtprel@ha */
|
||||
R_PPC64_DTPREL64 = 78, /* doubleword64 (sym+add)@dtprel */
|
||||
R_PPC64_GOT_TLSGD16 = 79, /* half16* (sym+add)@got@tlsgd */
|
||||
R_PPC64_GOT_TLSGD16_LO = 80, /* half16 (sym+add)@got@tlsgd@l */
|
||||
R_PPC64_GOT_TLSGD16_HI = 81, /* half16 (sym+add)@got@tlsgd@h */
|
||||
R_PPC64_GOT_TLSGD16_HA = 82, /* half16 (sym+add)@got@tlsgd@ha */
|
||||
R_PPC64_GOT_TLSLD16 = 83, /* half16* (sym+add)@got@tlsld */
|
||||
R_PPC64_GOT_TLSLD16_LO = 84, /* half16 (sym+add)@got@tlsld@l */
|
||||
R_PPC64_GOT_TLSLD16_HI = 85, /* half16 (sym+add)@got@tlsld@h */
|
||||
R_PPC64_GOT_TLSLD16_HA = 86, /* half16 (sym+add)@got@tlsld@ha */
|
||||
R_PPC64_GOT_TPREL16_DS = 87, /* half16ds* (sym+add)@got@tprel */
|
||||
R_PPC64_GOT_TPREL16_LO_DS = 88, /* half16ds (sym+add)@got@tprel@l */
|
||||
R_PPC64_GOT_TPREL16_HI = 89, /* half16 (sym+add)@got@tprel@h */
|
||||
R_PPC64_GOT_TPREL16_HA = 90, /* half16 (sym+add)@got@tprel@ha */
|
||||
R_PPC64_GOT_DTPREL16_DS = 91, /* half16ds* (sym+add)@got@dtprel */
|
||||
R_PPC64_GOT_DTPREL16_LO_DS = 92, /* half16ds (sym+add)@got@dtprel@l */
|
||||
R_PPC64_GOT_DTPREL16_HI = 93, /* half16 (sym+add)@got@dtprel@h */
|
||||
R_PPC64_GOT_DTPREL16_HA = 94, /* half16 (sym+add)@got@dtprel@ha */
|
||||
R_PPC64_TPREL16_DS = 95, /* half16ds* (sym+add)@tprel */
|
||||
R_PPC64_TPREL16_LO_DS = 96, /* half16ds (sym+add)@tprel@l */
|
||||
R_PPC64_TPREL16_HIGHER = 97, /* half16 (sym+add)@tprel@higher */
|
||||
R_PPC64_TPREL16_HIGHERA = 98, /* half16 (sym+add)@tprel@highera */
|
||||
R_PPC64_TPREL16_HIGHEST = 99, /* half16 (sym+add)@tprel@highest */
|
||||
R_PPC64_TPREL16_HIGHESTA = 100, /* half16 (sym+add)@tprel@highesta */
|
||||
R_PPC64_DTPREL16_DS = 101, /* half16ds* (sym+add)@dtprel */
|
||||
R_PPC64_DTPREL16_LO_DS = 102, /* half16ds (sym+add)@dtprel@l */
|
||||
R_PPC64_DTPREL16_HIGHER = 103, /* half16 (sym+add)@dtprel@higher */
|
||||
R_PPC64_DTPREL16_HIGHERA = 104, /* half16 (sym+add)@dtprel@highera */
|
||||
R_PPC64_DTPREL16_HIGHEST = 105, /* half16 (sym+add)@dtprel@highest */
|
||||
R_PPC64_DTPREL16_HIGHESTA = 106, /* half16 (sym+add)@dtprel@highesta */
|
||||
#if 0
|
||||
// These relocation types appear in David Anderson's libdwarf and
|
||||
// dwarfdump only. The PPC 64-Bit ELF V2 ABI uses these numbers for
|
||||
// different types (see below).
|
||||
R_PPC64_TOC32 = 107, /* word32 (.TOC. & 0xffff_ffff) */
|
||||
R_PPC64_DTPMOD32 = 108, /* word32 (@dtpmod & 0xffff_ffff) */
|
||||
R_PPC64_TPREL32 = 109, /* word32 (@tprel & 0xffff_ffff) */
|
||||
R_PPC64_DTPREL32 = 110, /* word32 (@dtprel & 0xffff_ffff) */
|
||||
#else
|
||||
// The PPC 64-Bit ELF V2 ABI uses these numbers for different types
|
||||
R_PPC64_TLSGD = 107, // used as markers on thread local
|
||||
R_PPC64_TLSLD = 108, // storage (TLS) code sequences
|
||||
R_PPC64_TOCSAVE = 109, // this relocation type indicates a
|
||||
// position where a TOC save may be
|
||||
// inserted in the function to avoid a
|
||||
// TOC save as part of the PLT stub code
|
||||
R_PPC64_ADDR16_HIGH = 110, // half16 #hi(S + A)
|
||||
R_PPC64_ADDR16_HIGHA = 111, // half16 #ha(S + A)
|
||||
R_PPC64_TPREL16_HIGH = 112, // half16 #hi(@tprel)
|
||||
R_PPC64_TPREL16_HIGHA = 113, // half16 #ha(@tprel)
|
||||
R_PPC64_DTPREL16_HIGH = 114, // half16 #hi(@dtprel)
|
||||
R_PPC64_DTPREL16_HIGHA = 115, // half16 #ha(@dtprel)
|
||||
R_PPC64_REL24_NOTOC = 116, // low24* (S + A - P) >> 2
|
||||
R_PPC64_ADDR64_LOCAL = 117, // doubleword64 S + A (see 3.5.4)
|
||||
#endif
|
||||
R_PPC64_JMP_IREL = 247, // GNU extension to support local ifunc
|
||||
// The PPC 64-Bit ELF V2 ABI
|
||||
R_PPC64_IRELATIVE = 248, // It is used to implement the
|
||||
// STT_GNU_IFUNC framework
|
||||
R_PPC64_REL16 = R_PPC_REL16, // half16* S + A - P
|
||||
R_PPC64_REL16_LO = R_PPC_REL16_LO, // half16 #lo(S + A - P)
|
||||
R_PPC64_REL16_HI = R_PPC_REL16_HI, // half16* #hi(S + A - P)
|
||||
R_PPC64_REL16_HA = R_PPC_REL16_HA, // half16* #la(S + A - P)
|
||||
};
|
||||
|
||||
// flags for VLE code
|
||||
#define SHF_PPC_VLE 0x10000000 /* section header flag */
|
||||
#define PF_PPC_VLE 0x10000000 /* program header flag */
|
||||
|
||||
// patching GOT loading,
|
||||
// discard auxiliary values in plt/got
|
||||
// can present offset bypass segment
|
||||
#define ELF_RPL_PPC_DEFAULT (ELF_RPL_GL | ELF_DIS_OFFW | ELF_DIS_GPLT)
|
||||
|
||||
#endif
|
||||
3550
idasdk75/ldr/elf/reader.cpp
Normal file
3550
idasdk75/ldr/elf/reader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user