upload android base code part8

This commit is contained in:
August 2018-08-08 20:10:12 +08:00
parent 841ae54672
commit 5425409085
57075 changed files with 9846578 additions and 0 deletions

View file

@ -0,0 +1,399 @@
2015-04-07 HC Yen <hc.yen@mediatek.com>
* arm.h: Add TAG_CPU_ARCH_V8 in Tag_CPU_arch EABI attribute.
2014-09-17 Han Shen <shenhan@google.com>
* aarch64.h (R_AARCH64_TLS_DTPREL64): Switch enum value with ...
(R_AARCH64_TLS_DTPMOD64): ... enum value.
2014-09-15 Andrew Bennett <andrew.bennett@imgtec.com>
Matthew Fortune <matthew.fortune@imgtec.com>
* mips.h (E_MIPS_ARCH_32R6, E_MIPS_ARCH_64R6): New enum constants.
2014-09-02 Cary Coutant <ccoutant@google.com>
* elfcpp_file.h (Elf_file::shnum): New const function.
(Elf_file::shstrndx): New const function.
(Elf_file::large_shndx_offset): New const function.
(Elf_file::section_name): Add const attribute.
(Elf_file::section_header_offset): Likewise.
2014-08-08 Han Shen <shenhan@google.com>
* aarch64.h (withdrawn): Replaced with R_AARCH64_withdrawn.
2014-07-29 Matthew Fortune <matthew.fortune@imgtec.com>
* elfcpp.h (PT_MIPS_ABIFLAGS): New program header type.
2014-07-02 Jing Yu <jingyu@google.com>
* aarch64.h: New file. New enums for aarch64-elf64 relocations.
* elfcpp.h (EM_AARCH64, SHT_AARCH64_ATTRIBUTES, PT_AARCH64_ARCHEXT,
PT_AARCH64_UNWIND): New enum constant.
2014-04-22 Christian Svensson <blue@cmd.nu>
* elfcpp.h: Remove openrisc and or32 support.
2014-04-15 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
* mips.h (R _MIPS16_TLS_GD, R_MIPS16_TLS_LDM, R_MIPS16_TLS_DTPREL_HI16,
R_MIPS16_TLS_DTPREL_LO16, R_MIPS16_TLS_GOTTPREL,
R_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_LO16, R_MICROMIPS_26_S1,
R_MICROMIPS_HI16, R_MICROMIPS_LO16, R_MICROMIPS_GPREL16,
R_MICROMIPS_LITERAL, R_MICROMIPS_GOT16, R_MICROMIPS_PC7_S1,
R_MICROMIPS_PC10_S1, R_MICROMIPS_PC16_S1, R_MICROMIPS_CALL16,
R_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_OFST,
R_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_LO16, R_MICROMIPS_SUB,
R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST, R_MICROMIPS_CALL_HI16,
R_MICROMIPS_CALL_LO16, R_MICROMIPS_SCN_DISP, R_MICROMIPS_JALR,
R_MICROMIPS_HI0_LO16, R_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_LDM,
R_MICROMIPS_TLS_DTPREL_HI16, R_MICROMIPS_TLS_DTPREL_LO16,
R_MICROMIPS_TLS_GOTTPREL, R_MICROMIPS_TLS_TPREL_HI16,
R_MICROMIPS_TLS_TPREL_LO16, R_MICROMIPS_GPREL7_S2,
R_MICROMIPS_PC23_S20, R_MIPS_EH): New enums for relocations (mips16 and
micromips).
(STO_MIPS_FLAGS): New enum constant.
(elf_st_is_mips16): New function.
(elf_st_is_micromips): New function.
(is_micromips): New function.
(abi_n32): New function.
(abi_n64): New function.
(ODK_NULL, ODK_REGINFO, ODK_EXCEPTIONS, ODK_PAD, ODK_HWPATCH, ODK_FILL,
ODK_TAGS, ODK_HWAND, ODK_HWOR, ODK_GP_GROUP, ODK_IDENT): New enum
constants.
* elfcpp.h (SHT_MIPS_OPTIONS): New enum constant.
2014-03-05 Alan Modra <amodra@gmail.com>
Update copyright years.
2014-03-05 Alan Modra <amodra@gmail.com>
* powerpc.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
2014-02-06 Andrew Pinski <apinski@cavium.com>
* mips.h (E_MIPS_MACH_OCTEON3): New enum constant.
2013-11-17 H.J. Lu <hongjiu.lu@intel.com>
* x86_64.h (R_X86_64_PC32_BND): New.
(R_X86_64_PLT32_BND): Likewise.
2013-10-30 Alan Modra <amodra@gmail.com>
* powerpc.h (EF_PPC64_ABI): New enum constant.
(STO_PPC64_LOCAL_BIT, STO_PPC64_LOCAL_MASK): Likewise.
(ppc64_decode_local_entry): New function.
(ppc64_encode_local_entry): Likewise.
2013-10-30 Alan Modra <amodra@gmail.com>
* powerpc.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): Define.
2013-03-01 Cary Coutant <ccoutant@google.com>
* dwarf.h (enum DW_LANG): Adjust spacing for consistency.
(enum DW_SECT): New enum type.
2012-12-17 Nick Clifton <nickc@redhat.com>
* README: Add copyright notice.
2012-10-30 Steve McIntyre <steve.mcintyre@linaro.org>
* arm.h: New enum for EABI soft- and hard-float flags.
2012-09-15 Jiong Wang <jiwang@tilera.com>
* tilegx.h: New file.
* elfcpp.h: add EM_TILEGX.
2012-08-14 Alan Modra <amodra@gmail.com>
* powerpc.h: Add more relocs.
(R_PPC_REL16*): Rename to R_POWERPC_REL16*.
2012-05-11 H.J. Lu <hongjiu.lu@intel.com>
PR gold/14091
* x86_64.h (R_X86_64_RELATIVE64): New.
2012-05-01 Cary Coutant <ccoutant@google.com>
* dwarf.h (enum DW_TAG, enum DW_FORM, enum DW_AT, enum DW_ENCODING)
(enum DW_OP, enum DW_CFA): Remove.
Include dwarf2.def.
2012-04-23 Cary Coutant <ccoutant@google.com>
* elfcpp_swap.h (struct Swap_aligned32): New template.
2012-04-16 David S. Miller <davem@davemloft.net>
* sparc.h (R_SPARC_JMP_IREL): New relocation.
2012-04-12 David S. Miller <davem@davemloft.net>
* sparc.h (R_SPARC_WDISP10): New relocation.
2012-03-12 Cary Coutant <ccoutant@google.com>
Update DWARF enums from ../include/dwarf2.h.
* dwarf.h (enum DW_TAG): Add new DWARF-4 tags.
(enum DW_FORM): Add new DWARF-4 and Fission extensions.
(enum DW_AT): New enum.
(enum DW_LINE_EXTENDED_OPS): Add new DWARF-4 opcode.
(enum DW_ENCODING): Add new DWARF-4 encoding.
(enum DW_OP): Add new DWARF-4 opcodes.
(enum DW_CHILDREN): New enum.
(enum DW_LANG): New enum.
2012-01-27 Aleksandar Simeonov <asimeonov@mips.com>
* mips.h: New file
* elfcpp.h (SHT_MIPS_REGINFO): New enums for processor-specific flags.
(SHF_MIPS_GPREL): Likewise.
(PT_MIPS_REGINFO, PT_MIPS_RTPROC, PT_MIPS_OPTIONS): Likewise.
(DT_MIPS_RLD_VERSION, DT_MIPS_TIME_STAMP, DT_MIPS_ICHECKSUM,
DT_MIPS_IVERSION, DT_MIPS_FLAGS, DT_MIPS_BASE_ADDRESS, DT_MIPS_MSYM,
DT_MIPS_CONFLICT, DT_MIPS_LIBLIST, DT_MIPS_LOCAL_GOTNO,
DT_MIPS_CONFLICTNO, DT_MIPS_LIBLISTNO, DT_MIPS_SYMTABNO,
DT_MIPS_UNREFEXTNO, DT_MIPS_GOTSYM, DT_MIPS_HIPAGENO, DT_MIPS_RLD_MAP,
DT_MIPS_DELTA_CLASS, DT_MIPS_DELTA_CLASS_NO, DT_MIPS_DELTA_INSTANCE,
DT_MIPS_DELTA_INSTANCE_NO, DT_MIPS_DELTA_RELOC, DT_MIPS_DELTA_RELOC_NO,
DT_MIPS_DELTA_SYM, DT_MIPS_DELTA_SYM_NO, DT_MIPS_DELTA_CLASSSYM,
DT_MIPS_DELTA_CLASSSYM_NO, DT_MIPS_CXX_FLAGS, DT_MIPS_PIXIE_INIT,
DT_MIPS_SYMBOL_LIB, DT_MIPS_LOCALPAGE_GOTIDX, DT_MIPS_LOCAL_GOTIDX,
DT_MIPS_HIDDEN_GOTIDX, DT_MIPS_PROTECTED_GOTIDX, DT_MIPS_OPTIONS,
DT_MIPS_INTERFACE, DT_MIPS_DYNSTR_ALIGN, DT_MIPS_INTERFACE_SIZE,
DT_MIPS_RLD_TEXT_RESOLVE_ADDR, DT_MIPS_PERF_SUFFIX,
DT_MIPS_COMPACT_SIZE, DT_MIPS_GP_VALUE, DT_MIPS_AUX_DYNAMIC,
DT_MIPS_PLTGOT, DT_MIPS_RWPLT): Likewise.
2012-01-27 Ian Lance Taylor <iant@google.com>
* elfcpp.h (STT_GNU_IFUNC): Add comment.
2011-07-03 Samuel Thibault <samuel.thibault@gnu.org>
Thomas Schwinge <thomas@schwinge.name>
PR binutils/12913
* elfcpp.h (ELFOSABI): Add ELFOSABI_GNU with value of ELFOSABI_LINUX,
keep ELFOSABI_LINUX as an alias. Remove ELFOSABI_HURD.
2011-07-01 Ian Lance Taylor <iant@google.com>
* dwarf.h (enum DW_CFA): Define.
2010-08-12 Cary Coutant <ccoutant@google.com>
* elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_GOT_PLT.
2010-08-12 Cary Coutant <ccoutant@google.com>
* elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB,
SHT_GNU_INCREMENTAL_RELOCS.
2010-08-04 Ian Lance Taylor <iant@google.com>
* i386.h (R_386_IRELATIVE): Define.
* powerpc.h (R_POWERPC_IRELATIVE): Define.
(R_PPC_RELAX32, R_PPC_RELAX32PC): Don't define.
(R_PPC_RELAX32_PLT, R_PPC_RELAX32PC_PLT): Don't define.
* sparc.h (R_SPARC_IRELATIVE): Define.
* x86_64.h (R_X86_64_IRELATIVE): Define.
(R_X86_64_GNU_VTINHERIT): Rename from R_386_GNU_VTINHERIT.
(R_X86_64_GNU_VTENTRY): Rename from R_386_GNU_VTENTRY.
2010-05-12 Doug Kwan <dougkwan@google.com>
* arm.h (Tag_FP_arch, Tag_ABI_align_needed, Tag_ABI_align_preserved,
Tag_FP_HP_extension, Tag_MPextension_use_legacy): Rename from
existing tags.
(Tag_undefined40, Tag_undefined41, Tag_MPextension_use,
Tag_undefined43): New tags.
(Targ_VFP_arch, Tag_ABI_align8_needed, TAG_ABI_align8_preserved,
Tag_VFP_HP_extension): Define aliases for backward compatiblity.
2010-03-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* elfcpp.h (VER_FLG_INFO): Define.
2010-01-21 Doug Kwan <dougkwan@google.com>
* arm.h (EXIDX_CANTUNWIND): New enum.
2010-01-19 Ian Lance Taylor <iant@google.com>
* elfcpp.h (PN_XNUM): Define.
2009-12-14 Ian Lance Taylor <iant@google.com>
* elfcpp_file.h: Revert last patch.
2009-12-11 Nick Clifton <nickc@redhat.com>
* elfcpp_file.h: Fix shadowed variable warnings.
2009-12-10 Doug Kwan <dougkwan@google.com>
* arm.h: New enums for EABI object attribute tags and values.
2009-12-05 Doug Kwan <dougkwan@google.com>
* arm.h: Define enums for Tag_CPU_arch EABI attribute.
2009-11-24 Rafael Avila de Espindola <espindola@google.com>
* elfcpp_file.h: Include elfcpp.h.
2009-11-03 Ian Lance Taylor <iant@google.com>
* elfcpp.h: Remove trailing commas from enum definitions.
2009-10-30 Doug Kwan <dougkwan@google.com>
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
2009-10-16 Doug Kwan <dougkwan@google.com>
* elfcpp/elfcpp.h (DT_PREINIT_ARRAY): Correct enum value.
2009-10-09 Andrew Pinski <andrew_pinski@playstation.sony.com>
* elfcpp/elfcpp_file.h (Elf_file::section_name): Change shstr_size
to Elf_WXword.
2009-10-09 Mikolaj Zalewski <mikolajz@google.com>
* elf_file.h: (class Elf_strtab): New class.
2009-10-09 Mikolaj Zalewski <mikolajz@google.com>
* elfcpp_file.h: Fix header guard. Include <cstdio>.
(class Elf_recognizer): New class, code from gold/object.cc.
(Elf_file::find_section_by_type): New method.
2009-07-23 Ulrich Drepper <drepper@redhat.com>
* elfcpp.h (enum STB): Add STB_GNU_UNIQUE.
2009-06-21 Ian Lance Taylor <iant@google.com>
* elfcpp.h (SHN_X86_64_LCOMMON): Define enum constant.
(enum SHT): Add SHT_X86_64_UNWIND.
(enum SHF): Add SHT_X86_64_LARGE.
2009-05-27 Doug Kwan <dougkwan@google.com>
* arm.h: New file.
* elfcpp.h (enum SHT): Add ARM-specific special sections.
(enum PT): Add ARM-specific section types.
(enum SST): Add STT_ARM_TFUNC.
2009-04-30 Nick Clifton <nickc@redhat.com>
* elfcpp.h (enum STT): Add STT_GNU_IFUNC.
2009-03-20 Mikolaj Zalewski <mikolajz@google.com>
* elfcpp.h (SHT_GNU_INCREMENTAL_INPUTS): Define.
2009-03-01 Ian Lance Taylor <iant@google.com>
* elfcpp_swap.h: #include "config.h". Only #include <byteswap.h>
if HAVE_BYTESWAP_H is defined; if not, provide definitions for
bswap_{16,32,64}. For gcc 4.3 and later, use the builtin bswap
functions. Check WORDS_BIGENDIAN rather than __BYTE_ORDER.
2009-01-06 H.J. Lu <hongjiu.lu@intel.com>
* elfcpp.h (enum STT): Remove STT_IFUNC.
2008-12-03 Nick Clifton <nickc@redhat.com>
* elfcpp.h (enum STT): Add STT_IFUNC.
2008-06-12 David S. Miller <davem@davemloft.net>
* powerpc.h: New file.
* elfcpp.h (SHT_ORDERED): New enum constant.
(DT_PPC_GOT, DT_PPC64_GLINK, DT_PPC64_OPD, DT_PPC64_OPDSZ): Same.
2008-05-28 Caleb Howe <cshowe@google.com>
* dwarf.h (enum DW_FORM): Define.
2008-04-19 Ian Lance Taylor <iant@google.com>
* elfcpp_file.h (class Elf_file): Add large_shndx_offset_ field.
(Elf_file::large_shndx_offset): New function.
(Elf_file::construct): Initialize large_shndx_offset_.
(Elf_File::initialize_shnum): If necessary, adjust shstrndx_ and
set large_shndx_offset_.
2008-04-16 David S. Miller <davem@davemloft.net>
* elfcpp.h (DF_1_NOW, DF_1_GLOBAL, DF_1_GROUP,
DF_1_NODELETE, DF_1_LOADFLTR, DF_1_INITFIRST,
DF_1_NOOPEN, DF_1_ORIGIN, DF_1_DIRECT, DF_1_TRANS,
DF_1_INTERPOSE, DF_1_NODEFLIB, DF_1_NODUMP,
DF_1_CONLFAT): New enum constants.
2008-04-15 David S. Miller <davem@davemloft.net>
* sparc.h (EF_SPARC_EXT_MASK, EF_SPARC_32PLUS_MASK,
EF_SPARC_32PLUS, EF_SPARC_SUN_US1, EF_SPARC_HAL_R1,
EF_SPARC_SUN_US3, EF_SPARC_LEDATA, EF_SPARCV9_MM,
EF_SPARCV9_TSO, EF_SPARCV9_PSO, EF_SPARCV9_RMO):
Define as enum constants.
2008-04-11 David S. Miller <davem@davemloft.net>
* sparc.h: New file
* elfcpp.h (SHN_BEFORE, SHN_AFTER): New enum constants.
(SHT_SPARC_GOTDATA, SHF_ORDERED, SHF_EXCLUDE,
STT_SPARC_REGISTER, DT_SPARC_REGISTER): Likewise.
2008-04-03 Ian Lance Taylor <iant@google.com>
* elfcpp_swap.h (Swap_unaligned<64, true>::writeval): Correct
byte order.
2008-03-24 Ian Lance Taylor <iant@google.com>
* elfcpp.h (NT_VERSION, NT_ARCH): Define as enum constants.
(NT_GNU_ABI_TAG, NT_GNU_HWCAP): Likewise.
(NT_GNU_BUILD_ID, NT_GNU_GOLD_VERSION): Likewise.
(ELF_NOTE_OS_LINUX, ELF_NOTE_OS_GNU): Likewise.
(ELF_NOTE_OS_SOLARIS2, ELF_NOTE_OS_NETBSD): Likewise.
(ELF_NOTE_OS_SYLLABLE): Likewise.
2008-03-21 Ian Lance Taylor <iant@google.com>
* Added source code to GNU binutils.
Copyright (C) 2008-2014 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
Local Variables:
mode: change-log
left-margin: 8
fill-column: 74
version-control: never
End:

View file

@ -0,0 +1,16 @@
elfcpp is a C++ library for reading and writing ELF information. This
was written to support gold, the ELF linker, and may not be generally
useful.
elfcpp does not do file I/O. It deals only with offsets and memory
data.
For efficiency, most accessors are templates with two arguments: the
ELF file class (32 or 64 bits) and the endianness.
Copyright (C) 2012-2014 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

View file

@ -0,0 +1,187 @@
// aarch64.h -- ELF definitions specific to AARCH64 -*- C++ -*-
// Copyright (C) 2014 Free Software Foundation, Inc.
// Written by Jing Yu (jingyu@google.com)
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_AARCH64_H
#define ELFCPP_AARCH64_H
namespace elfcpp
{
// The relocation type information is taken from:
//
// ELF for the ARM 64-bit Architecture (AArch64)
// Document number: ARM IHI 0056B, current through AArch64 ABI release 1.0
// Date of Issue: 22nd May, 2013
//
enum
{
// Null relocation codes
R_AARCH64_NONE = 0, // None
R_AARCH64_withdrawn = 256, // Treat as R_AARCH64_NONE
// Static relocations
R_AARCH64_ABS64 = 257, // S + A
R_AARCH64_ABS32 = 258, // S + A
R_AARCH64_ABS16 = 259, // S + A
R_AARCH64_PREL64 = 260, // S + A - P
R_AARCH64_PREL32 = 261, // S + A - P
R_AARCH64_PREL16 = 262, // S + A - P
R_AARCH64_MOVW_UABS_G0 = 263, // S + A
R_AARCH64_MOVW_UABS_G0_NC = 264, // S + A
R_AARCH64_MOVW_UABS_G1 = 265, // S + A
R_AARCH64_MOVW_UABS_G1_NC = 266, // S + A
R_AARCH64_MOVW_UABS_G2 = 267, // S + A
R_AARCH64_MOVW_UABS_G2_NC = 268, // S + A
R_AARCH64_MOVW_UABS_G3 = 269, // S + A
R_AARCH64_MOVW_SABS_G0 = 270, // S + A
R_AARCH64_MOVW_SABS_G1 = 271, // S + A
R_AARCH64_MOVW_SABS_G2 = 272, // S + A
R_AARCH64_LD_PREL_LO19 = 273, // S + A - P
R_AARCH64_ADR_PREL_LO21 = 274, // S + A - P
R_AARCH64_ADR_PREL_PG_HI21 = 275, // Page(S+A) - Page(P)
R_AARCH64_ADR_PREL_PG_HI21_NC = 276, // Page(S+A) - Page(P)
R_AARCH64_ADD_ABS_LO12_NC = 277, // S + A
R_AARCH64_LDST8_ABS_LO12_NC = 278, // S + A
R_AARCH64_TSTBR14 = 279, // S + A - P
R_AARCH64_CONDBR19 = 280, // S + A - P
R_AARCH64_JUMP26 = 282, // S + A - P
R_AARCH64_CALL26 = 283, // S + A - P
R_AARCH64_LDST16_ABS_LO12_NC = 284, // S + A
R_AARCH64_LDST32_ABS_LO12_NC = 285, // S + A
R_AARCH64_LDST64_ABS_LO12_NC = 286, // S + A
R_AARCH64_MOVW_PREL_G0 = 287, // S + A - P
R_AARCH64_MOVW_PREL_G0_NC = 288, // S + A - P
R_AARCH64_MOVW_PREL_G1 = 289, // S + A - P
R_AARCH64_MOVW_PREL_G1_NC = 290, // S + A - P
R_AARCH64_MOVW_PREL_G2 = 291, // S + A - P
R_AARCH64_MOVW_PREL_G2_NC = 292, // S + A - P
R_AARCH64_MOVW_PREL_G3 = 293, // S + A - P
R_AARCH64_LDST128_ABS_LO12_NC = 299, // S + A
R_AARCH64_MOVW_GOTOFF_G0 = 300, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G0_NC = 301, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G1 = 302, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G1_NC = 303, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G2 = 304, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G2_NC = 305, // G(GDAT(S+A))-GOT
R_AARCH64_MOVW_GOTOFF_G3 = 306, // G(GDAT(S+A))-GOT
R_AARCH64_GOTREL64 = 307, // S + A - GOT
R_AARCH64_GOTREL32 = 308, // S + A - GOT
R_AARCH64_GOT_LD_PREL19 = 309, // G(GDAT(S+A))-P
R_AARCH64_LD64_GOTOFF_LO15 = 310, // G(GDAT(S+A))-GOT
R_AARCH64_ADR_GOT_PAGE = 311, // Page(G(GDAT(S+A)))-Page(P)
R_AARCH64_LD64_GOT_LO12_NC = 312, // G(GDAT(S+A))
R_AARCH64_LD64_GOTPAGE_LO15 = 313, // G(GDAT(S+A))-Page(GOT)
// Relocations for thread-local storage
R_AARCH64_TLSGD_ADR_PREL21 = 512, // G(GTLSIDX(S,A)) - P
R_AARCH64_TLSGD_ADR_PAGE21 = 513, // Page(G(GTLSIDX(S,A)))-Page(P)
R_AARCH64_TLSGD_ADD_LO12_NC = 514, // G(GTLSICX(S,A))
R_AARCH64_TLSGD_MOVW_G1 = 515, // G(GTLSIDX(S,A)) - GOT
R_AARCH64_TLSGD_MOVW_G0_NC = 516, // G(GTLSIDX(S,A)) - GOT
R_AARCH64_TLSLD_ADR_PREL21 = 517, // G(GLDM(S)) - P
R_AARCH64_TLSLD_ADR_PAGE21 = 518, // Page(G(GLDM(S))) - Page(P)
R_AARCH64_TLSLD_ADD_LO12_NC = 519, // G(GLDM(S))
R_AARCH64_TLSLD_MOVW_G1 = 520, // G(GLDM(S)) - GOT
R_AARCH64_TLSLD_MOVW_G0_NC = 521, // G(GLDM(S)) - GOT
R_AARCH64_TLSLD_LD_PREL19 = 522, // G(GLDM(S)) - P
R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523, // DTPREL(S+A)
R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524, // DTPREL(S+A)
R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525, // DTPREL(S+A)
R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526, // DTPREL(S+A)
R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527, // DTPREL(S+A)
R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528, // DTPREL(S+A)
R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529, // DTPREL(S+A)
R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538, // DTPREL(S+A)
R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539, // G(GTPREL(S+A)) - GOT
R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540, // G(GTPREL(S+A)) - GOT
R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541, // Page(G(GTPREL(S+A)))-Page(P)
R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542, // G(GTPREL(S+A))
R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543, // G(GTPREL(S+A)) - P
R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544, // TPREL(S+A)
R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545, // TPREL(S+A)
R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546, // TPREL(S+A)
R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547, // TPREL(S+A)
R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548, // TPREL(S+A)
R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549, // TPREL(S+A)
R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550, // TPREL(S+A)
R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551, // TPREL(S+A)
R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552, // TPREL(S+A)
R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553, // TPREL(S+A)
R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554, // TPREL(S+A)
R_AARCH64_TLSLE_LSDT16_TPREL_LO12_NC = 555, // TPREL(S+A)
R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556, // TPREL(S+A)
R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557, // TPREL(S+A)
R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558, // TPREL(S+A)
R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559, // TPREL(S+A)
R_AARCH64_TLSDESC_LD_PREL19 = 560, // G(GTLSDESC(S+A)) - P
R_AARCH64_TLSDESC_ADR_PREL21 = 561, // G(GTLSDESC(S+A)) - P
R_AARCH64_TLSDESC_ADR_PAGE21 = 562, // Page(G(GTLSDESC(S+A)))-Page(P)
R_AARCH64_TLSDESC_LD64_LO12 = 563, // G(GTLSDESC(S+A))
R_AARCH64_TLSDESC_ADD_LO12 = 564, // G(GTLSDESC(S+A))
R_AARCH64_TLSDESC_OFF_G1 = 565, // G(GTLSDESC(S+A)) - GOT
R_AARCH64_TLSDESC_OFF_G0_NC = 566, // G(GTLSDESC(S+A)) - GOT
R_AARCH64_TLSDESC_LDR = 567, // None
R_AARCH64_TLSDESC_ADD = 568, // None
R_AARCH64_TLSDESC_CALL = 569, // None
R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570, // TPREL(S+A)
R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571, // TPREL(S+A)
R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572, // DTPREL(S+A)
R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573, // DTPREL(S+A)
// Dynamic relocations
R_AARCH64_COPY = 1024,
R_AARCH64_GLOB_DAT = 1025, // S + A
R_AARCH64_JUMP_SLOT = 1026, // S + A
R_AARCH64_RELATIVE = 1027, // Delta(S) + A
// Note (shenhan): the following 2 relocs are different from elf spec from
// arm. In elf docs, TLS_DTPMOD64 is defined as 1029, TLS_DTPREL64 1028.
// While actually the bfd linker (and the dynamic linker) treates TLS_DTPMOD64
// as 1028, TLS_DTPREL64 1029. See binutils-gdb/include/elf/aarch64.h.
R_AARCH64_TLS_DTPMOD64 = 1028, // LDM(S)
R_AARCH64_TLS_DTPREL64 = 1029, // DTPREL(S+A)
R_AARCH64_TLS_TPREL64 = 1030, // TPREL(S+A)
R_AARCH64_TLSDESC = 1031, // TLSDESC(S+A)
R_AARCH64_IRELATIVE = 1032, // Indirect(Delta(S) + A)
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_AARCH64_H)

View file

@ -0,0 +1,372 @@
// arm.h -- ELF definitions specific to EM_ARM -*- C++ -*-
// Copyright (C) 2009-2014 Free Software Foundation, Inc.
// Written by Doug Kwan <dougkwan@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_ARM_H
#define ELFCPP_ARM_H
// The relocation type information is taken from:
//
// ELF for the ARM Architecture
// Document number: ARM IHI 0044C, current through ABI release 2.07
// Date of Issue: 10th October, 2008
//
namespace elfcpp
{
//
// ARM Relocations Codes
//
// Operation notes:
// S: Address of the symbol.
// A: Addend for relocation.
// P: Address of the place being relocated.
// Pa: Adjusted address of the place being relocated (P & 0xfffffffc)
// T: is 1 if S has type STT_FUNC and the symbol addresses a Thumb
// instruction.Thumb-bit; it is 0 otherwise.
// B(S): Addressing origin of the output segment defining S.
// GOT_ORG: Addressing origin of the Global Offset Table.
// GOT(S): Address of the GOT entry for S.
//
enum
{
// Type Class Operation
// ------------------------------
R_ARM_NONE = 0, // Static Misc
R_ARM_PC24 = 1, // Deprecated ARM ((S + A) | T) - P
R_ARM_ABS32 = 2, // Static Data (S + A) | T
R_ARM_REL32 = 3, // Static Data ((S + A) | T) - P
R_ARM_LDR_PC_G0 = 4, // Static ARM S + A - P
R_ARM_ABS16 = 5, // Static Data S + A
R_ARM_ABS12 = 6, // Static ARM S + A
R_ARM_THM_ABS5 = 7, // Static Thumb16 S + A
R_ARM_ABS8 = 8, // Static Data S + A
R_ARM_SBREL32 = 9, // Static Data ((S + A) | T) - B(S)
R_ARM_THM_CALL = 10, // Static Thumb32 ((S + A) | T) - P
R_ARM_THM_PC8 = 11, // Static Thumb16
R_ARM_BREL_ADJ = 12, // Dynamic Data DeltaB(S) + A
R_ARM_TLS_DESC = 13, // Dynamic Data
R_ARM_THM_SWI8 = 14, // Obsolete
R_ARM_XPC25 = 15, // Obsolete
R_ARM_THM_XPC22 = 16, // Obsolete
R_ARM_TLS_DTPMOD32 = 17, // Dynamic Data Module(S)
R_ARM_TLS_DTPOFF32 = 18, // Dynamic Data S + A - TLS
R_ARM_TLS_TPOFF32 = 19, // Dynamic Data S + A - tp
R_ARM_COPY = 20, // Dynamic Misc
R_ARM_GLOB_DAT = 21, // Dynamic Data (S + A) | T
R_ARM_JUMP_SLOT = 22, // Dynamic Data (S + A) | T
R_ARM_RELATIVE = 23, // Dynamic Data B(S) + A
R_ARM_GOTOFF32 = 24, // Static Data (((S + A) | T) - GOT_ORG
R_ARM_BASE_PREL = 25, // Static Data B(S) + A - P
R_ARM_GOT_BREL = 26, // Static Data GOT(S) + A - GOT_ORG
R_ARM_PLT32 = 27, // Deprecated ARM ((S + A) | T) - P
R_ARM_CALL = 28, // Static ARM ((S + A) | T) - P
R_ARM_JUMP24 = 29, // Static ARM ((S + A) | T) - P
R_ARM_THM_JUMP24 = 30, // Static Thumb32 ((S + A) | T) - P
R_ARM_BASE_ABS = 31, // Static Data B(S) + A
R_ARM_ALU_PCREL_7_0 = 32, // Obsolete
R_ARM_ALU_PCREL_15_8 = 33, // Obsolete
R_ARM_ALU_PCREL_23_15 = 34, // Obsolete
R_ARM_LDR_SBREL_11_0_NC = 35, // Deprecated ARM S + A - B(S)
R_ARM_ALU_SBREL_19_12_NC = 36,// Deprecated ARM S + A - B(S)
R_ARM_ALU_SBREL_27_20_CK = 37,// Deprecated ARM S + A - B(S)
R_ARM_TARGET1 = 38, // Data Misc (S + A) | T or
// ((S + A) | T) - P
R_ARM_SBREL31 = 39, // Deprecated Data ((S + A) | T) - B(S)
R_ARM_V4BX = 40, // Static Misc
R_ARM_TARGET2 = 41, // Static Misc
R_ARM_PREL31 = 42, // Static Data ((S + A) | T) - P
R_ARM_MOVW_ABS_NC = 43, // Static ARM (S + A) | T
R_ARM_MOVT_ABS = 44, // Static ARM S + A
R_ARM_MOVW_PREL_NC = 45, // Static ARM ((S + A) | T) - P
R_ARM_MOVT_PREL = 46, // Static ARM S + A - P
R_ARM_THM_MOVW_ABS_NC = 47, // Static Thumb32 (S + A) | T
R_ARM_THM_MOVT_ABS = 48, // Static Thumb32 S + A - P
R_ARM_THM_MOVW_PREL_NC = 49, // Static Thumb32 ((S + A) | T) - P
R_ARM_THM_MOVT_PREL = 50, // Static Thumb32 S + A - P
R_ARM_THM_JUMP19 = 51, // Static Thumb32 ((S + A) | T) - P
R_ARM_THM_JUMP6 = 52, // Static Thumb16 S + A - P
R_ARM_THM_ALU_PREL_11_0 = 53, // Static Thumb32 ((S + A) | T) - Pa
R_ARM_THM_PC12 = 54, // Static Thumb32 S + A - Pa
R_ARM_ABS32_NOI = 55, // Static Data S + A
R_ARM_REL32_NOI = 56, // Static Data S + A - P
R_ARM_ALU_PC_G0_NC = 57, // Static ARM ((S + A) | T) - P
R_ARM_ALU_PC_G0 = 58, // Static ARM ((S + A) | T) - P
R_ARM_ALU_PC_G1_NC = 59, // Static ARM ((S + A) | T) - P
R_ARM_ALU_PC_G1 = 60, // Static ARM ((S + A) | T) - P
R_ARM_ALU_PC_G2 = 61, // Static ARM ((S + A) | T) - P
R_ARM_LDR_PC_G1 = 62, // Static ARM S + A - P
R_ARM_LDR_PC_G2 = 63, // Static ARM S + A - P
R_ARM_LDRS_PC_G0 = 64, // Static ARM S + A - P
R_ARM_LDRS_PC_G1 = 65, // Static ARM S + A - P
R_ARM_LDRS_PC_G2 = 66, // Static ARM S + A - P
R_ARM_LDC_PC_G0 = 67, // Static ARM S + A - P
R_ARM_LDC_PC_G1 = 68, // Static ARM S + A - P
R_ARM_LDC_PC_G2 = 69, // Static ARM S + A - P
R_ARM_ALU_SB_G0_NC = 70, // Static ARM ((S + A) | T) - B(S)
R_ARM_ALU_SB_G0 = 71, // Static ARM ((S + A) | T) - B(S)
R_ARM_ALU_SB_G1_NC = 72, // Static ARM ((S + A) | T) - B(S)
R_ARM_ALU_SB_G1 = 73, // Static ARM ((S + A) | T) - B(S)
R_ARM_ALU_SB_G2 = 74, // Static ARM ((S + A) | T) - B(S)
R_ARM_LDR_SB_G0 = 75, // Static ARM S + A - B(S)
R_ARM_LDR_SB_G1 = 76, // Static ARM S + A - B(S)
R_ARM_LDR_SB_G2 = 77, // Static ARM S + A - B(S)
R_ARM_LDRS_SB_G0 = 78, // Static ARM S + A - B(S)
R_ARM_LDRS_SB_G1 = 79, // Static ARM S + A - B(S)
R_ARM_LDRS_SB_G2 = 80, // Static ARM S + A - B(S)
R_ARM_LDC_SB_G0 = 81, // Static ARM S + A - B(S)
R_ARM_LDC_SB_G1 = 82, // Static ARM S + A - B(S)
R_ARM_LDC_SB_G2 = 83, // Static ARM S + A - B(S)
R_ARM_MOVW_BREL_NC = 84, // Static ARM ((S + A) | T) - B(S)
R_ARM_MOVT_BREL = 85, // Static ARM S + A - B(S)
R_ARM_MOVW_BREL = 86, // Static ARM ((S + A) | T) - B(S)
R_ARM_THM_MOVW_BREL_NC = 87, // Static Thumb32 ((S + A) | T) - B(S)
R_ARM_THM_MOVT_BREL = 88, // Static Thumb32 S + A - B(S)
R_ARM_THM_MOVW_BREL = 89, // Static Thumb32 ((S + A) | T) - B(S)
R_ARM_TLS_GOTDESC = 90, // Static Data
R_ARM_TLS_CALL = 91, // Static ARM
R_ARM_TLS_DESCSEQ = 92, // Static ARM TLS relaxation
R_ARM_THM_TLS_CALL = 93, // Static Thumb32
R_ARM_PLT32_ABS = 94, // Static Data PLT(S) + A
R_ARM_GOT_ABS = 95, // Static Data GOT(S) + A
R_ARM_GOT_PREL = 96, // Static Data GOT(S) + A - P
R_ARM_GOT_BREL12 = 97, // Static ARM GOT(S) + A - GOT_ORG
R_ARM_GOTOFF12 = 98, // Static ARM S + A - GOT_ROG
R_ARM_GOTRELAX = 99, // Static Misc
R_ARM_GNU_VTENTRY = 100, // Deprecated Data
R_ARM_GNU_VTINHERIT = 101, // Deprecated Data
R_ARM_THM_JUMP11 = 102, // Static Thumb16 S + A - P
R_ARM_THM_JUMP8 = 103, // Static Thumb16 S + A - P
R_ARM_TLS_GD32 = 104, // Static Data GOT(S) + A - P
R_ARM_TLS_LDM32 = 105, // Static Data GOT(S) + A - P
R_ARM_TLS_LDO32 = 106, // Static Data S + A - TLS
R_ARM_TLS_IE32 = 107, // Static Data GOT(S) + A - P
R_ARM_TLS_LE32 = 108, // Static Data S + A - tp
R_ARM_TLS_LDO12 = 109, // Static ARM S + A - TLS
R_ARM_TLS_LE12 = 110, // Static ARM S + A - tp
R_ARM_TLS_IE12GP = 111, // Static ARM GOT(S) + A - GOT_ORG
R_ARM_PRIVATE_0 = 112, // Private (n = 0, 1, ... 15)
R_ARM_PRIVATE_1 = 113,
R_ARM_PRIVATE_2 = 114,
R_ARM_PRIVATE_3 = 115,
R_ARM_PRIVATE_4 = 116,
R_ARM_PRIVATE_5 = 117,
R_ARM_PRIVATE_6 = 118,
R_ARM_PRIVATE_7 = 119,
R_ARM_PRIVATE_8 = 120,
R_ARM_PRIVATE_9 = 121,
R_ARM_PRIVATE_10 = 122,
R_ARM_PRIVATE_11 = 123,
R_ARM_PRIVATE_12 = 124,
R_ARM_PRIVATE_13 = 125,
R_ARM_PRIVATE_14 = 126,
R_ARM_PRIVATE_15 = 127,
R_ARM_ME_TOO = 128, // Obsolete
R_ARM_THM_TLS_DESCSEQ16 = 129,// Static Thumb16
R_ARM_THM_TLS_DESCSEQ32 = 130,// Static Thumb32
// 131 - 139 Unallocated
// 140 - 159 Dynamic Reserved for future allocation
R_ARM_IRELATIVE = 160, // Dynamic
// 161 - 255 Unallocated
};
// e_flags values used for ARM. We only support flags defined in AAELF.
enum
{
EF_ARM_BE8 = 0x00800000,
// Mask to extract EABI version, not really a flag value.
EF_ARM_EABIMASK = 0xFF000000,
EF_ARM_EABI_UNKNOWN = 0x00000000,
EF_ARM_EABI_VER1 = 0x01000000,
EF_ARM_EABI_VER2 = 0x02000000,
EF_ARM_EABI_VER3 = 0x03000000,
EF_ARM_EABI_VER4 = 0x04000000,
EF_ARM_EABI_VER5 = 0x05000000,
};
// Extract EABI version from flags.
inline Elf_Word
arm_eabi_version(Elf_Word flags)
{ return flags & EF_ARM_EABIMASK; }
// EABI_VER5 e_flags values for identifying soft- and hard-float ABI
// choice.
enum
{
EF_ARM_ABI_FLOAT_SOFT = 0x200,
EF_ARM_ABI_FLOAT_HARD = 0x400,
};
// Values for the Tag_CPU_arch EABI attribute.
enum
{
TAG_CPU_ARCH_PRE_V4,
TAG_CPU_ARCH_V4,
TAG_CPU_ARCH_V4T,
TAG_CPU_ARCH_V5T,
TAG_CPU_ARCH_V5TE,
TAG_CPU_ARCH_V5TEJ,
TAG_CPU_ARCH_V6,
TAG_CPU_ARCH_V6KZ,
TAG_CPU_ARCH_V6T2,
TAG_CPU_ARCH_V6K,
TAG_CPU_ARCH_V7,
TAG_CPU_ARCH_V6_M,
TAG_CPU_ARCH_V6S_M,
TAG_CPU_ARCH_V7E_M,
TAG_CPU_ARCH_V8,
MAX_TAG_CPU_ARCH = TAG_CPU_ARCH_V8,
// Pseudo-architecture to allow objects to be compatible with the subset of
// armv4t and armv6-m. This value should never be stored in object files.
TAG_CPU_ARCH_V4T_PLUS_V6_M = (MAX_TAG_CPU_ARCH + 1)
};
// EABI object attributes.
enum
{
// 0-3 are generic.
Tag_CPU_raw_name = 4,
Tag_CPU_name = 5,
Tag_CPU_arch = 6,
Tag_CPU_arch_profile = 7,
Tag_ARM_ISA_use = 8,
Tag_THUMB_ISA_use = 9,
Tag_FP_arch = 10,
Tag_WMMX_arch = 11,
Tag_Advanced_SIMD_arch = 12,
Tag_PCS_config = 13,
Tag_ABI_PCS_R9_use = 14,
Tag_ABI_PCS_RW_data = 15,
Tag_ABI_PCS_RO_data = 16,
Tag_ABI_PCS_GOT_use = 17,
Tag_ABI_PCS_wchar_t = 18,
Tag_ABI_FP_rounding = 19,
Tag_ABI_FP_denormal = 20,
Tag_ABI_FP_exceptions = 21,
Tag_ABI_FP_user_exceptions = 22,
Tag_ABI_FP_number_model = 23,
Tag_ABI_align_needed = 24,
Tag_ABI_align_preserved = 25,
Tag_ABI_enum_size = 26,
Tag_ABI_HardFP_use = 27,
Tag_ABI_VFP_args = 28,
Tag_ABI_WMMX_args = 29,
Tag_ABI_optimization_goals = 30,
Tag_ABI_FP_optimization_goals = 31,
// 32 is generic (Tag_compatibility).
Tag_undefined33 = 33,
Tag_CPU_unaligned_access = 34,
Tag_undefined35 = 35,
Tag_FP_HP_extension = 36,
Tag_undefined37 = 37,
Tag_ABI_FP_16bit_format = 38,
Tag_undefined39 = 39,
Tag_undefined40 = 40,
Tag_undefined41 = 41,
Tag_MPextension_use = 42,
Tag_undefined43 = 43,
Tag_DIV_use = 44,
Tag_nodefaults = 64,
Tag_also_compatible_with = 65,
Tag_T2EE_use = 66,
Tag_conformance = 67,
Tag_Virtualization_use = 68,
Tag_undefined69 = 69,
Tag_MPextension_use_legacy = 70,
// The following tags are legacy names for other tags.
Tag_VFP_arch = Tag_FP_arch,
Tag_ABI_align8_needed = Tag_ABI_align_needed,
Tag_ABI_align8_preserved = Tag_ABI_align_preserved,
Tag_VFP_HP_extension = Tag_FP_HP_extension
};
// Values for Tag_ABI_PCS_R9_use.
enum
{
AEABI_R9_V6 = 0,
AEABI_R9_SB = 1,
AEABI_R9_TLS = 2,
AEABI_R9_unused = 3
};
// Values for Tag_ABI_PCS_RW_data.
enum
{
AEABI_PCS_RW_data_absolute = 0,
AEABI_PCS_RW_data_PCrel = 1,
AEABI_PCS_RW_data_SBrel = 2,
AEABI_PCS_RW_data_unused = 3
};
// Values for Tag_ABI_enum_size.
enum
{
AEABI_enum_unused = 0,
AEABI_enum_short = 1,
AEABI_enum_wide = 2,
AEABI_enum_forced_wide = 3
};
// Values for Tag_ABI_FP_number_model.
enum
{
AEABI_FP_number_model_none = 0,
AEABI_FP_number_model_ieee754_number = 1,
AEABI_FP_number_model_rtabi = 2,
AEABI_FP_number_model_ieee754_all = 3
};
// Values for Tag_ABI_VFP_args.
enum
{
AEABI_VFP_args_base = 0,
AEABI_VFP_args_vfp = 1,
AEABI_VFP_args_toolchain = 2,
AEABI_VFP_args_compatible = 3
};
// For Exception Index Table. (Exception handling ABI for the ARM
// architectue, Section 5)
enum
{
EXIDX_CANTUNWIND = 1,
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_ARM_H)

View file

@ -0,0 +1,266 @@
// dwarf.h -- DWARF2 constants -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_DWARF_H
#define ELFCPP_DWARF_H
namespace elfcpp
{
// DWARF2 codes.
// Include DW_TAG, DW_FORM, DW_AT, DW_OP, DW_ATE, and DW_CFA
// codes from dwarf2.def.
#define DW_FIRST_TAG(name, value) enum DW_TAG { \
name = value
#define DW_TAG(name, value) , name = value
#define DW_TAG_DUP(name, value) , name = value
#define DW_END_TAG };
#define DW_FIRST_FORM(name, value) enum DW_FORM { \
name = value
#define DW_FORM(name, value) , name = value
#define DW_END_FORM };
#define DW_FIRST_AT(name, value) enum DW_AT { \
name = value
#define DW_AT(name, value) , name = value
#define DW_AT_DUP(name, value) , name = value
#define DW_END_AT };
#define DW_FIRST_OP(name, value) enum DW_OP { \
name = value
#define DW_OP(name, value) , name = value
#define DW_OP_DUP(name, value) , name = value
#define DW_END_OP };
#define DW_FIRST_ATE(name, value) enum DW_ENCODING { \
name = value
#define DW_ATE(name, value) , name = value
#define DW_ATE_DUP(name, value) , name = value
#define DW_END_ATE };
#define DW_FIRST_CFA(name, value) enum DW_CFA { \
name = value
#define DW_CFA(name, value) , name = value
#define DW_END_CFA };
#include "dwarf2.def"
#undef DW_FIRST_TAG
#undef DW_TAG
#undef DW_TAG_DUP
#undef DW_END_TAG
#undef DW_FIRST_FORM
#undef DW_FORM
#undef DW_END_FORM
#undef DW_FIRST_AT
#undef DW_AT
#undef DW_AT_DUP
#undef DW_END_AT
#undef DW_FIRST_OP
#undef DW_OP
#undef DW_OP_DUP
#undef DW_END_OP
#undef DW_FIRST_ATE
#undef DW_ATE
#undef DW_ATE_DUP
#undef DW_END_ATE
#undef DW_FIRST_CFA
#undef DW_CFA
#undef DW_END_CFA
// Frame unwind information.
enum DW_EH_PE
{
DW_EH_PE_absptr = 0x00,
DW_EH_PE_omit = 0xff,
DW_EH_PE_uleb128 = 0x01,
DW_EH_PE_udata2 = 0x02,
DW_EH_PE_udata4 = 0x03,
DW_EH_PE_udata8 = 0x04,
DW_EH_PE_signed = 0x08,
DW_EH_PE_sleb128 = 0x09,
DW_EH_PE_sdata2 = 0x0a,
DW_EH_PE_sdata4 = 0x0b,
DW_EH_PE_sdata8 = 0x0c,
DW_EH_PE_pcrel = 0x10,
DW_EH_PE_textrel = 0x20,
DW_EH_PE_datarel = 0x30,
DW_EH_PE_funcrel = 0x40,
DW_EH_PE_aligned = 0x50,
DW_EH_PE_indirect = 0x80
};
// Line number opcodes.
enum DW_LINE_OPS
{
DW_LNS_extended_op = 0,
DW_LNS_copy = 1,
DW_LNS_advance_pc = 2,
DW_LNS_advance_line = 3,
DW_LNS_set_file = 4,
DW_LNS_set_column = 5,
DW_LNS_negate_stmt = 6,
DW_LNS_set_basic_block = 7,
DW_LNS_const_add_pc = 8,
DW_LNS_fixed_advance_pc = 9,
// DWARF 3.
DW_LNS_set_prologue_end = 10,
DW_LNS_set_epilogue_begin = 11,
DW_LNS_set_isa = 12,
/* Experimental DWARF 5 extensions.
See http://wiki.dwarfstd.org/index.php?title=TwoLevelLineTables. */
DW_LNS_set_address_from_logical = 13, /* Actuals table only. */
DW_LNS_set_subprogram = 13, /* Logicals table only. */
DW_LNS_inlined_call = 14, /* Logicals table only. */
DW_LNS_pop_context = 15 /* Logicals table only. */
};
// Line number extended opcodes.
enum DW_LINE_EXTENDED_OPS
{
DW_LNE_end_sequence = 1,
DW_LNE_set_address = 2,
DW_LNE_define_file = 3,
// DWARF4.
DW_LNE_set_discriminator = 4,
// HP extensions.
DW_LNE_HP_negate_is_UV_update = 0x11,
DW_LNE_HP_push_context = 0x12,
DW_LNE_HP_pop_context = 0x13,
DW_LNE_HP_set_file_line_column = 0x14,
DW_LNE_HP_set_routine_name = 0x15,
DW_LNE_HP_set_sequence = 0x16,
DW_LNE_HP_negate_post_semantics = 0x17,
DW_LNE_HP_negate_function_exit = 0x18,
DW_LNE_HP_negate_front_end_logical = 0x19,
DW_LNE_HP_define_proc = 0x20
};
enum DW_CHILDREN
{
DW_CHILDREN_no =0x00,
DW_CHILDREN_yes =0x01
};
// Source language names and codes.
enum DW_LANG
{
DW_LANG_C89 = 0x0001,
DW_LANG_C = 0x0002,
DW_LANG_Ada83 = 0x0003,
DW_LANG_C_plus_plus = 0x0004,
DW_LANG_Cobol74 = 0x0005,
DW_LANG_Cobol85 = 0x0006,
DW_LANG_Fortran77 = 0x0007,
DW_LANG_Fortran90 = 0x0008,
DW_LANG_Pascal83 = 0x0009,
DW_LANG_Modula2 = 0x000a,
// DWARF 3.
DW_LANG_Java = 0x000b,
DW_LANG_C99 = 0x000c,
DW_LANG_Ada95 = 0x000d,
DW_LANG_Fortran95 = 0x000e,
DW_LANG_PLI = 0x000f,
DW_LANG_ObjC = 0x0010,
DW_LANG_ObjC_plus_plus = 0x0011,
DW_LANG_UPC = 0x0012,
DW_LANG_D = 0x0013,
// DWARF 4.
DW_LANG_Python = 0x0014,
// DWARF 5.
DW_LANG_Go = 0x0016,
DW_LANG_C_plus_plus_11 = 0x001a,
DW_LANG_C11 = 0x001d,
DW_LANG_C_plus_plus_14 = 0x0021,
DW_LANG_Fortran03 = 0x0022,
DW_LANG_Fortran08 = 0x0023,
DW_LANG_lo_user = 0x8000, // Implementation-defined range start.
DW_LANG_hi_user = 0xffff, // Implementation-defined range start.
// MIPS.
DW_LANG_Mips_Assembler = 0x8001,
// UPC.
DW_LANG_Upc = 0x8765,
// HP extensions.
DW_LANG_HP_Bliss = 0x8003,
DW_LANG_HP_Basic91 = 0x8004,
DW_LANG_HP_Pascal91 = 0x8005,
DW_LANG_HP_IMacro = 0x8006,
DW_LANG_HP_Assembler = 0x8007
};
// DWARF section identifiers used in the package format.
// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFissionDWP.
enum DW_SECT
{
DW_SECT_INFO = 1,
DW_SECT_TYPES = 2,
DW_SECT_ABBREV = 3,
DW_SECT_LINE = 4,
DW_SECT_LOC = 5,
DW_SECT_STR_OFFSETS = 6,
DW_SECT_MACINFO = 7,
DW_SECT_MACRO = 8,
DW_SECT_MAX = DW_SECT_MACRO,
};
enum DW_LNCT
{
DW_LNCT_path = 1,
DW_LNCT_directory_index = 2,
DW_LNCT_timestamp = 3,
DW_LNCT_size = 4,
DW_LNCT_MD5 = 5,
/* Experimental DWARF 5 extensions.
See http://wiki.dwarfstd.org/index.php?title=TwoLevelLineTables. */
DW_LNCT_subprogram_name = 6,
DW_LNCT_decl_file = 7,
DW_LNCT_decl_line = 8
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_DWARF_H)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,718 @@
// elfcpp_file.h -- file access for elfcpp -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
// This header file defines the class Elf_file which can be used to
// read useful data from an ELF file. The functions here are all
// templates which take a file interface object as a parameter. This
// type must have a subtype View. This type must support two methods:
// View view(off_t file_offset, off_t data_size)
// returns a View for the specified part of the file.
// void error(const char* printf_format, ...)
// prints an error message and does not return. The subtype View must
// support a method
// const unsigned char* data()
// which returns a pointer to a buffer containing the requested data.
// This general interface is used to read data from the file. Objects
// of type View will never survive longer than the elfcpp function.
// Some of these functions must return a reference to part of the
// file. To use these, the file interface must support a subtype
// Location:
// Location(off_t file_offset, off_t data_size)
// To use this in conjunction with the accessors types Shdr, etc., the
// file interface should support an overload of view:
// View view(Location)
// This permits writing
// elfcpp::Shdr shdr(file, ef.section_header(n));
#ifndef ELFCPP_FILE_H
#define ELFCPP_FILE_H
#include <string>
#include <cstdio>
#include <cstring>
#include "elfcpp.h"
namespace elfcpp
{
// A simple helper class to recognize if a file has an ELF header.
class Elf_recognizer
{
public:
// Maximum header size. The user should try to read this much of
// the file when using this class.
static const int max_header_size = Elf_sizes<64>::ehdr_size;
// Checks if the file contains the ELF magic. Other header fields
// are not checked.
static bool
is_elf_file(const unsigned char* ehdr_buf, int size);
// Check if EHDR_BUF/BUFSIZE is a valid header of a 32-bit or
// 64-bit, little-endian or big-endian ELF file. Assumes
// is_elf_file() has been checked to be true. If the header is not
// valid, *ERROR contains a human-readable error message. If is is,
// *SIZE is set to either 32 or 64, *BIG_ENDIAN is set to indicate
// whether the file is big-endian.
static bool
is_valid_header(const unsigned char* ehdr_buf, off_t bufsize,
int* size, bool* big_endian,
std::string* error);
};
// This object is used to read an ELF file.
// SIZE: The size of file, 32 or 64.
// BIG_ENDIAN: Whether the file is in big-endian format.
// FILE: A file reading type as described above.
template<int size, bool big_endian, typename File>
class Elf_file
{
private:
typedef Elf_file<size, big_endian, File> This;
public:
static const int ehdr_size = Elf_sizes<size>::ehdr_size;
static const int phdr_size = Elf_sizes<size>::phdr_size;
static const int shdr_size = Elf_sizes<size>::shdr_size;
static const int sym_size = Elf_sizes<size>::sym_size;
static const int rel_size = Elf_sizes<size>::rel_size;
static const int rela_size = Elf_sizes<size>::rela_size;
typedef Ehdr<size, big_endian> Ef_ehdr;
typedef Phdr<size, big_endian> Ef_phdr;
typedef Shdr<size, big_endian> Ef_shdr;
typedef Sym<size, big_endian> Ef_sym;
// Construct an Elf_file given an ELF file header.
Elf_file(File* file, const Ef_ehdr& ehdr)
{ this->construct(file, ehdr); }
// Construct an ELF file.
inline
Elf_file(File* file);
// Return the file offset to the section headers.
off_t
shoff() const
{ return this->shoff_; }
// Find the first section with an sh_type field equal to TYPE and
// return its index. Returns SHN_UNDEF if there is no such section.
unsigned int
find_section_by_type(unsigned int type);
// Return the number of sections.
unsigned int
shnum()
{
this->initialize_shnum();
return this->shnum_;
}
unsigned int
shnum() const
{
if (this->shnum_ == 0 && this->shoff_ != 0)
this->file_->error(_("ELF file has not been initialized yet"
" (internal error)"));
return this->shnum_;
}
// Return the section index of the section name string table.
unsigned int
shstrndx()
{
this->initialize_shnum();
return this->shstrndx_;
}
unsigned int
shstrndx() const
{
if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0)
{
this->file_->error(_("ELF file has not been initialized yet"
" (internal error)"));
return 0;
}
return this->shstrndx_;
}
// Return the value to subtract from section indexes >=
// SHN_LORESERVE. See the comment in initialize_shnum.
int
large_shndx_offset()
{
this->initialize_shnum();
return this->large_shndx_offset_;
}
int
large_shndx_offset() const
{
if (this->shstrndx_ == SHN_XINDEX && this->shoff_ != 0)
this->file_->error(_("ELF file has not been initialized yet"
" (internal error)"));
return this->large_shndx_offset_;
}
// Return the location of the header of section SHNDX.
typename File::Location
section_header(unsigned int shndx)
{
return typename File::Location(this->section_header_offset(shndx),
shdr_size);
}
// Return the name of section SHNDX.
std::string
section_name(unsigned int shndx) const;
// Return the location of the contents of section SHNDX.
typename File::Location
section_contents(unsigned int shndx);
// Return the size of section SHNDX.
typename Elf_types<size>::Elf_WXword
section_size(unsigned int shndx);
// Return the flags of section SHNDX.
typename Elf_types<size>::Elf_WXword
section_flags(unsigned int shndx);
// Return the address of section SHNDX.
typename Elf_types<size>::Elf_Addr
section_addr(unsigned int shndx);
// Return the type of section SHNDX.
Elf_Word
section_type(unsigned int shndx);
// Return the link field of section SHNDX.
Elf_Word
section_link(unsigned int shndx);
// Return the info field of section SHNDX.
Elf_Word
section_info(unsigned int shndx);
// Return the addralign field of section SHNDX.
typename Elf_types<size>::Elf_WXword
section_addralign(unsigned int shndx);
private:
// Shared constructor code.
void
construct(File* file, const Ef_ehdr& ehdr);
// Initialize shnum_ and shstrndx_.
void
initialize_shnum();
// Return the file offset of the header of section SHNDX.
off_t
section_header_offset(unsigned int shndx) const;
// The file we are reading.
File* file_;
// The file offset to the section headers.
off_t shoff_;
// The number of sections.
unsigned int shnum_;
// The section index of the section name string table.
unsigned int shstrndx_;
// Offset to add to sections larger than SHN_LORESERVE.
int large_shndx_offset_;
};
// A small wrapper around SHT_STRTAB data mapped to memory. It checks that the
// index is not out of bounds and the string is NULL-terminated.
class Elf_strtab
{
public:
// Construct an Elf_strtab for a section with contents *P and size SIZE.
Elf_strtab(const unsigned char* p, size_t size);
// Return the file offset to the section headers.
bool
get_c_string(size_t offset, const char** cstring) const
{
if (offset >= this->usable_size_)
return false;
*cstring = this->base_ + offset;
return true;
}
private:
// Contents of the section mapped to memory.
const char* base_;
// One larger that the position of the last NULL character in the section.
// For valid SHT_STRTAB sections, this is the size of the section.
size_t usable_size_;
};
// Inline function definitions.
// Check for presence of the ELF magic number.
inline bool
Elf_recognizer::is_elf_file(const unsigned char* ehdr_buf, int size)
{
if (size < 4)
return false;
static unsigned char elfmagic[4] =
{
elfcpp::ELFMAG0, elfcpp::ELFMAG1,
elfcpp::ELFMAG2, elfcpp::ELFMAG3
};
return memcmp(ehdr_buf, elfmagic, 4) == 0;
}
namespace
{
// Print a number to a string.
inline std::string
internal_printf_int(const char* format, int arg)
{
char buf[256];
snprintf(buf, sizeof(buf), format, arg);
return std::string(buf);
}
} // End anonymous namespace.
// Check the validity of the ELF header.
inline bool
Elf_recognizer::is_valid_header(
const unsigned char* ehdr_buf,
off_t bufsize,
int* size,
bool* big_endian,
std::string* error)
{
if (bufsize < elfcpp::EI_NIDENT)
{
*error = _("ELF file too short");
return false;
}
int v = ehdr_buf[elfcpp::EI_VERSION];
if (v != elfcpp::EV_CURRENT)
{
if (v == elfcpp::EV_NONE)
*error = _("invalid ELF version 0");
else
*error = internal_printf_int(_("unsupported ELF version %d"), v);
return false;
}
int c = ehdr_buf[elfcpp::EI_CLASS];
if (c == elfcpp::ELFCLASSNONE)
{
*error = _("invalid ELF class 0");
return false;
}
else if (c != elfcpp::ELFCLASS32
&& c != elfcpp::ELFCLASS64)
{
*error = internal_printf_int(_("unsupported ELF class %d"), c);
return false;
}
int d = ehdr_buf[elfcpp::EI_DATA];
if (d == elfcpp::ELFDATANONE)
{
*error = _("invalid ELF data encoding");
return false;
}
else if (d != elfcpp::ELFDATA2LSB
&& d != elfcpp::ELFDATA2MSB)
{
*error = internal_printf_int(_("unsupported ELF data encoding %d"), d);
return false;
}
*big_endian = (d == elfcpp::ELFDATA2MSB);
if (c == elfcpp::ELFCLASS32)
{
if (bufsize < elfcpp::Elf_sizes<32>::ehdr_size)
{
*error = _("ELF file too short");
return false;
}
*size = 32;
}
else
{
if (bufsize < elfcpp::Elf_sizes<64>::ehdr_size)
{
*error = _("ELF file too short");
return false;
}
*size = 64;
}
return true;
}
// Template function definitions.
// Construct an Elf_file given an ELF file header.
template<int size, bool big_endian, typename File>
void
Elf_file<size, big_endian, File>::construct(File* file, const Ef_ehdr& ehdr)
{
this->file_ = file;
this->shoff_ = ehdr.get_e_shoff();
this->shnum_ = ehdr.get_e_shnum();
this->shstrndx_ = ehdr.get_e_shstrndx();
this->large_shndx_offset_ = 0;
if (ehdr.get_e_ehsize() != This::ehdr_size)
file->error(_("bad e_ehsize (%d != %d)"),
ehdr.get_e_ehsize(), This::ehdr_size);
if (ehdr.get_e_shentsize() != This::shdr_size)
file->error(_("bad e_shentsize (%d != %d)"),
ehdr.get_e_shentsize(), This::shdr_size);
}
// Construct an ELF file.
template<int size, bool big_endian, typename File>
inline
Elf_file<size, big_endian, File>::Elf_file(File* file)
{
typename File::View v(file->view(file_header_offset, This::ehdr_size));
this->construct(file, Ef_ehdr(v.data()));
}
// Initialize the shnum_ and shstrndx_ fields, handling overflow.
template<int size, bool big_endian, typename File>
void
Elf_file<size, big_endian, File>::initialize_shnum()
{
if ((this->shnum_ == 0 || this->shstrndx_ == SHN_XINDEX)
&& this->shoff_ != 0)
{
typename File::View v(this->file_->view(this->shoff_, This::shdr_size));
Ef_shdr shdr(v.data());
if (this->shnum_ == 0)
this->shnum_ = shdr.get_sh_size();
if (this->shstrndx_ == SHN_XINDEX)
{
this->shstrndx_ = shdr.get_sh_link();
// Versions of the GNU binutils between 2.12 and 2.18 did
// not handle objects with more than SHN_LORESERVE sections
// correctly. All large section indexes were offset by
// 0x100. Some information can be found here:
// http://sourceware.org/bugzilla/show_bug.cgi?id=5900 .
// Fortunately these object files are easy to detect, as the
// GNU binutils always put the section header string table
// near the end of the list of sections. Thus if the
// section header string table index is larger than the
// number of sections, then we know we have to subtract
// 0x100 to get the real section index.
if (this->shstrndx_ >= this->shnum_)
{
if (this->shstrndx_ >= elfcpp::SHN_LORESERVE + 0x100)
{
this->large_shndx_offset_ = - 0x100;
this->shstrndx_ -= 0x100;
}
if (this->shstrndx_ >= this->shnum_)
this->file_->error(_("bad shstrndx: %u >= %u"),
this->shstrndx_, this->shnum_);
}
}
}
}
// Find section with sh_type equal to TYPE and return its index.
// Returns SHN_UNDEF if not found.
template<int size, bool big_endian, typename File>
unsigned int
Elf_file<size, big_endian, File>::find_section_by_type(unsigned int type)
{
unsigned int shnum = this->shnum();
typename File::View v(this->file_->view(this->shoff_,
This::shdr_size * shnum));
for (unsigned int i = 0; i < shnum; i++)
{
Ef_shdr shdr(v.data() + This::shdr_size * i);
if (shdr.get_sh_type() == type)
return i;
}
return SHN_UNDEF;
}
// Return the file offset of the section header of section SHNDX.
template<int size, bool big_endian, typename File>
off_t
Elf_file<size, big_endian, File>::section_header_offset(unsigned int shndx) const
{
if (shndx >= this->shnum())
this->file_->error(_("section_header_offset: bad shndx %u >= %u"),
shndx, this->shnum());
return this->shoff_ + This::shdr_size * shndx;
}
// Return the name of section SHNDX.
template<int size, bool big_endian, typename File>
std::string
Elf_file<size, big_endian, File>::section_name(unsigned int shndx) const
{
File* const file = this->file_;
// Get the section name offset.
unsigned int sh_name;
{
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
sh_name = shdr.get_sh_name();
}
// Get the file offset for the section name string table data.
off_t shstr_off;
typename Elf_types<size>::Elf_WXword shstr_size;
{
const unsigned int shstrndx = this->shstrndx_;
typename File::View v(file->view(this->section_header_offset(shstrndx),
This::shdr_size));
Ef_shdr shstr_shdr(v.data());
shstr_off = shstr_shdr.get_sh_offset();
shstr_size = shstr_shdr.get_sh_size();
}
if (sh_name >= shstr_size)
file->error(_("bad section name offset for section %u: %u"),
shndx, sh_name);
typename File::View v(file->view(shstr_off, shstr_size));
const unsigned char* datau = v.data();
const char* data = reinterpret_cast<const char*>(datau);
const void* p = ::memchr(data + sh_name, '\0', shstr_size - sh_name);
if (p == NULL)
file->error(_("missing null terminator for name of section %u"),
shndx);
size_t len = static_cast<const char*>(p) - (data + sh_name);
return std::string(data + sh_name, len);
}
// Return the contents of section SHNDX.
template<int size, bool big_endian, typename File>
typename File::Location
Elf_file<size, big_endian, File>::section_contents(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_contents: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return typename File::Location(shdr.get_sh_offset(), shdr.get_sh_size());
}
// Get the size of section SHNDX.
template<int size, bool big_endian, typename File>
typename Elf_types<size>::Elf_WXword
Elf_file<size, big_endian, File>::section_size(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_size: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_size();
}
// Return the section flags of section SHNDX.
template<int size, bool big_endian, typename File>
typename Elf_types<size>::Elf_WXword
Elf_file<size, big_endian, File>::section_flags(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_flags: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_flags();
}
// Return the address of section SHNDX.
template<int size, bool big_endian, typename File>
typename Elf_types<size>::Elf_Addr
Elf_file<size, big_endian, File>::section_addr(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_flags: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_addr();
}
// Return the type of section SHNDX.
template<int size, bool big_endian, typename File>
Elf_Word
Elf_file<size, big_endian, File>::section_type(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_type: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_type();
}
// Return the sh_link field of section SHNDX.
template<int size, bool big_endian, typename File>
Elf_Word
Elf_file<size, big_endian, File>::section_link(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_link: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_link();
}
// Return the sh_info field of section SHNDX.
template<int size, bool big_endian, typename File>
Elf_Word
Elf_file<size, big_endian, File>::section_info(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_info: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_info();
}
// Return the sh_addralign field of section SHNDX.
template<int size, bool big_endian, typename File>
typename Elf_types<size>::Elf_WXword
Elf_file<size, big_endian, File>::section_addralign(unsigned int shndx)
{
File* const file = this->file_;
if (shndx >= this->shnum())
file->error(_("section_addralign: bad shndx %u >= %u"),
shndx, this->shnum());
typename File::View v(file->view(this->section_header_offset(shndx),
This::shdr_size));
Ef_shdr shdr(v.data());
return shdr.get_sh_addralign();
}
inline
Elf_strtab::Elf_strtab(const unsigned char* p, size_t size)
{
// Check if the section is NUL-terminated. If it isn't, we ignore
// the last part to make sure we don't return non-NUL-terminated
// strings.
while (size > 0 && p[size - 1] != 0)
size--;
this->base_ = reinterpret_cast<const char*>(p);
this->usable_size_ = size;
}
} // End namespace elfcpp.
#endif // !defined(ELFCPP_FILE_H)

View file

@ -0,0 +1,240 @@
// elfcpp_internal.h -- internals for elfcpp -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
// This is included by elfcpp.h, the external interface, but holds
// information which we want to keep private.
#ifndef ELFCPP_INTERNAL_H
#define ELFCPP_INTERNAL_H
namespace elfcpp
{
namespace internal
{
// The ELF file header.
template<int size>
struct Ehdr_data
{
unsigned char e_ident[EI_NIDENT];
Elf_Half e_type;
Elf_Half e_machine;
Elf_Word e_version;
typename Elf_types<size>::Elf_Addr e_entry;
typename Elf_types<size>::Elf_Off e_phoff;
typename Elf_types<size>::Elf_Off e_shoff;
Elf_Word e_flags;
Elf_Half e_ehsize;
Elf_Half e_phentsize;
Elf_Half e_phnum;
Elf_Half e_shentsize;
Elf_Half e_shnum;
Elf_Half e_shstrndx;
};
// An ELF section header.
template<int size>
struct Shdr_data
{
Elf_Word sh_name;
Elf_Word sh_type;
typename Elf_types<size>::Elf_WXword sh_flags;
typename Elf_types<size>::Elf_Addr sh_addr;
typename Elf_types<size>::Elf_Off sh_offset;
typename Elf_types<size>::Elf_WXword sh_size;
Elf_Word sh_link;
Elf_Word sh_info;
typename Elf_types<size>::Elf_WXword sh_addralign;
typename Elf_types<size>::Elf_WXword sh_entsize;
};
// An ELF segment header. We use template specialization for the
// 32-bit and 64-bit versions because the fields are in a different
// order.
template<int size>
struct Phdr_data;
template<>
struct Phdr_data<32>
{
Elf_Word p_type;
Elf_types<32>::Elf_Off p_offset;
Elf_types<32>::Elf_Addr p_vaddr;
Elf_types<32>::Elf_Addr p_paddr;
Elf_Word p_filesz;
Elf_Word p_memsz;
Elf_Word p_flags;
Elf_Word p_align;
};
template<>
struct Phdr_data<64>
{
Elf_Word p_type;
Elf_Word p_flags;
Elf_types<64>::Elf_Off p_offset;
Elf_types<64>::Elf_Addr p_vaddr;
Elf_types<64>::Elf_Addr p_paddr;
Elf_Xword p_filesz;
Elf_Xword p_memsz;
Elf_Xword p_align;
};
// An ELF symbol table entry. We use template specialization for the
// 32-bit and 64-bit versions because the fields are in a different
// order.
template<int size>
struct Sym_data;
template<>
struct Sym_data<32>
{
Elf_Word st_name;
Elf_types<32>::Elf_Addr st_value;
Elf_Word st_size;
unsigned char st_info;
unsigned char st_other;
Elf_Half st_shndx;
};
template<>
struct Sym_data<64>
{
Elf_Word st_name;
unsigned char st_info;
unsigned char st_other;
Elf_Half st_shndx;
Elf_types<64>::Elf_Addr st_value;
Elf_Xword st_size;
};
// ELF relocation table entries.
template<int size>
struct Rel_data
{
typename Elf_types<size>::Elf_Addr r_offset;
typename Elf_types<size>::Elf_WXword r_info;
};
template<int size>
struct Rela_data
{
typename Elf_types<size>::Elf_Addr r_offset;
typename Elf_types<size>::Elf_WXword r_info;
typename Elf_types<size>::Elf_Swxword r_addend;
};
// An entry in the ELF SHT_DYNAMIC section aka PT_DYNAMIC segment.
template<int size>
struct Dyn_data
{
typename Elf_types<size>::Elf_Swxword d_tag;
typename Elf_types<size>::Elf_WXword d_val;
};
// An entry in a SHT_GNU_verdef section. This structure is the same
// in 32-bit and 64-bit ELF files.
struct Verdef_data
{
// Version number of structure (VER_DEF_*).
Elf_Half vd_version;
// Bit flags (VER_FLG_*).
Elf_Half vd_flags;
// Version index.
Elf_Half vd_ndx;
// Number of auxiliary Verdaux entries.
Elf_Half vd_cnt;
// Hash of name.
Elf_Word vd_hash;
// Byte offset to first Verdaux entry.
Elf_Word vd_aux;
// Byte offset to next Verdef entry.
Elf_Word vd_next;
};
// An auxiliary entry in a SHT_GNU_verdef section. This structure is
// the same in 32-bit and 64-bit ELF files.
struct Verdaux_data
{
// Offset in string table of version name.
Elf_Word vda_name;
// Byte offset to next Verdaux entry.
Elf_Word vda_next;
};
// An entry in a SHT_GNU_verneed section. This structure is the same
// in 32-bit and 64-bit ELF files.
struct Verneed_data
{
// Version number of structure (VER_NEED_*).
Elf_Half vn_version;
// Number of auxiliary Vernaux entries.
Elf_Half vn_cnt;
// Offset in string table of library name.
Elf_Word vn_file;
// Byte offset to first Vernaux entry.
Elf_Word vn_aux;
// Byt eoffset to next Verneed entry.
Elf_Word vn_next;
};
// An auxiliary entry in a SHT_GNU_verneed section. This structure is
// the same in 32-bit and 64-bit ELF files.
struct Vernaux_data
{
// Hash of dependency name.
Elf_Word vna_hash;
// Bit flags (VER_FLG_*).
Elf_Half vna_flags;
// Version index used in SHT_GNU_versym entries.
Elf_Half vna_other;
// Offset in string table of version name.
Elf_Word vna_name;
// Byte offset to next Vernaux entry.
Elf_Word vna_next;
};
} // End namespace internal.
} // End namespace elfcpp.
#endif // !defined(ELFCPP_INTERNAL_H)

View file

@ -0,0 +1,500 @@
// elfcpp_swap.h -- Handle swapping for elfcpp -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
// This header file defines basic template classes to efficiently swap
// numbers between host form and target form. When the host and
// target have the same endianness, these turn into no-ops.
#ifndef ELFCPP_SWAP_H
#define ELFCPP_SWAP_H
#include <stdint.h>
// We need an autoconf-generated config.h file for endianness and
// swapping. We check two macros: WORDS_BIGENDIAN and
// HAVE_BYTESWAP_H.
#include "config.h"
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#else
// Provide our own versions of the byteswap functions.
inline uint16_t
bswap_16(uint16_t v)
{
return ((v >> 8) & 0xff) | ((v & 0xff) << 8);
}
inline uint32_t
bswap_32(uint32_t v)
{
return ( ((v & 0xff000000) >> 24)
| ((v & 0x00ff0000) >> 8)
| ((v & 0x0000ff00) << 8)
| ((v & 0x000000ff) << 24));
}
inline uint64_t
bswap_64(uint64_t v)
{
return ( ((v & 0xff00000000000000ULL) >> 56)
| ((v & 0x00ff000000000000ULL) >> 40)
| ((v & 0x0000ff0000000000ULL) >> 24)
| ((v & 0x000000ff00000000ULL) >> 8)
| ((v & 0x00000000ff000000ULL) << 8)
| ((v & 0x0000000000ff0000ULL) << 24)
| ((v & 0x000000000000ff00ULL) << 40)
| ((v & 0x00000000000000ffULL) << 56));
}
#endif // !defined(HAVE_BYTESWAP_H)
// gcc 4.3 and later provides __builtin_bswap32 and __builtin_bswap64.
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#undef bswap_32
#define bswap_32 __builtin_bswap32
#undef bswap_64
#define bswap_64 __builtin_bswap64
#endif
namespace elfcpp
{
// Endian simply indicates whether the host is big endian or not.
struct Endian
{
public:
// Used for template specializations.
static const bool host_big_endian =
#ifdef WORDS_BIGENDIAN
true
#else
false
#endif
;
};
// Valtype_base is a template based on size (8, 16, 32, 64) which
// defines the type Valtype as the unsigned integer, and
// Signed_valtype as the signed integer, of the specified size.
template<int size>
struct Valtype_base;
template<>
struct Valtype_base<8>
{
typedef uint8_t Valtype;
typedef int8_t Signed_valtype;
};
template<>
struct Valtype_base<16>
{
typedef uint16_t Valtype;
typedef int16_t Signed_valtype;
};
template<>
struct Valtype_base<32>
{
typedef uint32_t Valtype;
typedef int32_t Signed_valtype;
};
template<>
struct Valtype_base<64>
{
typedef uint64_t Valtype;
typedef int64_t Signed_valtype;
};
// Convert_endian is a template based on size and on whether the host
// and target have the same endianness. It defines the type Valtype
// as Valtype_base does, and also defines a function convert_host
// which takes an argument of type Valtype and returns the same value,
// but swapped if the host and target have different endianness.
template<int size, bool same_endian>
struct Convert_endian;
template<int size>
struct Convert_endian<size, true>
{
typedef typename Valtype_base<size>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{ return v; }
};
template<>
struct Convert_endian<8, false>
{
typedef Valtype_base<8>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{ return v; }
};
template<>
struct Convert_endian<16, false>
{
typedef Valtype_base<16>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{ return bswap_16(v); }
};
template<>
struct Convert_endian<32, false>
{
typedef Valtype_base<32>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{ return bswap_32(v); }
};
template<>
struct Convert_endian<64, false>
{
typedef Valtype_base<64>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{ return bswap_64(v); }
};
// Convert is a template based on size and on whether the target is
// big endian. It defines Valtype and convert_host like
// Convert_endian. That is, it is just like Convert_endian except in
// the meaning of the second template parameter.
template<int size, bool big_endian>
struct Convert
{
typedef typename Valtype_base<size>::Valtype Valtype;
static inline Valtype
convert_host(Valtype v)
{
return Convert_endian<size, big_endian == Endian::host_big_endian>
::convert_host(v);
}
};
// Swap is a template based on size and on whether the target is big
// endian. It defines the type Valtype and the functions readval and
// writeval. The functions read and write values of the appropriate
// size out of buffers, swapping them if necessary. readval and
// writeval are overloaded to take pointers to the appropriate type or
// pointers to unsigned char.
template<int size, bool big_endian>
struct Swap
{
typedef typename Valtype_base<size>::Valtype Valtype;
static inline Valtype
readval(const Valtype* wv)
{ return Convert<size, big_endian>::convert_host(*wv); }
static inline void
writeval(Valtype* wv, Valtype v)
{ *wv = Convert<size, big_endian>::convert_host(v); }
static inline Valtype
readval(const unsigned char* wv)
{ return readval(reinterpret_cast<const Valtype*>(wv)); }
static inline void
writeval(unsigned char* wv, Valtype v)
{ writeval(reinterpret_cast<Valtype*>(wv), v); }
};
// We need to specialize the 8-bit version of Swap to avoid
// conflicting overloads, since both versions of readval and writeval
// will have the same type parameters.
template<bool big_endian>
struct Swap<8, big_endian>
{
typedef typename Valtype_base<8>::Valtype Valtype;
static inline Valtype
readval(const Valtype* wv)
{ return *wv; }
static inline void
writeval(Valtype* wv, Valtype v)
{ *wv = v; }
};
// Swap_unaligned is a template based on size and on whether the
// target is big endian. It defines the type Valtype and the
// functions readval and writeval. The functions read and write
// values of the appropriate size out of buffers which may be
// misaligned.
template<int size, bool big_endian>
struct Swap_unaligned;
template<bool big_endian>
struct Swap_unaligned<8, big_endian>
{
typedef typename Valtype_base<8>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{ return *wv; }
static inline void
writeval(unsigned char* wv, Valtype v)
{ *wv = v; }
};
template<>
struct Swap_unaligned<16, false>
{
typedef Valtype_base<16>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return (wv[1] << 8) | wv[0];
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[1] = v >> 8;
wv[0] = v;
}
};
template<>
struct Swap_unaligned<16, true>
{
typedef Valtype_base<16>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return (wv[0] << 8) | wv[1];
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[0] = v >> 8;
wv[1] = v;
}
};
template<>
struct Swap_unaligned<32, false>
{
typedef Valtype_base<32>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return (wv[3] << 24) | (wv[2] << 16) | (wv[1] << 8) | wv[0];
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[3] = v >> 24;
wv[2] = v >> 16;
wv[1] = v >> 8;
wv[0] = v;
}
};
template<>
struct Swap_unaligned<32, true>
{
typedef Valtype_base<32>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return (wv[0] << 24) | (wv[1] << 16) | (wv[2] << 8) | wv[3];
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[0] = v >> 24;
wv[1] = v >> 16;
wv[2] = v >> 8;
wv[3] = v;
}
};
template<>
struct Swap_unaligned<64, false>
{
typedef Valtype_base<64>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return ((static_cast<Valtype>(wv[7]) << 56)
| (static_cast<Valtype>(wv[6]) << 48)
| (static_cast<Valtype>(wv[5]) << 40)
| (static_cast<Valtype>(wv[4]) << 32)
| (static_cast<Valtype>(wv[3]) << 24)
| (static_cast<Valtype>(wv[2]) << 16)
| (static_cast<Valtype>(wv[1]) << 8)
| static_cast<Valtype>(wv[0]));
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[7] = v >> 56;
wv[6] = v >> 48;
wv[5] = v >> 40;
wv[4] = v >> 32;
wv[3] = v >> 24;
wv[2] = v >> 16;
wv[1] = v >> 8;
wv[0] = v;
}
};
template<>
struct Swap_unaligned<64, true>
{
typedef Valtype_base<64>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return ((static_cast<Valtype>(wv[0]) << 56)
| (static_cast<Valtype>(wv[1]) << 48)
| (static_cast<Valtype>(wv[2]) << 40)
| (static_cast<Valtype>(wv[3]) << 32)
| (static_cast<Valtype>(wv[4]) << 24)
| (static_cast<Valtype>(wv[5]) << 16)
| (static_cast<Valtype>(wv[6]) << 8)
| static_cast<Valtype>(wv[7]));
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
wv[0] = v >> 56;
wv[1] = v >> 48;
wv[2] = v >> 40;
wv[3] = v >> 32;
wv[4] = v >> 24;
wv[5] = v >> 16;
wv[6] = v >> 8;
wv[7] = v;
}
};
// Swap_aligned32 is a template based on size and on whether the
// target is big endian. It defines the type Valtype and the
// functions readval and writeval. The functions read and write
// values of the appropriate size out of buffers which may not be
// 64-bit aligned, but are 32-bit aligned.
template<int size, bool big_endian>
struct Swap_aligned32
{
typedef typename Valtype_base<size>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{ return Swap<size, big_endian>::readval(
reinterpret_cast<const Valtype*>(wv)); }
static inline void
writeval(unsigned char* wv, Valtype v)
{ Swap<size, big_endian>::writeval(reinterpret_cast<Valtype*>(wv), v); }
};
template<>
struct Swap_aligned32<64, true>
{
typedef Valtype_base<64>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return ((static_cast<Valtype>(Swap<32, true>::readval(wv)) << 32)
| static_cast<Valtype>(Swap<32, true>::readval(wv + 4)));
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
typedef Valtype_base<32>::Valtype Valtype32;
Swap<32, true>::writeval(wv, static_cast<Valtype32>(v >> 32));
Swap<32, true>::writeval(wv + 4, static_cast<Valtype32>(v));
}
};
template<>
struct Swap_aligned32<64, false>
{
typedef Valtype_base<64>::Valtype Valtype;
static inline Valtype
readval(const unsigned char* wv)
{
return ((static_cast<Valtype>(Swap<32, false>::readval(wv + 4)) << 32)
| static_cast<Valtype>(Swap<32, false>::readval(wv)));
}
static inline void
writeval(unsigned char* wv, Valtype v)
{
typedef Valtype_base<32>::Valtype Valtype32;
Swap<32, false>::writeval(wv + 4, static_cast<Valtype32>(v >> 32));
Swap<32, false>::writeval(wv, static_cast<Valtype32>(v));
}
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_SWAP_H)

View file

@ -0,0 +1,98 @@
// i386.h -- ELF definitions specific to EM_386 -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_I386_H
#define ELFCPP_I386_H
// Documentation for the TLS relocs is taken from
// http://people.redhat.com/drepper/tls.pdf
// http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt
namespace elfcpp
{
enum
{
R_386_NONE = 0, // No reloc
R_386_32 = 1, // Direct 32 bit zero extended
R_386_PC32 = 2, // PC relative 32 bit signed
R_386_GOT32 = 3, // 32 bit GOT entry
R_386_PLT32 = 4, // 32 bit PLT address
R_386_COPY = 5, // Copy symbol at runtime
R_386_GLOB_DAT = 6, // Create GOT entry
R_386_JUMP_SLOT = 7, // Create PLT entry
R_386_RELATIVE = 8, // Adjust by program base
R_386_GOTOFF = 9, // 32-bit GOT offset
R_386_GOTPC = 10, // 32-bit PC relative offset to GOT
// Used by Sun.
R_386_32PLT = 11,
// TLS extensions.
R_386_TLS_TPOFF = 14, // Outstanding Initial Exec reloc, gnu-style (both)
R_386_TLS_IE = 15, // Initial Initial Exec reloc, gnu-style (no-PIC)
R_386_TLS_GOTIE = 16, // Initial Initial Exec reloc, gnu-style (for PIC)
R_386_TLS_LE = 17, // Initial Local Exec reloc, gnu-style
R_386_TLS_GD = 18, // Initial General Dynamic reloc, gnu-style
R_386_TLS_LDM = 19, // Initial Local Dynamic reloc, gnu-style
// GNU extensions.
R_386_16 = 20, // Direct 16 bit zero extended
R_386_PC16 = 21, // 16 bit sign extended pc relative
R_386_8 = 22, // Direct 8 bit sign extended
R_386_PC8 = 23, // 8 bit sign extended pc relative
// More TLS relocs.
R_386_TLS_GD_32 = 24, // Initial General Dynamic reloc, sun-style
R_386_TLS_GD_PUSH = 25, // Initial General Dynamic reloc, sun-style
R_386_TLS_GD_CALL = 26, // Initial General Dynamic reloc, sun-style
R_386_TLS_GD_POP = 27, // Initial General Dynamic reloc, sun-style
R_386_TLS_LDM_32 = 28, // Initial Local Dynamic reloc, sun-style
R_386_TLS_LDM_PUSH = 29, // Initial Local Dynamic reloc, sun-style
R_386_TLS_LDM_CALL = 30, // Initial Local Dynamic reloc, sun-style
R_386_TLS_LDM_POP = 31, // Initial Local Dynamic reloc, sun-style
R_386_TLS_LDO_32 = 32, // Initial Local Dynamic reloc, sun+gnu styles
R_386_TLS_IE_32 = 33, // Initial Initial Exec reloc, sun-style
R_386_TLS_LE_32 = 34, // Initial Local Exec reloc, sun-style
R_386_TLS_DTPMOD32 = 35, // Outstanding General/Local Dynamic reloc, sun+gnu
R_386_TLS_DTPOFF32 = 36, // Outstanding General Dynamic reloc, sun+gnu
R_386_TLS_TPOFF32 = 37, // Outstanding Initial Exec reloc, sun-style
R_386_TLS_GOTDESC = 39, // GOT offset for TLS descriptor
R_386_TLS_DESC_CALL = 40, // Marker of call through TLS desc for relaxation
R_386_TLS_DESC = 41, // TLS descriptor containing pointer to code and
// to argument, returning TLS offset for symbol
R_386_IRELATIVE = 42, // Adjust indirectly by program base
// Used by Intel.
R_386_USED_BY_INTEL_200 = 200,
// GNU vtable garbage collection extensions.
R_386_GNU_VTINHERIT = 250,
R_386_GNU_VTENTRY = 251
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_I386_H)

View file

@ -0,0 +1,381 @@
// mips.h -- ELF definitions specific to EM_MIPS -*- C++ -*-
// Copyright (C) 2012-2014 Free Software Foundation, Inc.
// Written by Sasa Stankovic <sasa.stankovic@imgtec.com>
// and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_MIPS_H
#define ELFCPP_MIPS_H
// Documentation for the MIPS relocs is taken from
// http://math-atlas.sourceforge.net/devel/assembly/mipsabi32.pdf
namespace elfcpp
{
//
// MIPS Relocation Codes
//
enum
{
R_MIPS_NONE = 0,
R_MIPS_16 = 1,
R_MIPS_32 = 2, // In Elf 64: alias R_MIPS_ADD
R_MIPS_REL32 = 3, // In Elf 64: alias R_MIPS_REL
R_MIPS_26 = 4,
R_MIPS_HI16 = 5,
R_MIPS_LO16 = 6,
R_MIPS_GPREL16 = 7, // In Elf 64: alias R_MIPS_GPREL
R_MIPS_LITERAL = 8,
R_MIPS_GOT16 = 9, // In Elf 64: alias R_MIPS_GOT
R_MIPS_PC16 = 10,
R_MIPS_CALL16 = 11, // In Elf 64: alias R_MIPS_CALL
R_MIPS_GPREL32 = 12,
R_MIPS_UNUSED1 = 13,
R_MIPS_UNUSED2 = 14,
R_MIPS_UNUSED3 = 15,
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,
// TLS relocations.
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,
// These relocs are used for the mips16.
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_MIPS_COPY = 126,
R_MIPS_JUMP_SLOT = 127,
// These relocations are specific to microMIPS.
R_MICROMIPS_26_S1 = 133,
R_MICROMIPS_HI16 = 134,
R_MICROMIPS_LO16 = 135,
R_MICROMIPS_GPREL16 = 136, // In Elf 64: alias R_MICROMIPS_GPREL
R_MICROMIPS_LITERAL = 137,
R_MICROMIPS_GOT16 = 138, // In Elf 64: alias R_MICROMIPS_GOT
R_MICROMIPS_PC7_S1 = 139,
R_MICROMIPS_PC10_S1 = 140,
R_MICROMIPS_PC16_S1 = 141,
R_MICROMIPS_CALL16 = 142, // In Elf 64: alias R_MICROMIPS_CALL
R_MICROMIPS_GOT_DISP = 145,
R_MICROMIPS_GOT_PAGE = 146,
R_MICROMIPS_GOT_OFST = 147,
R_MICROMIPS_GOT_HI16 = 148,
R_MICROMIPS_GOT_LO16 = 149,
R_MICROMIPS_SUB = 150,
R_MICROMIPS_HIGHER = 151,
R_MICROMIPS_HIGHEST = 152,
R_MICROMIPS_CALL_HI16 = 153,
R_MICROMIPS_CALL_LO16 = 154,
R_MICROMIPS_SCN_DISP = 155,
R_MICROMIPS_JALR = 156,
R_MICROMIPS_HI0_LO16 = 157,
// TLS relocations.
R_MICROMIPS_TLS_GD = 162,
R_MICROMIPS_TLS_LDM = 163,
R_MICROMIPS_TLS_DTPREL_HI16 = 164,
R_MICROMIPS_TLS_DTPREL_LO16 = 165,
R_MICROMIPS_TLS_GOTTPREL = 166,
R_MICROMIPS_TLS_TPREL_HI16 = 169,
R_MICROMIPS_TLS_TPREL_LO16 = 170,
// microMIPS GP- and PC-relative relocations.
R_MICROMIPS_GPREL7_S2 = 172,
R_MICROMIPS_PC23_S2 = 173,
// This was a GNU extension used by embedded-PIC. It was co-opted by
// mips-linux for exception-handling data. GCC stopped using it in
// May, 2004, then started using it again for compact unwind tables.
R_MIPS_PC32 = 248,
R_MIPS_EH = 249,
// This relocation is used internally by gas.
R_MIPS_GNU_REL16_S2 = 250,
// These are GNU extensions to enable C++ vtable garbage collection.
R_MIPS_GNU_VTINHERIT = 253,
R_MIPS_GNU_VTENTRY = 254
};
// Processor specific flags for the ELF header e_flags field.
enum
{
// At least one .noreorder directive appears in the source.
EF_MIPS_NOREORDER = 0x00000001,
// File contains position independent code.
EF_MIPS_PIC = 0x00000002,
// Code in file uses the standard calling sequence for calling
// position independent code.
EF_MIPS_CPIC = 0x00000004,
// ??? Unknown flag, set in IRIX 6's BSDdup2.o in libbsd.a.
EF_MIPS_XGOT = 0x00000008,
// Code in file uses UCODE (obsolete)
EF_MIPS_UCODE = 0x00000010,
// Code in file uses new ABI (-n32 on Irix 6).
EF_MIPS_ABI2 = 0x00000020,
// Process the .MIPS.options section first by ld
EF_MIPS_OPTIONS_FIRST = 0x00000080,
// Architectural Extensions used by this file
EF_MIPS_ARCH_ASE = 0x0f000000,
// Use MDMX multimedia extensions
EF_MIPS_ARCH_ASE_MDMX = 0x08000000,
// Use MIPS-16 ISA extensions
EF_MIPS_ARCH_ASE_M16 = 0x04000000,
// Use MICROMIPS ISA extensions.
EF_MIPS_ARCH_ASE_MICROMIPS = 0x02000000,
// Indicates code compiled for a 64-bit machine in 32-bit mode.
// (regs are 32-bits wide.)
EF_MIPS_32BITMODE = 0x00000100,
// MIPS dynamic
EF_MIPS_DYNAMIC = 0x40
};
// 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.
enum
{
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.
E_MIPS_MACH_3900 = 0x00810000,
E_MIPS_MACH_4010 = 0x00820000,
E_MIPS_MACH_4100 = 0x00830000,
E_MIPS_MACH_4650 = 0x00850000,
E_MIPS_MACH_4120 = 0x00870000,
E_MIPS_MACH_4111 = 0x00880000,
E_MIPS_MACH_SB1 = 0x008a0000,
E_MIPS_MACH_OCTEON = 0x008b0000,
E_MIPS_MACH_XLR = 0x008c0000,
E_MIPS_MACH_OCTEON2 = 0x008d0000,
E_MIPS_MACH_OCTEON3 = 0x008e0000,
E_MIPS_MACH_5400 = 0x00910000,
E_MIPS_MACH_5500 = 0x00980000,
E_MIPS_MACH_9000 = 0x00990000,
E_MIPS_MACH_LS2E = 0x00A00000,
E_MIPS_MACH_LS2F = 0x00A10000,
E_MIPS_MACH_LS3A = 0x00A20000,
};
// MIPS architecture
enum
{
// Four bit MIPS architecture field.
EF_MIPS_ARCH = 0xf0000000,
// -mips1 code.
E_MIPS_ARCH_1 = 0x00000000,
// -mips2 code.
E_MIPS_ARCH_2 = 0x10000000,
// -mips3 code.
E_MIPS_ARCH_3 = 0x20000000,
// -mips4 code.
E_MIPS_ARCH_4 = 0x30000000,
// -mips5 code.
E_MIPS_ARCH_5 = 0x40000000,
// -mips32 code.
E_MIPS_ARCH_32 = 0x50000000,
// -mips64 code.
E_MIPS_ARCH_64 = 0x60000000,
// -mips32r2 code.
E_MIPS_ARCH_32R2 = 0x70000000,
// -mips64r2 code.
E_MIPS_ARCH_64R2 = 0x80000000,
// -mips32r6 code.
E_MIPS_ARCH_32R6 = 0x90000000,
// -mips64r6 code.
E_MIPS_ARCH_64R6 = 0xa0000000,
};
enum
{
// Mask to extract ABI version, not really a flag value.
EF_MIPS_ABI = 0x0000F000,
// The original o32 abi.
E_MIPS_ABI_O32 = 0x00001000,
// O32 extended to work on 64 bit architectures
E_MIPS_ABI_O64 = 0x00002000,
// EABI in 32 bit mode
E_MIPS_ABI_EABI32 = 0x00003000,
// EABI in 64 bit mode
E_MIPS_ABI_EABI64 = 0x00004000,
};
// Dynamic section MIPS flags
enum
{
// None
RHF_NONE = 0x00000000,
// Use shortcut pointers
RHF_QUICKSTART = 0x00000001,
// Hash size not power of two
RHF_NOTPOT = 0x00000002,
// Ignore LD_LIBRARY_PATH
RHF_NO_LIBRARY_REPLACEMENT = 0x00000004
};
// Special values for the st_other field in the symbol table.
enum
{
// 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 mask spanning the rest of MIPS psABI flags. At most one is expected
// to be set except for STO_MIPS16.
STO_MIPS_FLAGS = ~(STO_MIPS_ISA | 0x3),
// 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
};
// Values for base offsets for thread-local storage
enum
{
TP_OFFSET = 0x7000,
DTP_OFFSET = 0x8000
};
bool
elf_st_is_mips16(unsigned char st_other)
{ return (st_other & elfcpp::STO_MIPS16) == elfcpp::STO_MIPS16; }
bool
elf_st_is_micromips(unsigned char st_other)
{ return (st_other & elfcpp::STO_MIPS_ISA) == elfcpp::STO_MICROMIPS; }
// Whether the ABI is N32.
bool
abi_n32(elfcpp::Elf_Word e_flags)
{ return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; }
// Whether the ABI is N64.
bool
abi_64(unsigned char ei_class)
{ return ei_class == elfcpp::ELFCLASS64; }
// Whether the file has microMIPS code.
bool
is_micromips(elfcpp::Elf_Word e_flags)
{ return (e_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS) != 0; }
// Values which may appear in the kind field of an Elf_Options structure.
enum
{
// Undefined.
ODK_NULL = 0,
// Register usage and GP value.
ODK_REGINFO = 1,
// Exception processing information.
ODK_EXCEPTIONS = 2,
// Section padding information.
ODK_PAD = 3,
// Hardware workarounds performed.
ODK_HWPATCH = 4,
// Fill value used by the linker.
ODK_FILL = 5,
// Reserved space for desktop tools.
ODK_TAGS = 6,
// Hardware workarounds, AND bits when merging.
ODK_HWAND = 7,
// Hardware workarounds, OR bits when merging.
ODK_HWOR = 8,
// GP group to use for text/data sections.
ODK_GP_GROUP = 9,
// ID information.
ODK_IDENT = 10
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_MIPS_H)

View file

@ -0,0 +1,274 @@
// powerpc.h -- ELF definitions specific to EM_PPC and EM_PPC64 -*- C++ -*-
// Copyright (C) 2008-2014 Free Software Foundation, Inc.
// Written by David S. Miller <davem@davemloft.net>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_POWERPC_H
#define ELFCPP_POWERPC_H
namespace elfcpp
{
// The relocation numbers for 32-bit and 64-bit powerpc are nearly
// identical. Therefore I've adopted the convention of using
// R_POWERPC_foo for values which are the same in R_PPC_* and R_PPC64_*.
// For relocations which are specific to the word size I will use
// R_PPC_foo or R_PPC64_foo.
enum
{
R_POWERPC_NONE = 0,
R_POWERPC_ADDR32 = 1,
R_POWERPC_ADDR24 = 2,
R_POWERPC_ADDR16 = 3,
R_POWERPC_ADDR16_LO = 4,
R_POWERPC_ADDR16_HI = 5,
R_POWERPC_ADDR16_HA = 6,
R_POWERPC_ADDR14 = 7,
R_POWERPC_ADDR14_BRTAKEN = 8,
R_POWERPC_ADDR14_BRNTAKEN = 9,
R_POWERPC_REL24 = 10,
R_POWERPC_REL14 = 11,
R_POWERPC_REL14_BRTAKEN = 12,
R_POWERPC_REL14_BRNTAKEN = 13,
R_POWERPC_GOT16 = 14,
R_POWERPC_GOT16_LO = 15,
R_POWERPC_GOT16_HI = 16,
R_POWERPC_GOT16_HA = 17,
R_PPC_PLTREL24 = 18,
R_POWERPC_COPY = 19,
R_POWERPC_GLOB_DAT = 20,
R_POWERPC_JMP_SLOT = 21,
R_POWERPC_RELATIVE = 22,
R_PPC_LOCAL24PC = 23,
R_POWERPC_UADDR32 = 24,
R_POWERPC_UADDR16 = 25,
R_POWERPC_REL32 = 26,
R_POWERPC_PLT32 = 27,
R_POWERPC_PLTREL32 = 28,
R_POWERPC_PLT16_LO = 29,
R_POWERPC_PLT16_HI = 30,
R_POWERPC_PLT16_HA = 31,
R_PPC_SDAREL16 = 32,
R_POWERPC_SECTOFF = 33,
R_POWERPC_SECTOFF_LO = 34,
R_POWERPC_SECTOFF_HI = 35,
R_POWERPC_SECTOFF_HA = 36,
R_POWERPC_ADDR30 = 37,
R_PPC64_ADDR64 = 38,
R_PPC64_ADDR16_HIGHER = 39,
R_PPC64_ADDR16_HIGHERA = 40,
R_PPC64_ADDR16_HIGHEST = 41,
R_PPC64_ADDR16_HIGHESTA = 42,
R_PPC64_UADDR64 = 43,
R_PPC64_REL64 = 44,
R_PPC64_PLT64 = 45,
R_PPC64_PLTREL64 = 46,
R_PPC64_TOC16 = 47,
R_PPC64_TOC16_LO = 48,
R_PPC64_TOC16_HI = 49,
R_PPC64_TOC16_HA = 50,
R_PPC64_TOC = 51,
R_PPC64_PLTGOT16 = 52,
R_PPC64_PLTGOT16_LO = 53,
R_PPC64_PLTGOT16_HI = 54,
R_PPC64_PLTGOT16_HA = 55,
R_PPC64_ADDR16_DS = 56,
R_PPC64_ADDR16_LO_DS = 57,
R_PPC64_GOT16_DS = 58,
R_PPC64_GOT16_LO_DS = 59,
R_PPC64_PLT16_LO_DS = 60,
R_PPC64_SECTOFF_DS = 61,
R_PPC64_SECTOFF_LO_DS = 62,
R_PPC64_TOC16_DS = 63,
R_PPC64_TOC16_LO_DS = 64,
R_PPC64_PLTGOT16_DS = 65,
R_PPC64_PLTGOT16_LO_DS = 66,
R_POWERPC_TLS = 67,
R_POWERPC_DTPMOD = 68,
R_POWERPC_TPREL16 = 69,
R_POWERPC_TPREL16_LO = 70,
R_POWERPC_TPREL16_HI = 71,
R_POWERPC_TPREL16_HA = 72,
R_POWERPC_TPREL = 73,
R_POWERPC_DTPREL16 = 74,
R_POWERPC_DTPREL16_LO = 75,
R_POWERPC_DTPREL16_HI = 76,
R_POWERPC_DTPREL16_HA = 77,
R_POWERPC_DTPREL = 78,
R_POWERPC_GOT_TLSGD16 = 79,
R_POWERPC_GOT_TLSGD16_LO = 80,
R_POWERPC_GOT_TLSGD16_HI = 81,
R_POWERPC_GOT_TLSGD16_HA = 82,
R_POWERPC_GOT_TLSLD16 = 83,
R_POWERPC_GOT_TLSLD16_LO = 84,
R_POWERPC_GOT_TLSLD16_HI = 85,
R_POWERPC_GOT_TLSLD16_HA = 86,
R_POWERPC_GOT_TPREL16 = 87,
R_POWERPC_GOT_TPREL16_LO = 88,
R_POWERPC_GOT_TPREL16_HI = 89,
R_POWERPC_GOT_TPREL16_HA = 90,
R_POWERPC_GOT_DTPREL16 = 91,
R_POWERPC_GOT_DTPREL16_LO = 92,
R_POWERPC_GOT_DTPREL16_HI = 93,
R_POWERPC_GOT_DTPREL16_HA = 94,
R_PPC_TLSGD = 95,
R_PPC64_TPREL16_DS = 95,
R_PPC_TLSLD = 96,
R_PPC64_TPREL16_LO_DS = 96,
R_PPC64_TPREL16_HIGHER = 97,
R_PPC64_TPREL16_HIGHERA = 98,
R_PPC64_TPREL16_HIGHEST = 99,
R_PPC64_TPREL16_HIGHESTA = 100,
R_PPC_EMB_NADDR32 = 101,
R_PPC64_DTPREL16_DS = 101,
R_PPC_EMB_NADDR16 = 102,
R_PPC64_DTPREL16_LO_DS = 102,
R_PPC_EMB_NADDR16_LO = 103,
R_PPC64_DTPREL16_HIGHER = 103,
R_PPC_EMB_NADDR16_HI = 104,
R_PPC64_DTPREL16_HIGHERA = 104,
R_PPC_EMB_NADDR16_HA = 105,
R_PPC64_DTPREL16_HIGHEST = 105,
R_PPC_EMB_SDAI16 = 106,
R_PPC64_DTPREL16_HIGHESTA = 106,
R_PPC_EMB_SDA2I16 = 107,
R_PPC64_TLSGD = 107,
R_PPC_EMB_SDA2REL = 108,
R_PPC64_TLSLD = 108,
R_PPC_EMB_SDA21 = 109,
R_PPC64_TOCSAVE = 109,
R_PPC_EMB_MRKREF = 110,
R_PPC64_ADDR16_HIGH = 110,
R_PPC_EMB_RELSEC16 = 111,
R_PPC64_ADDR16_HIGHA = 111,
R_PPC_EMB_RELST_LO = 112,
R_PPC64_TPREL16_HIGH = 112,
R_PPC_EMB_RELST_HI = 113,
R_PPC64_TPREL16_HIGHA = 113,
R_PPC_EMB_RELST_HA = 114,
R_PPC64_DTPREL16_HIGH = 114,
R_PPC_EMB_BIT_FLD = 115,
R_PPC64_DTPREL16_HIGHA = 115,
R_PPC_EMB_RELSDA = 116,
R_PPC64_REL24_NOTOC = 116,
R_PPC64_ADDR64_LOCAL = 117,
R_PPC_VLE_REL8 = 216,
R_PPC_VLE_REL15 = 217,
R_PPC_VLE_REL24 = 218,
R_PPC_VLE_LO16A = 219,
R_PPC_VLE_LO16D = 220,
R_PPC_VLE_HI16A = 221,
R_PPC_VLE_HI16D = 222,
R_PPC_VLE_HA16A = 223,
R_PPC_VLE_HA16D = 224,
R_PPC_VLE_SDA21 = 225,
R_PPC_VLE_SDA21_LO = 226,
R_PPC_VLE_SDAREL_LO16A = 227,
R_PPC_VLE_SDAREL_LO16D = 228,
R_PPC_VLE_SDAREL_HI16A = 229,
R_PPC_VLE_SDAREL_HI16D = 230,
R_PPC_VLE_SDAREL_HA16A = 231,
R_PPC_VLE_SDAREL_HA16D = 232,
R_PPC64_JMP_IREL = 247,
R_POWERPC_IRELATIVE = 248,
R_POWERPC_REL16 = 249,
R_POWERPC_REL16_LO = 250,
R_POWERPC_REL16_HI = 251,
R_POWERPC_REL16_HA = 252,
R_POWERPC_GNU_VTINHERIT = 253,
R_POWERPC_GNU_VTENTRY = 254,
R_PPC_TOC16 = 255,
};
// e_flags values defined for powerpc
enum
{
EF_PPC_EMB = 0x80000000, // PowerPC embedded flag.
EF_PPC_RELOCATABLE = 0x00010000, // PowerPC -mrelocatable flag. */
EF_PPC_RELOCATABLE_LIB = 0x00008000, // PowerPC -mrelocatable-lib flag. */
};
// e_flags values defined for powerpc64
enum
{
// ABI version
// 1 for original function descriptor using ABI,
// 2 for revised ABI without function descriptors,
// 0 for unspecified or not using any features affected by the differences.
EF_PPC64_ABI = 3
};
enum
{
// The ELFv2 ABI uses three bits in the symbol st_other field of a
// function definition to specify the number of instructions between a
// function's global entry point and local entry point.
// The global entry point is used when it is necessary to set up the
// toc pointer (r2) for the function. Callers must enter the global
// entry point with r12 set to the global entry point address. On
// return from the function, r2 may have a different value to that
// which it had on entry.
// The local entry point is used when r2 is known to already be valid
// for the function. There is no requirement on r12 when using the
// local entry point, and on return r2 will contain the same value as
// at entry.
// A value of zero in these bits means that the function has a single
// entry point with no requirement on r12 or r2, and that on return r2
// will contain the same value as at entry.
// Values of one and seven are reserved.
STO_PPC64_LOCAL_BIT = 5,
STO_PPC64_LOCAL_MASK = 0xE0
};
// 3 bit other field to bytes.
static inline unsigned int
ppc64_decode_local_entry(unsigned int other)
{
return ((1 << other) >> 2) << 2;
}
// bytes to field value.
static inline unsigned int
ppc64_encode_local_entry(unsigned int val)
{
return (val >= 4 * 4
? (val >= 8 * 4
? (val >= 16 * 4 ? 6 : 5)
: 4)
: (val >= 2 * 4
? 3
: (val >= 1 * 4 ? 2 : 0)));
}
} // End namespace elfcpp.
#endif // !defined(ELFCPP_POWERPC_H)

View file

@ -0,0 +1,173 @@
// sparc.h -- ELF definitions specific to EM_SPARC -*- C++ -*-
// Copyright (C) 2008-2014 Free Software Foundation, Inc.
// Written by David S. Miller <davem@davemloft.net>.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_SPARC_H
#define ELFCPP_SPARC_H
// Documentation for the TLS relocs is taken from
// http://people.redhat.com/drepper/tls.pdf
//
// More full documentation on sparc specific ELF file
// format details can be found at
//
// http://docs.sun.com/app/docs/doc/819/0690/
// "Linker and Libraries Guide"
//
// specifically Chapter 7 "Object File Format" and
// Chapter 8 "Thread-Local Storage"
namespace elfcpp
{
enum
{
R_SPARC_NONE = 0, // No reloc
R_SPARC_8 = 1, // Direct 8 bit
R_SPARC_16 = 2, // Direct 16 bit
R_SPARC_32 = 3, // Direct 32 bit
R_SPARC_DISP8 = 4, // PC relative 8 bit
R_SPARC_DISP16 = 5, // PC relative 16 bit
R_SPARC_DISP32 = 6, // PC relative 32 bit
R_SPARC_WDISP30 = 7, // PC relative 30 bit shifted
R_SPARC_WDISP22 = 8, // PC relative 22 bit shifted
R_SPARC_HI22 = 9, // High 22 bit
R_SPARC_22 = 10, // Direct 22 bit
R_SPARC_13 = 11, // Direct 13 bit
R_SPARC_LO10 = 12, // Truncated 10 bit
R_SPARC_GOT10 = 13, // Truncated 10 bit GOT entry
R_SPARC_GOT13 = 14, // 13 bit GOT entry
R_SPARC_GOT22 = 15, // 22 bit GOT entry shifted
R_SPARC_PC10 = 16, // PC relative 10 bit truncated
R_SPARC_PC22 = 17, // PC relative 22 bit shifted
R_SPARC_WPLT30 = 18, // 30 bit PC relative PLT address
R_SPARC_COPY = 19, // Copy symbol at runtime
R_SPARC_GLOB_DAT = 20, // Create GOT entry
R_SPARC_JMP_SLOT = 21, // Create PLT entry
R_SPARC_RELATIVE = 22, // Adjust by program base
R_SPARC_UA32 = 23, // Direct 32 bit unaligned
R_SPARC_PLT32 = 24, // Direct 32 bit ref to PLT entry
R_SPARC_HIPLT22 = 25, // High 22 bit PLT entry
R_SPARC_LOPLT10 = 26, // Truncated 10 bit PLT entry
R_SPARC_PCPLT32 = 27, // PC rel 32 bit ref to PLT entry
R_SPARC_PCPLT22 = 28, // PC rel high 22 bit PLT entry
R_SPARC_PCPLT10 = 29, // PC rel trunc 10 bit PLT entry
R_SPARC_10 = 30, // Direct 10 bit
R_SPARC_11 = 31, // Direct 11 bit
R_SPARC_64 = 32, // Direct 64 bit
R_SPARC_OLO10 = 33, // 10bit with secondary 13bit addend
R_SPARC_HH22 = 34, // Top 22 bits of direct 64 bit
R_SPARC_HM10 = 35, // High middle 10 bits of ...
R_SPARC_LM22 = 36, // Low middle 22 bits of ...
R_SPARC_PC_HH22 = 37, // Top 22 bits of pc rel 64 bit
R_SPARC_PC_HM10 = 38, // High middle 10 bit of ...
R_SPARC_PC_LM22 = 39, // Low miggle 22 bits of ...
R_SPARC_WDISP16 = 40, // PC relative 16 bit shifted
R_SPARC_WDISP19 = 41, // PC relative 19 bit shifted
R_SPARC_GLOB_JMP = 42, // was part of v9 ABI but was removed
R_SPARC_7 = 43, // Direct 7 bit
R_SPARC_5 = 44, // Direct 5 bit
R_SPARC_6 = 45, // Direct 6 bit
R_SPARC_DISP64 = 46, // PC relative 64 bit
R_SPARC_PLT64 = 47, // Direct 64 bit ref to PLT entry
R_SPARC_HIX22 = 48, // High 22 bit complemented
R_SPARC_LOX10 = 49, // Truncated 11 bit complemented
R_SPARC_H44 = 50, // Direct high 12 of 44 bit
R_SPARC_M44 = 51, // Direct mid 22 of 44 bit
R_SPARC_L44 = 52, // Direct low 10 of 44 bit
R_SPARC_REGISTER = 53, // Global register usage
R_SPARC_UA64 = 54, // Direct 64 bit unaligned
R_SPARC_UA16 = 55, // Direct 16 bit unaligned
R_SPARC_TLS_GD_HI22 = 56, // Initial General Dynamic reloc, high 22-bit
R_SPARC_TLS_GD_LO10 = 57, // Initial General Dynamic reloc, low 10-bit
R_SPARC_TLS_GD_ADD = 58, // Initial General Dynamic reloc, add
R_SPARC_TLS_GD_CALL = 59, // Initial General Dynamic reloc, call
R_SPARC_TLS_LDM_HI22 = 60, // Initial Local Dynamic reloc, high 22-bit
R_SPARC_TLS_LDM_LO10 = 61, // Initial Local Dynamic reloc, low 10-bit
R_SPARC_TLS_LDM_ADD = 62, // Initial Local Dynamic reloc, add
R_SPARC_TLS_LDM_CALL = 63, // Initial Local Dynamic reloc, call
R_SPARC_TLS_LDO_HIX22 = 64, // Initial Local Dynamic, high extended 22-bit
R_SPARC_TLS_LDO_LOX10 = 65, // Initial Local Dynamic, low extended 10-bit
R_SPARC_TLS_LDO_ADD = 66, // Initial Local Dynamic, add extended
R_SPARC_TLS_IE_HI22 = 67, // Initial Initial Exec reloc, high 22-bit
R_SPARC_TLS_IE_LO10 = 68, // Initial Initial Exec reloc, low 10-bit
R_SPARC_TLS_IE_LD = 69, // Initial Initial Exec reloc, load 32-bit
R_SPARC_TLS_IE_LDX = 70, // Initial Initial Exec reloc, load 64-bit
R_SPARC_TLS_IE_ADD = 71, // Initial Initial Exec reloc, add
R_SPARC_TLS_LE_HIX22 = 72, // Initial Local Exec reloc, high extended 22-bit
R_SPARC_TLS_LE_LOX10 = 73, // Initial Local Exec reloc, low extended 10-bit
R_SPARC_TLS_DTPMOD32 = 74, // Outstanding General/Local Dynamic reloc, 32-bit
R_SPARC_TLS_DTPMOD64 = 75, // Outstanding General/Local Dynamic reloc, 64-bit
R_SPARC_TLS_DTPOFF32 = 76, // Outstanding General Dynamic reloc, 32-bit
R_SPARC_TLS_DTPOFF64 = 77, // Outstanding General Dynamic reloc, 64-bit
R_SPARC_TLS_TPOFF32 = 78, // Outstanding Initial Exec reloc, 32-bit
R_SPARC_TLS_TPOFF64 = 79, // Outstanding Initial Exec reloc, 64-bit
// GOT data code transformations
R_SPARC_GOTDATA_HIX22 = 80,
R_SPARC_GOTDATA_LOX10 = 81,
R_SPARC_GOTDATA_OP_HIX22 = 82,
R_SPARC_GOTDATA_OP_LOX10 = 83,
R_SPARC_GOTDATA_OP = 84,
R_SPARC_H34 = 85, // Direct high 12 of 34 bit
R_SPARC_SIZE32 = 86, // size of symbol, 32-bit
R_SPARC_SIZE64 = 87, // size of symbol, 64-bit
R_SPARC_WDISP10 = 88, // PC relative 10 bit shifted
R_SPARC_JMP_IREL = 248, // Create PLT slot to IFUNC function
R_SPARC_IRELATIVE = 249, // Adjust indirectly by program base
// GNU vtable garbage collection extensions.
R_SPARC_GNU_VTINHERIT = 250,
R_SPARC_GNU_VTENTRY = 251,
R_SPARC_REV32 = 252,
};
// e_flags values defined for sparc
enum
{
EF_SPARC_EXT_MASK = 0xffff00, // reserved for vendor extensions
EF_SPARC_32PLUS_MASK = 0xffff00, // bits indicating V8+ type
EF_SPARC_32PLUS = 0x000100, // generic V8+ features
EF_SPARC_SUN_US1 = 0x000200, // Sun UltraSPARC-I extensions
EF_SPARC_HAL_R1 = 0x000400, // HAL R1 extensions
EF_SPARC_SUN_US3 = 0x000800, // Sun UltraSPARC-III extensions
EF_SPARC_LEDATA = 0x800000, // little endian data
EF_SPARCV9_MM = 0x3, // memory model mask
EF_SPARCV9_TSO = 0x0, // total store ordering
EF_SPARCV9_PSO = 0x1, // partial store ordering
EF_SPARCV9_RMO = 0x2, // relaxed store ordering
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_SPARC_H)

View file

@ -0,0 +1,171 @@
// tilegx.h -- ELF definitions specific to EM_TILEGX -*- C++ -*-
// Copyright (C) 2012-2014 Free Software Foundation, Inc.
// Written by Jiong Wang (jiwang@tilera.com)
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_TILEGX_H
#define ELFCPP_TILEGX_H
namespace elfcpp
{
// Documentation is taken from
// http://www.tilera.com/scm/docs/index.html
enum
{
R_TILEGX_NONE = 0,
R_TILEGX_64 = 1,
R_TILEGX_32 = 2,
R_TILEGX_16 = 3,
R_TILEGX_8 = 4,
R_TILEGX_64_PCREL = 5,
R_TILEGX_32_PCREL = 6,
R_TILEGX_16_PCREL = 7,
R_TILEGX_8_PCREL = 8,
R_TILEGX_HW0 = 9,
R_TILEGX_HW1 = 10,
R_TILEGX_HW2 = 11,
R_TILEGX_HW3 = 12,
R_TILEGX_HW0_LAST = 13,
R_TILEGX_HW1_LAST = 14,
R_TILEGX_HW2_LAST = 15,
R_TILEGX_COPY = 16,
R_TILEGX_GLOB_DAT = 17,
R_TILEGX_JMP_SLOT = 18,
R_TILEGX_RELATIVE = 19,
R_TILEGX_BROFF_X1 = 20,
R_TILEGX_JUMPOFF_X1 = 21,
R_TILEGX_JUMPOFF_X1_PLT = 22,
R_TILEGX_IMM8_X0 = 23,
R_TILEGX_IMM8_Y0 = 24,
R_TILEGX_IMM8_X1 = 25,
R_TILEGX_IMM8_Y1 = 26,
R_TILEGX_DEST_IMM8_X1 = 27,
R_TILEGX_MT_IMM14_X1 = 28,
R_TILEGX_MF_IMM14_X1 = 29,
R_TILEGX_MMSTART_X0 = 30,
R_TILEGX_MMEND_X0 = 31,
R_TILEGX_SHAMT_X0 = 32,
R_TILEGX_SHAMT_X1 = 33,
R_TILEGX_SHAMT_Y0 = 34,
R_TILEGX_SHAMT_Y1 = 35,
R_TILEGX_IMM16_X0_HW0 = 36,
R_TILEGX_IMM16_X1_HW0 = 37,
R_TILEGX_IMM16_X0_HW1 = 38,
R_TILEGX_IMM16_X1_HW1 = 39,
R_TILEGX_IMM16_X0_HW2 = 40,
R_TILEGX_IMM16_X1_HW2 = 41,
R_TILEGX_IMM16_X0_HW3 = 42,
R_TILEGX_IMM16_X1_HW3 = 43,
R_TILEGX_IMM16_X0_HW0_LAST = 44,
R_TILEGX_IMM16_X1_HW0_LAST = 45,
R_TILEGX_IMM16_X0_HW1_LAST = 46,
R_TILEGX_IMM16_X1_HW1_LAST = 47,
R_TILEGX_IMM16_X0_HW2_LAST = 48,
R_TILEGX_IMM16_X1_HW2_LAST = 49,
R_TILEGX_IMM16_X0_HW0_PCREL = 50,
R_TILEGX_IMM16_X1_HW0_PCREL = 51,
R_TILEGX_IMM16_X0_HW1_PCREL = 52,
R_TILEGX_IMM16_X1_HW1_PCREL = 53,
R_TILEGX_IMM16_X0_HW2_PCREL = 54,
R_TILEGX_IMM16_X1_HW2_PCREL = 55,
R_TILEGX_IMM16_X0_HW3_PCREL = 56,
R_TILEGX_IMM16_X1_HW3_PCREL = 57,
R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58,
R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59,
R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60,
R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61,
R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62,
R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63,
R_TILEGX_IMM16_X0_HW0_GOT = 64,
R_TILEGX_IMM16_X1_HW0_GOT = 65,
R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66,
R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67,
R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68,
R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69,
R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70,
R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71,
R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72,
R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73,
R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74,
R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75,
R_TILEGX_IMM16_X0_HW0_TLS_GD = 78,
R_TILEGX_IMM16_X1_HW0_TLS_GD = 79,
R_TILEGX_IMM16_X0_HW0_TLS_LE = 80,
R_TILEGX_IMM16_X1_HW0_TLS_LE = 81,
R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82,
R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83,
R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84,
R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85,
R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86,
R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87,
R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88,
R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89,
R_TILEGX_IRELATIVE = 90,
R_TILEGX_IMM16_X0_HW0_TLS_IE = 92,
R_TILEGX_IMM16_X1_HW0_TLS_IE = 93,
R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94,
R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95,
R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96,
R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97,
R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98,
R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99,
R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100,
R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101,
R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102,
R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103,
R_TILEGX_TLS_DTPMOD64 = 106,
R_TILEGX_TLS_DTPOFF64 = 107,
R_TILEGX_TLS_TPOFF64 = 108,
R_TILEGX_TLS_DTPMOD32 = 109,
R_TILEGX_TLS_DTPOFF32 = 110,
R_TILEGX_TLS_TPOFF32 = 111,
R_TILEGX_TLS_GD_CALL = 112,
R_TILEGX_IMM8_X0_TLS_GD_ADD = 113,
R_TILEGX_IMM8_X1_TLS_GD_ADD = 114,
R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115,
R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116,
R_TILEGX_TLS_IE_LOAD = 117,
R_TILEGX_IMM8_X0_TLS_ADD = 118,
R_TILEGX_IMM8_X1_TLS_ADD = 119,
R_TILEGX_IMM8_Y0_TLS_ADD = 120,
R_TILEGX_IMM8_Y1_TLS_ADD = 121,
R_TILEGX_GNU_VTINHERIT = 128,
R_TILEGX_GNU_VTENTRY = 129,
R_TILEGX_NUM = 130
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_TILEGX_H)

View file

@ -0,0 +1,104 @@
// x86-64.h -- ELF definitions specific to EM_X86_64 -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Andrew Chatham.
// This file is part of elfcpp.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public License
// as published by the Free Software Foundation; either version 2, or
// (at your option) any later version.
// In addition to the permissions in the GNU Library General Public
// License, the Free Software Foundation gives you unlimited
// permission to link the compiled version of this file into
// combinations with other programs, and to distribute those
// combinations without any restriction coming from the use of this
// file. (The Library Public License restrictions do apply in other
// respects; for example, they cover modification of the file, and
/// distribution when not linked into a combined executable.)
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
#ifndef ELFCPP_X86_64_H
#define ELFCPP_X86_64_H
namespace elfcpp
{
// Documentation is taken from
// http://www.x86-64.org/documentation/abi-0.98.pdf
// elf.h
// Documentation for the TLS relocs is taken from
// http://people.redhat.com/drepper/tls.pdf
// http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt
enum
{
R_X86_64_NONE = 0, // No reloc
R_X86_64_64 = 1, // Direct 64 bit
R_X86_64_PC32 = 2, // PC relative 32 bit signed
R_X86_64_GOT32 = 3, // 32 bit GOT entry
R_X86_64_PLT32 = 4, // 32 bit PLT address
R_X86_64_COPY = 5, // Copy symbol at runtime
R_X86_64_GLOB_DAT = 6, // Create GOT entry
R_X86_64_JUMP_SLOT = 7, // Create PLT entry
R_X86_64_RELATIVE = 8, // Adjust by program base
R_X86_64_GOTPCREL = 9, // 32 bit signed PC relative offset to GOT
R_X86_64_32 = 10, // Direct 32 bit zero extended
R_X86_64_32S = 11, // Direct 32 bit sign extended
R_X86_64_16 = 12, // Direct 16 bit zero extended
R_X86_64_PC16 = 13, // 16 bit sign extended pc relative
R_X86_64_8 = 14, // Direct 8 bit sign extended
R_X86_64_PC8 = 15, // 8 bit sign extended pc relative
// TLS relocations
R_X86_64_DTPMOD64 = 16, // ID of module containing symbol
R_X86_64_DTPOFF64 = 17, // Offset in module's TLS block
R_X86_64_TPOFF64 = 18, // Offset in initial TLS block
R_X86_64_TLSGD = 19, // 32 bit signed PC relative offset to two
// GOT entries for GD symbol
R_X86_64_TLSLD = 20, // 32 bit signed PC relative offset to two
// GOT entries for LD symbol
R_X86_64_DTPOFF32 = 21, // Offset in TLS block
R_X86_64_GOTTPOFF = 22, // 32 bit signed PC relative offset to GOT
// entry for IE symbol
R_X86_64_TPOFF32 = 23, // Offset in initial TLS block
R_X86_64_PC64 = 24, // 64-bit PC relative
R_X86_64_GOTOFF64 = 25, // 64-bit GOT offset
R_X86_64_GOTPC32 = 26, // 32-bit PC relative offset to GOT
R_X86_64_GOT64 = 27, // 64-bit GOT entry offset
R_X86_64_GOTPCREL64 = 28, // 64-bit PC relative offset to GOT entry
R_X86_64_GOTPC64 = 29, // 64-bit PC relative offset to GOT
R_X86_64_GOTPLT64 = 30, // Like GOT64, indicates that PLT entry needed
R_X86_64_PLTOFF64 = 31, // 64-bit GOT relative offset to PLT entry
R_X86_64_SIZE32 = 32,
R_X86_64_SIZE64 = 33,
R_X86_64_GOTPC32_TLSDESC = 34, // 32-bit PC relative to TLS descriptor in GOT
R_X86_64_TLSDESC_CALL = 35, // Relaxable call through TLS descriptor
R_X86_64_TLSDESC = 36, // 2 by 64-bit TLS descriptor
R_X86_64_IRELATIVE = 37, // Adjust indirectly by program base
R_X86_64_RELATIVE64 = 38, // 64-bit adjust by program base
R_X86_64_PC32_BND = 39, // PC relative 32 bit signed with BND prefix
R_X86_64_PLT32_BND = 40, // 32 bit PLT address with BND prefix
// GNU vtable garbage collection extensions.
R_X86_64_GNU_VTINHERIT = 250,
R_X86_64_GNU_VTENTRY = 251
};
} // End namespace elfcpp.
#endif // !defined(ELFCPP_X86_64_H)