binutils-gdb/elfcpp/elfcpp.h

2221 lines
54 KiB
C
Raw Normal View History

2006-08-05 01:10:59 +02:00
// elfcpp.h -- main header file for elfcpp -*- C++ -*-
// Copyright (C) 2006-2018 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.
2006-08-05 01:10:59 +02:00
// This is the external interface for elfcpp.
#ifndef ELFCPP_H
#define ELFCPP_H
2006-11-06 23:45:08 +01:00
#include "elfcpp_swap.h"
2006-08-05 01:10:59 +02:00
#include <stdint.h>
namespace elfcpp
{
// Basic ELF types.
// These types are always the same size.
typedef uint16_t Elf_Half;
typedef uint32_t Elf_Word;
typedef int32_t Elf_Sword;
typedef uint64_t Elf_Xword;
typedef int64_t Elf_Sxword;
// These types vary in size depending on the ELF file class. The
// template parameter should be 32 or 64.
template<int size>
2006-09-25 23:29:06 +02:00
struct Elf_types;
2006-08-05 01:10:59 +02:00
template<>
struct Elf_types<32>
{
typedef uint32_t Elf_Addr;
typedef uint32_t Elf_Off;
typedef uint32_t Elf_WXword;
typedef int32_t Elf_Swxword;
2006-08-05 01:10:59 +02:00
};
template<>
struct Elf_types<64>
{
typedef uint64_t Elf_Addr;
typedef uint64_t Elf_Off;
typedef uint64_t Elf_WXword;
typedef int64_t Elf_Swxword;
2006-08-05 01:10:59 +02:00
};
// Offsets within the Ehdr e_ident field.
const int EI_MAG0 = 0;
const int EI_MAG1 = 1;
const int EI_MAG2 = 2;
const int EI_MAG3 = 3;
const int EI_CLASS = 4;
const int EI_DATA = 5;
const int EI_VERSION = 6;
const int EI_OSABI = 7;
const int EI_ABIVERSION = 8;
const int EI_PAD = 9;
const int EI_NIDENT = 16;
// The valid values found in Ehdr e_ident[EI_MAG0 through EI_MAG3].
const int ELFMAG0 = 0x7f;
const int ELFMAG1 = 'E';
const int ELFMAG2 = 'L';
const int ELFMAG3 = 'F';
// The valid values found in Ehdr e_ident[EI_CLASS].
enum
{
ELFCLASSNONE = 0,
ELFCLASS32 = 1,
ELFCLASS64 = 2
};
// The valid values found in Ehdr e_ident[EI_DATA].
enum
{
ELFDATANONE = 0,
ELFDATA2LSB = 1,
ELFDATA2MSB = 2
};
// The valid values found in Ehdr e_ident[EI_VERSION] and e_version.
enum
{
EV_NONE = 0,
EV_CURRENT = 1
};
// The valid values found in Ehdr e_ident[EI_OSABI].
enum ELFOSABI
{
ELFOSABI_NONE = 0,
ELFOSABI_HPUX = 1,
ELFOSABI_NETBSD = 2,
ELFOSABI_GNU = 3,
// ELFOSABI_LINUX is an alias for ELFOSABI_GNU.
2006-08-05 01:10:59 +02:00
ELFOSABI_LINUX = 3,
ELFOSABI_SOLARIS = 6,
ELFOSABI_AIX = 7,
ELFOSABI_IRIX = 8,
ELFOSABI_FREEBSD = 9,
ELFOSABI_TRU64 = 10,
ELFOSABI_MODESTO = 11,
ELFOSABI_OPENBSD = 12,
ELFOSABI_OPENVMS = 13,
ELFOSABI_NSK = 14,
ELFOSABI_AROS = 15,
// A GNU extension for the ARM.
ELFOSABI_ARM = 97,
// A GNU extension for the MSP.
ELFOSABI_STANDALONE = 255
};
// The valid values found in the Ehdr e_type field.
enum ET
{
ET_NONE = 0,
ET_REL = 1,
ET_EXEC = 2,
ET_DYN = 3,
ET_CORE = 4,
ET_LOOS = 0xfe00,
ET_HIOS = 0xfeff,
ET_LOPROC = 0xff00,
ET_HIPROC = 0xffff
};
// The valid values found in the Ehdr e_machine field.
enum EM
{
EM_NONE = 0,
EM_M32 = 1,
EM_SPARC = 2,
EM_386 = 3,
EM_68K = 4,
EM_88K = 5,
EM_IAMCU = 6,
2006-08-05 01:10:59 +02:00
EM_860 = 7,
EM_MIPS = 8,
EM_S370 = 9,
EM_MIPS_RS3_LE = 10,
// 11 was the old Sparc V9 ABI.
// 12 through 14 are reserved.
EM_PARISC = 15,
// 16 is reserved.
// Some old PowerPC object files use 17.
EM_VPP500 = 17,
EM_SPARC32PLUS = 18,
EM_960 = 19,
EM_PPC = 20,
EM_PPC64 = 21,
EM_S390 = 22,
// 23 through 35 are served.
EM_V800 = 36,
EM_FR20 = 37,
EM_RH32 = 38,
EM_RCE = 39,
EM_ARM = 40,
EM_ALPHA = 41,
EM_SH = 42,
EM_SPARCV9 = 43,
EM_TRICORE = 44,
EM_ARC = 45,
EM_H8_300 = 46,
EM_H8_300H = 47,
EM_H8S = 48,
EM_H8_500 = 49,
EM_IA_64 = 50,
EM_MIPS_X = 51,
EM_COLDFIRE = 52,
EM_68HC12 = 53,
EM_MMA = 54,
EM_PCP = 55,
EM_NCPU = 56,
EM_NDR1 = 57,
EM_STARCORE = 58,
EM_ME16 = 59,
EM_ST100 = 60,
EM_TINYJ = 61,
EM_X86_64 = 62,
EM_PDSP = 63,
EM_PDP10 = 64,
EM_PDP11 = 65,
EM_FX66 = 66,
EM_ST9PLUS = 67,
EM_ST7 = 68,
EM_68HC16 = 69,
EM_68HC11 = 70,
EM_68HC08 = 71,
EM_68HC05 = 72,
EM_SVX = 73,
EM_ST19 = 74,
EM_VAX = 75,
EM_CRIS = 76,
EM_JAVELIN = 77,
EM_FIREPATH = 78,
EM_ZSP = 79,
EM_MMIX = 80,
EM_HUANY = 81,
EM_PRISM = 82,
EM_AVR = 83,
EM_FR30 = 84,
EM_D10V = 85,
EM_D30V = 86,
EM_V850 = 87,
EM_M32R = 88,
EM_MN10300 = 89,
EM_MN10200 = 90,
EM_PJ = 91,
EM_OR1K = 92,
2006-08-05 01:10:59 +02:00
EM_ARC_A5 = 93,
EM_XTENSA = 94,
EM_VIDEOCORE = 95,
EM_TMM_GPP = 96,
EM_NS32K = 97,
EM_TPC = 98,
// Some old picoJava object files use 99 (EM_PJ is correct).
EM_SNP1K = 99,
EM_ST200 = 100,
EM_IP2K = 101,
EM_MAX = 102,
EM_CR = 103,
EM_F2MC16 = 104,
EM_MSP430 = 105,
EM_BLACKFIN = 106,
EM_SE_C33 = 107,
EM_SEP = 108,
EM_ARCA = 109,
EM_UNICORE = 110,
EM_ALTERA_NIOS2 = 113,
EM_CRX = 114,
EM_TI_PRU = 144,
EM_AARCH64 = 183,
EM_TILEGX = 191,
2006-08-05 01:10:59 +02:00
// The Morph MT.
EM_MT = 0x2530,
// DLX.
EM_DLX = 0x5aa5,
// FRV.
EM_FRV = 0x5441,
// Infineon Technologies 16-bit microcontroller with C166-V2 core.
EM_X16X = 0x4688,
// Xstorym16
EM_XSTORMY16 = 0xad45,
// Renesas M32C
EM_M32C = 0xfeb0,
// Vitesse IQ2000
EM_IQ2000 = 0xfeba,
// NIOS
EM_NIOS32 = 0xfebb
// Old AVR objects used 0x1057 (EM_AVR is correct).
// Old MSP430 objects used 0x1059 (EM_MSP430 is correct).
// Old FR30 objects used 0x3330 (EM_FR30 is correct).
// Old OpenRISC objects used 0x3426 and 0x8472 (EM_OR1K is correct).
2006-08-05 01:10:59 +02:00
// Old D10V objects used 0x7650 (EM_D10V is correct).
// Old D30V objects used 0x7676 (EM_D30V is correct).
// Old IP2X objects used 0x8217 (EM_IP2K is correct).
// Old PowerPC objects used 0x9025 (EM_PPC is correct).
// Old Alpha objects used 0x9026 (EM_ALPHA is correct).
// Old M32R objects used 0x9041 (EM_M32R is correct).
// Old V850 objects used 0x9080 (EM_V850 is correct).
// Old S/390 objects used 0xa390 (EM_S390 is correct).
// Old Xtensa objects used 0xabc7 (EM_XTENSA is correct).
// Old MN10300 objects used 0xbeef (EM_MN10300 is correct).
// Old MN10200 objects used 0xdead (EM_MN10200 is correct).
};
// A special value found in the Ehdr e_phnum field.
enum
{
// Number of program segments stored in sh_info field of first
// section headre.
PN_XNUM = 0xffff
};
2006-08-05 01:10:59 +02:00
// Special section indices.
enum
{
SHN_UNDEF = 0,
SHN_LORESERVE = 0xff00,
SHN_LOPROC = 0xff00,
SHN_HIPROC = 0xff1f,
SHN_LOOS = 0xff20,
SHN_HIOS = 0xff3f,
SHN_ABS = 0xfff1,
SHN_COMMON = 0xfff2,
SHN_XINDEX = 0xffff,
SHN_HIRESERVE = 0xffff,
// Provide for initial and final section ordering in conjunction
// with the SHF_LINK_ORDER and SHF_ORDERED section flags.
SHN_BEFORE = 0xff00,
SHN_AFTER = 0xff01,
// x86_64 specific large common symbol.
SHN_X86_64_LCOMMON = 0xff02
2006-08-05 01:10:59 +02:00
};
// The valid values found in the Shdr sh_type field.
2006-09-25 23:29:06 +02:00
enum SHT
2006-08-05 01:10:59 +02:00
{
SHT_NULL = 0,
SHT_PROGBITS = 1,
SHT_SYMTAB = 2,
SHT_STRTAB = 3,
SHT_RELA = 4,
SHT_HASH = 5,
SHT_DYNAMIC = 6,
SHT_NOTE = 7,
SHT_NOBITS = 8,
SHT_REL = 9,
SHT_SHLIB = 10,
SHT_DYNSYM = 11,
SHT_INIT_ARRAY = 14,
SHT_FINI_ARRAY = 15,
SHT_PREINIT_ARRAY = 16,
SHT_GROUP = 17,
SHT_SYMTAB_SHNDX = 18,
SHT_LOOS = 0x60000000,
SHT_HIOS = 0x6fffffff,
SHT_LOPROC = 0x70000000,
SHT_HIPROC = 0x7fffffff,
SHT_LOUSER = 0x80000000,
SHT_HIUSER = 0xffffffff,
// The remaining values are not in the standard.
// Incremental build data.
SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700,
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
SHT_GNU_INCREMENTAL_SYMTAB = 0x6fff4701,
SHT_GNU_INCREMENTAL_RELOCS = 0x6fff4702,
SHT_GNU_INCREMENTAL_GOT_PLT = 0x6fff4703,
2008-03-06 01:15:04 +01:00
// Object attributes.
SHT_GNU_ATTRIBUTES = 0x6ffffff5,
// GNU style dynamic hash table.
SHT_GNU_HASH = 0x6ffffff6,
2006-08-05 01:10:59 +02:00
// List of prelink dependencies.
SHT_GNU_LIBLIST = 0x6ffffff7,
// Versions defined by file.
SHT_SUNW_verdef = 0x6ffffffd,
SHT_GNU_verdef = 0x6ffffffd,
// Versions needed by file.
SHT_SUNW_verneed = 0x6ffffffe,
SHT_GNU_verneed = 0x6ffffffe,
// Symbol versions,
SHT_SUNW_versym = 0x6fffffff,
SHT_GNU_versym = 0x6fffffff,
SHT_SPARC_GOTDATA = 0x70000000,
// ARM-specific section types.
// Exception Index table.
SHT_ARM_EXIDX = 0x70000001,
// BPABI DLL dynamic linking pre-emption map.
SHT_ARM_PREEMPTMAP = 0x70000002,
// Object file compatibility attributes.
SHT_ARM_ATTRIBUTES = 0x70000003,
// Support for debugging overlaid programs.
SHT_ARM_DEBUGOVERLAY = 0x70000004,
SHT_ARM_OVERLAYSECTION = 0x70000005,
// x86_64 unwind information.
SHT_X86_64_UNWIND = 0x70000001,
// MIPS-specific section types.
// Section contains register usage information.
SHT_MIPS_REGINFO = 0x70000006,
// Section contains miscellaneous options.
SHT_MIPS_OPTIONS = 0x7000000d,
Add support for .MIPS.abiflags and .gnu.attributes sections. elfcpp/ * elfcpp.h (SHT_MIPS_ABIFLAGS): New enum constant. * mips.h (EF_MIPS_FP64, EF_MIPS_NAN2008): New enum constants for processor-specific flags. (E_MIPS_MACH_5900): New enum constant for machine variant. (AFL_REG_NONE, AFL_REG_32, AFL_REG_64, AFL_REG_128): New enum constants. (AFL_ASE_DSP, AFL_ASE_DSPR2, AFL_ASE_EVA, AFL_ASE_MCU, AFL_ASE_MDMX, AFL_ASE_MIPS3D, AFL_ASE_MT, AFL_ASE_SMARTMIPS, AFL_ASE_VIRT, AFL_ASE_MSA, AFL_ASE_MIPS16, AFL_ASE_MICROMIPS, AFL_ASE_XPA): Likewise. (AFL_EXT_XLR, AFL_EXT_OCTEON2, AFL_EXT_OCTEONP, AFL_EXT_LOONGSON_3A, AFL_EXT_OCTEON, AFL_EXT_5900, AFL_EXT_4650, AFL_EXT_4010, AFL_EXT_4100, AFL_EXT_3900, AFL_EXT_10000, AFL_EXT_SB1, AFL_EXT_4111, AFL_EXT_4120, AFL_EXT_5400, AFL_EXT_5500, AFL_EXT_LOONGSON_2E, AFL_EXT_LOONGSON_2F, AFL_EXT_OCTEON3): Likewise. (Tag_GNU_MIPS_ABI_FP, Tag_GNU_MIPS_ABI_MSA): Likewise. (Val_GNU_MIPS_ABI_FP_ANY, Val_GNU_MIPS_ABI_FP_DOUBLE, Val_GNU_MIPS_ABI_FP_SINGLE, Val_GNU_MIPS_ABI_FP_SOFT, Val_GNU_MIPS_ABI_FP_OLD_64,Val_GNU_MIPS_ABI_FP_XX, Val_GNU_MIPS_ABI_FP_64, Val_GNU_MIPS_ABI_FP_64A, Val_GNU_MIPS_ABI_FP_NAN2008, Val_GNU_MIPS_ABI_MSA_ANY, Val_GNU_MIPS_ABI_MSA_128): Likewise. (AFL_FLAGS1_ODDSPREG): New enum constant. gold/ * mips.cc (struct Mips_abiflags): New struct. (Mips_relobj::Mips_relobj): Initialize attributes_section_data_ and abiflags_. (Mips_relobj::~Mips_relobj): Delete object pointed by attributes_section_data_. (Mips_relobj::abiflags): New method. (Mips_relobj::attributes_section_data): Likewise. (Mips_relobj::attributes_section_data_): New data member. (Mips_relobj::abiflags_): Likewise. (class Mips_output_section_abiflags): New class. (Target_mips::Target_mips): Initialize attributes_section_data_, abiflags_ and has_abiflags_section_. (Target_mips::do_should_include_section): Don't emit input .MIPS.abiflags sections to output .MIPS.abiflags. (Target_mips::Mips_mach): Add new enum constants. (Target_mips::mips_isa_ext_mach): New method. (Target_mips::mips_isa_ext): Likewise. (Target_mips::update_abiflags_isa): Likewise. (Target_mips::infer_abiflags): Likewise. (Target_mips::create_abiflags): Likewise. (Target_mips::fp_abi_string): Likewise. (Target_mips::select_fp_abi): Likewise. (Target_mips::merge_obj_attributes): Likewise. (Target_mips::merge_obj_abiflags): Likewise. (Target_mips::level_rev): Likewise. (Target_mips::merge_obj_e_flags): Rename from merge_processor_specific_flags. Remove dyn_obj argument, call update_abiflags_isa when needed, compare NaN encodings and compare FP64 state. (Target_mips::add_machine_extensions): Add two machine extensions and fix one. (Target_mips::attributes_section_data_): New data member. (Target_mips::abiflags_): Likewise. (Target_mips::has_abiflags_section_): Likewise. (Mips_relobj::do_read_symbols): Read .gnu.attributes and .MIPS.abiflags sections if they exists. (Target_mips::elf_mips_mach): Add E_MIPS_MACH_5900 and E_MIPS_MACH_OCTEON3 support. (Target_mips::do_adjust_elf_header): Setup EI_ABIVERSION flag. (Target_mips::do_finalize_sections): Merge .gnu.attributes and .MIPS.abiflags sections from input. Create these sections if needed. (Target_mips::elf_mips_mach_name): Add E_MIPS_MACH_5900 and E_MIPS_MACH_OCTEON3 support, and change strings for E_MIPS_MACH_LS2E, E_MIPS_MACH_LS2F and E_MIPS_MACH_LS3A just to match bfd.
2016-06-11 00:50:13 +02:00
// ABI related flags section.
SHT_MIPS_ABIFLAGS = 0x7000002a,
// AARCH64-specific section type.
SHT_AARCH64_ATTRIBUTES = 0x70000003,
// Link editor is to sort the entries in this section based on the
// address specified in the associated symbol table entry.
SHT_ORDERED = 0x7fffffff
2006-08-05 01:10:59 +02:00
};
// The valid bit flags found in the Shdr sh_flags field.
2006-09-25 23:29:06 +02:00
enum SHF
2006-08-05 01:10:59 +02:00
{
SHF_WRITE = 0x1,
SHF_ALLOC = 0x2,
SHF_EXECINSTR = 0x4,
SHF_MERGE = 0x10,
SHF_STRINGS = 0x20,
SHF_INFO_LINK = 0x40,
SHF_LINK_ORDER = 0x80,
SHF_OS_NONCONFORMING = 0x100,
SHF_GROUP = 0x200,
SHF_TLS = 0x400,
SHF_COMPRESSED = 0x800,
2006-08-05 01:10:59 +02:00
SHF_MASKOS = 0x0ff00000,
SHF_MASKPROC = 0xf0000000,
// Indicates this section requires ordering in relation to
// other sections of the same type. Ordered sections are
// combined within the section pointed to by the sh_link entry.
// The sh_info values SHN_BEFORE and SHN_AFTER imply that the
// sorted section is to precede or follow, respectively, all
// other sections in the set being ordered.
SHF_ORDERED = 0x40000000,
// This section is excluded from input to the link-edit of an
// executable or shared object. This flag is ignored if SHF_ALLOC
// is also set, or if relocations exist against the section.
SHF_EXCLUDE = 0x80000000,
// Section with data that is GP relative addressable.
SHF_MIPS_GPREL = 0x10000000,
// x86_64 specific large section.
SHF_X86_64_LARGE = 0x10000000
2006-08-05 01:10:59 +02:00
};
// Values which appear in the first Elf_WXword of the section data
// of a SHF_COMPRESSED section.
enum
{
ELFCOMPRESS_ZLIB = 1,
ELFCOMPRESS_LOOS = 0x60000000,
ELFCOMPRESS_HIOS = 0x6fffffff,
ELFCOMPRESS_LOPROC = 0x70000000,
ELFCOMPRESS_HIPROC = 0x7fffffff,
};
2006-08-05 01:10:59 +02:00
// Bit flags which appear in the first 32-bit word of the section data
// of a SHT_GROUP section.
enum
{
GRP_COMDAT = 0x1,
GRP_MASKOS = 0x0ff00000,
GRP_MASKPROC = 0xf0000000
};
2006-09-25 23:29:06 +02:00
// The valid values found in the Phdr p_type field.
enum PT
{
PT_NULL = 0,
PT_LOAD = 1,
PT_DYNAMIC = 2,
PT_INTERP = 3,
PT_NOTE = 4,
PT_SHLIB = 5,
PT_PHDR = 6,
PT_TLS = 7,
PT_LOOS = 0x60000000,
PT_HIOS = 0x6fffffff,
PT_LOPROC = 0x70000000,
PT_HIPROC = 0x7fffffff,
// The remaining values are not in the standard.
// Frame unwind information.
PT_GNU_EH_FRAME = 0x6474e550,
PT_SUNW_EH_FRAME = 0x6474e550,
// Stack flags.
PT_GNU_STACK = 0x6474e551,
// Read only after relocation.
PT_GNU_RELRO = 0x6474e552,
// Platform architecture compatibility information
PT_ARM_ARCHEXT = 0x70000000,
// Exception unwind tables
PT_ARM_EXIDX = 0x70000001,
// Register usage information. Identifies one .reginfo section.
PT_MIPS_REGINFO =0x70000000,
// Runtime procedure table.
PT_MIPS_RTPROC = 0x70000001,
// .MIPS.options section.
PT_MIPS_OPTIONS = 0x70000002,
[MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions Specification: https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking include/ * elf/mips.h (PT_MIPS_ABIFLAGS, SHT_MIPS_ABIFLAGS): Define. (Val_GNU_MIPS_ABI_FP_OLD_64): Rename from Val_GNU_MIPS_ABI_FP_64. (Val_GNU_MIPS_ABI_FP_64): Redefine. (Val_GNU_MIPS_ABI_FP_XX): Define. (Elf_External_ABIFlags_v0, Elf_Internal_ABIFlags_v0): New structures. (AFL_REG_NONE, AFL_REG_32, AFL_REG_64, AFL_REG_128): Define. (AFL_ASE_DSP, AFL_ASE_DSPR2, AFL_ASE_EVA, AFL_ASE_MCU): Likewise. (AFL_ASE_MDMX, AFL_ASE_MIPS3D, AFL_ASE_MT, AFL_ASE_SMARTMIPS): Likewise. (AFL_ASE_VIRT, AFL_ASE_MSA, AFL_ASE_MIPS16): Likewise. (AFL_ASE_MICROMIPS, AFL_ASE_XPA): Likewise. (AFL_EXT_XLR, AFL_EXT_OCTEON2, AFL_EXT_OCTEONP): Likewise. (AFL_EXT_LOONGSON_3A, AFL_EXT_OCTEON, AFL_EXT_5900): Likewise. (AFL_EXT_4650, AFL_EXT_4010, AFL_EXT_4100, AFL_EXT_3900): Likewise. (AFL_EXT_10000, AFL_EXT_SB1, AFL_EXT_4111, AFL_EXT_4120): Likewise. (AFL_EXT_5400, AFL_EXT_5500, AFL_EXT_LOONGSON_2E): Likewise. (AFL_EXT_LOONGSON_2F): Likewise. (bfd_mips_elf_swap_abiflags_v0_in): Prototype. (bfd_mips_elf_swap_abiflags_v0_out): Likewise. (bfd_mips_isa_ext): Likewise. bfd/ * elfxx-mips.c (ABI_O32_P, MIPS_ELF_ABIFLAGS_SECTION_NAME_P): New macro. (mips_elf_obj_tdata): Add abiflags and abiflags_valid fields. (bfd_mips_elf_swap_abiflags_v0_in): New function. (bfd_mips_elf_swap_abiflags_v0_out): Likewise. (_bfd_mips_elf_section_from_shdr): Handle SHT_MIPS_ABIFLAGS. (_bfd_mips_elf_fake_sections): Likewise. (_bfd_mips_elf_always_size_sections): Handle .MIPS.abiflags. (_bfd_mips_elf_additional_program_headers): Account for new PT_MIPS_ABIFLAGS program header. (_bfd_mips_elf_modify_segment_map): Create PT_MIPS_ABIFLAGS segment and associate with .MIPS.abiflags. (_bfd_mips_elf_gc_mark_extra_sections): New function. (bfd_mips_isa_ext, update_mips_abiflags_isa): New static function. (infer_mips_abiflags): Likewise. (_bfd_mips_elf_final_link): Handle .MIPS.abiflags. (mips_32bit_flags_p): Moved higher. (mips_elf_merge_obj_attributes, _bfd_mips_fp_abi_string): Error checking for FP ABIs. (_bfd_mips_elf_merge_private_bfd_data): Restructure and add abiflags checks. Check EF_MIPS_FP64 flag consistency. (print_mips_ases, print_mips_isa_ext): New static function. (print_mips_fp_abi_value, get_mips_reg_size): Likewise. (_bfd_mips_elf_print_private_bfd_data): Display abiflags data. (_bfd_mips_post_process_headers): Set EI_ABIVERSION = 3 for Val_GNU_MIPS_ABI_FP_64 or Val_GNU_MIPS_ABI_FP_64A. * elfxx-mips.h (_bfd_mips_elf_gc_mark_extra_sections): New prototype. * elf32-mips.c (elf_backend_gc_mark_extra_sections): Implement. * elfn32-mips.c (elf_backend_gc_mark_extra_sections): Implement. * elf64-mips.c (elf_backend_gc_mark_extra_sections): Implement. binutils/ * readelf.c (get_mips_segment_type): Display name for PT_MIPS_ABIFLAGS. (get_mips_section_type_name): Display name for SHT_MIPS_ABIFLAGS. (display_mips_gnu_attribute): Abstracted fp abi printing to... (print_mips_fp_abi_value): New static function. Handle new FP ABIs. (print_mips_ases, print_mips_isa_ext): New static functions. (get_mips_reg_size): Likewise. (process_mips_specific): Display abiflags data. elfcpp/ * elfcpp.h (PT_MIPS_ABIFLAGS): New program header type. gas/ * config/tc-mips.c (mips_flags_frag): New static global. (struct mips_set_options): Add oddspreg field. (file_mips_opts, mips_opts): Initialize oddspreg. (ISA_HAS_ODD_SINGLE_FPR): Add CPU argument and update for R5900 and Loongson-3a. (enum options, md_longopts, md_parse_option): Add -mfpxx, -modd-spreg and -mno-odd-spreg options. (md_begin): Create .MIPS.abiflags section. (fpabi_incompatible_with, fpabi_requires): New static function. (check_fpabi): Likewise. (mips_check_options): Handle fp=xx and oddspreg restrictions. (file_mips_check_options): Set oddspreg by default for fp=xx. (mips_oddfpreg_ok): Re-write function. (check_regno): Check odd numbered registers regardless of FPR size. For fp != 32 use as_bad instead of as_warn. (match_float_constant): Rewrite check regarding FP register width. Add support for generating constants when MXHC1 is present. Handle fp=xx to comply with the ABI. (macro): Update M_LI_DD similarly to match_float_constant. Generate MTHC1 when available. Check that correct code can be generated for fp=xx and fp=64 ABIs. (parse_code_option, s_mipsset): Add fp=xx, oddspreg and nooddspreg options. (mips_convert_ase_flags): New static function. (mips_elf_final_processing): Use fpabi == Val_GNU_MIPS_ABI_FP_OLD_64 to determine when to add the EF_MIPS_FP64 flag. Populate the .MIPS.abiflags section. (md_mips_end): Update .gnu_attribute based on command line and .module as applicable. Use check_fpabi to ensure .gnu.attribute and command line/.module options are consistent. * doc/as.texinfo: Add missing -mgp64/-mfp64 options and document new -mfpxx, -modd-spreg and -mno-odd-spreg options. * doc/c-mips.texi: Document -mfpxx, -modd-spreg, -mno-odd-spreg, gnu_attribute values and FP ABIs. ld/ * emulparams/elf32bmip.sh: Add .MIPS.abiflags. * emulparams/elf32bmipn32-defs.sh: Likewise. * emulparams/elf64bmip-defs.sh: Likewise. opcodes/ * micromips-opc.c (COD, LCD) New macros. (cfc1, ctc1): Remove FP_S attribute. (dmfc1, mfc1, mfhc1): Add LCD attribute. (dmtc1, mtc1, mthc1): Add COD attribute. * mips-opc.c (cfc1, cftc1, ctc, cttc1): Remove FP_S attribute. binutils/testsuite/ * binutils-all/readelf.s: Account for .MIPS.abiflags and .gnu.attributes. * binutils-all/readelf.ss-tmips: Likewise. * binutils-all/strip-3.d: Likewise. gas/testsuite/ * gas/mips/attr-gnu-4-0.d: New. * gas/mips/attr-gnu-4-0.s: Likewise. * gas/mips/attr-gnu-4-1-mfp32.l: Likewise. * gas/mips/attr-gnu-4-1-mfp32.s: Likewise. * gas/mips/attr-gnu-4-1-mfp64.l: Likewise. * gas/mips/attr-gnu-4-1-mfp64.s: Likewise. * gas/mips/attr-gnu-4-1-mfpxx.s: Likewise. * gas/mips/attr-gnu-4-1-msingle-float.l: Likewise. * gas/mips/attr-gnu-4-1-msingle-float.s: Likewise. * gas/mips/attr-gnu-4-1-msoft-float.l: Likewise. * gas/mips/attr-gnu-4-1-msoft-float.s: Likewise. * gas/mips/attr-gnu-4-1.d: Likewise. * gas/mips/attr-gnu-4-1.s: Likewise. * gas/mips/attr-gnu-4-2-mdouble-float.l: Likewise. * gas/mips/attr-gnu-4-2-mdouble-float.s: Likewise. * gas/mips/attr-gnu-4-2-msoft-float.l: Likewise. * gas/mips/attr-gnu-4-2-msoft-float.s: Likewise. * gas/mips/attr-gnu-4-2.d: Likewise. * gas/mips/attr-gnu-4-2.s: Likewise. * gas/mips/attr-gnu-4-3-mhard-float.l: Likewise. * gas/mips/attr-gnu-4-3-mhard-float.s: Likewise. * gas/mips/attr-gnu-4-3.d: Likewise. * gas/mips/attr-gnu-4-3.s: Likewise. * gas/mips/attr-gnu-4-4.l: Likewise. * gas/mips/attr-gnu-4-4.s: Likewise. * gas/mips/attr-gnu-4-5-64.l: Likewise. * gas/mips/attr-gnu-4-5-64.s: Likewise. * gas/mips/attr-gnu-4-5.d: Likewise. * gas/mips/attr-gnu-4-5.l: Likewise. * gas/mips/attr-gnu-4-5.s: Likewise. * gas/mips/attr-gnu-4-6-64.l: Likewise. * gas/mips/attr-gnu-4-6-64.s: Likewise. * gas/mips/attr-gnu-4-6.d: Likewise. * gas/mips/attr-gnu-4-6.l: Likewise. * gas/mips/attr-gnu-4-6.s: Likewise. * gas/mips/attr-gnu-4-6-msingle-float.l: Likewise. * gas/mips/attr-gnu-4-6-msingle-float.s: Likewise. * gas/mips/attr-gnu-4-6-msoft-float.l: Likewise. * gas/mips/attr-gnu-4-6-msoft-float.s: Likewise. * gas/mips/attr-gnu-4-6-noodd.l: Likewise. * gas/mips/attr-gnu-4-6-noodd.s: Likewise. * gas/mips/attr-gnu-4-7-64.l: Likewise. * gas/mips/attr-gnu-4-7-64.s: Likewise. * gas/mips/attr-gnu-4-7-msingle-float.l: Likewise. * gas/mips/attr-gnu-4-7-msingle-float.s: Likewise. * gas/mips/attr-gnu-4-7-msoft-float.l: Likewise. * gas/mips/attr-gnu-4-7-msoft-float.s: Likewise. * gas/mips/attr-gnu-4-7-odd.l: Likewise. * gas/mips/attr-gnu-4-7-odd.s: Likewise. * gas/mips/attr-gnu-4-7.d: Likewise. * gas/mips/attr-gnu-4-7.l: Likewise. * gas/mips/attr-gnu-4-7.s: Likewise. * gas/mips/attr-none-double.d: Likewise. * gas/mips/attr-none-o32-fp64.d: Likewise. * gas/mips/attr-none-o32-fp64-nooddspreg.d * gas/mips/attr-none-o32-fpxx.d: Likewise. * gas/mips/attr-none-single-float.d: Likewise. * gas/mips/attr-none-soft-float.d: Likewise. * gas/mips/elf_arch_mips32r3.d: Likewise. * gas/mips/elf_arch_mips32r5.d: Likewise. * gas/mips/elf_arch_mips64r3.d: Likewise. * gas/mips/elf_arch_mips64r5.d: Likewise. * gas/mips/li-d.d: Likewise. * gas/mips/li-d.s: Likewise. * gas/mips/module-check-warn.l: Likewise. * gas/mips/module-check-warn.s: Likewise. * gas/mips/module-check.d: Likewise. * gas/mips/module-check.s: Likewise. * gas/mips/module-mfp32.d: Likewise. * gas/mips/module-mfp32.s: Likewise. * gas/mips/module-mfp64.d: Likewise. * gas/mips/module-mfp64.s: Likewise. * gas/mips/module-mfp64-noodd.d: Likewise. * gas/mips/module-mfp64-noodd.s: Likewise. * gas/mips/module-mfpxx.d: Likewise. * gas/mips/module-mfpxx.s: Likewise. * gas/mips/module-msingle-float.d: Likewise. * gas/mips/module-msingle-float.s: Likewise. * gas/mips/module-msoft-float.d: Likewise. * gas/mips/module-msoft-float.s: Likewise. * gas/mips/module-set-mfpxx.d: Likewise. * gas/mips/module-set-mfpxx.s: Likewise. * gas/mips/fpxx-oddfpreg.d: Likewise. * gas/mips/fpxx-oddfpreg.l: Likewise. * gas/mips/fpxx-oddfpreg.s: Likewise. * gas/mips/no-odd-spreg.d: Likewise. * gas/mips/odd-spreg.d: Likewise. * gas/elf/section2.e-mips: Adjust expected output. * gas/mips/attr-gnu-abi-fp-1.d: Likewise. * gas/mips/attr-gnu-abi-msa-1.d: Likewise. * gas/mips/call-nonpic-1.d: Likewise. * gas/mips/elf_arch_mips1.d: Likewise. * gas/mips/elf_arch_mips2.d: Likewise. * gas/mips/elf_arch_mips3.d: Likewise. * gas/mips/elf_arch_mips32.d: Likewise. * gas/mips/elf_arch_mips32r2.d: Likewise. * gas/mips/elf_arch_mips4.d: Likewise. * gas/mips/elf_arch_mips5.d: Likewise. * gas/mips/elf_arch_mips64.d: Likewise. * gas/mips/elf_arch_mips64r2.d: Likewise. * gas/mips/elf_ase_micromips-2.d: Likewise. * gas/mips/elf_ase_micromips.d: Likewise. * gas/mips/elf_ase_mips16-2.d: Likewise. * gas/mips/elf_ase_mips16.d: Likewise. * gas/mips/module-defer-warn1.d: Likewise. * gas/mips/module-override.d: Likewise. * gas/mips/n32-consec.d: Likewise. * gas/mips/nan-2008-1.d: Likewise. * gas/mips/nan-2008-2.d: Likewise. * gas/mips/nan-2008-3.d: Likewise. * gas/mips/nan-2008-4.d: Likewise. * gas/mips/nan-legacy-1.d: Likewise. * gas/mips/nan-legacy-2.d: Likewise. * gas/mips/nan-legacy-3.d: Likewise. * gas/mips/nan-legacy-4.d: Likewise. * gas/mips/nan-legacy-5.d: Likewise. * gas/mips/tmips16-e.d: Likewise. * gas/mips/tmips16-f.d: Likewise. * gas/mips/tmipsel16-e.d: Likewise. * gas/mips/tmipsel16-f.d: Likewise. * gas/testsuite/gas/mips/mips.exp: Add new tests. ld/testsuite/ * ld-mips-elf/abiflags-strip1-ph.d: New. * ld-mips-elf/abiflags-strip2-ph.d: Likewise. * ld-mips-elf/abiflags-strip3-ph.d: Likewise. * ld-mips-elf/abiflags-strip4-ph.d: Likewise. * ld-mips-elf/abiflags-strip5-ph.d: Likewise. * ld-mips-elf/abiflags-strip6-ph.d: Likewise. * ld-mips-elf/abiflags-strip7-ph.d: Likewise. * ld-mips-elf/abiflags-strip8-ph.d: Likewise. * ld-mips-elf/abiflags-strip9-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-0-n32-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-0-n64-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-0-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-06.d: Likewise. * ld-mips-elf/attr-gnu-4-07.d: Likewise. * ld-mips-elf/attr-gnu-4-08.d: Likewise. * ld-mips-elf/attr-gnu-4-1-n32-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-1-n64-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-1-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-16.d: Likewise. * ld-mips-elf/attr-gnu-4-17.d: Likewise. * ld-mips-elf/attr-gnu-4-18.d: Likewise. * ld-mips-elf/attr-gnu-4-2-n32-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-2-n64-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-2-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-26.d: Likewise. * ld-mips-elf/attr-gnu-4-27.d: Likewise. * ld-mips-elf/attr-gnu-4-28.d: Likewise. * ld-mips-elf/attr-gnu-4-3-n32-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-3-n64-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-3-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-36.d: Likewise. * ld-mips-elf/attr-gnu-4-37.d: Likewise. * ld-mips-elf/attr-gnu-4-38.d: Likewise. * ld-mips-elf/attr-gnu-4-4-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-46.d: Likewise. * ld-mips-elf/attr-gnu-4-47.d: Likewise. * ld-mips-elf/attr-gnu-4-48.d: Likewise. * ld-mips-elf/attr-gnu-4-5-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-50.d: Likewise. * ld-mips-elf/attr-gnu-4-52.d: Likewise. * ld-mips-elf/attr-gnu-4-53.d: Likewise. * ld-mips-elf/attr-gnu-4-54.d: Likewise. * ld-mips-elf/attr-gnu-4-55.d: Likewise. * ld-mips-elf/attr-gnu-4-56.d: Likewise. * ld-mips-elf/attr-gnu-4-57.d: Likewise. * ld-mips-elf/attr-gnu-4-58.d: Likewise. * ld-mips-elf/attr-gnu-4-6-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-6.s: Likewise. * ld-mips-elf/attr-gnu-4-60.d: Likewise. * ld-mips-elf/attr-gnu-4-61.d: Likewise. * ld-mips-elf/attr-gnu-4-62.d: Likewise. * ld-mips-elf/attr-gnu-4-63.d: Likewise. * ld-mips-elf/attr-gnu-4-64.d: Likewise. * ld-mips-elf/attr-gnu-4-65.d: Likewise. * ld-mips-elf/attr-gnu-4-66.d: Likewise. * ld-mips-elf/attr-gnu-4-67.d: Likewise. * ld-mips-elf/attr-gnu-4-68.d: Likewise. * ld-mips-elf/attr-gnu-4-7-ph.d: Likewise. * ld-mips-elf/attr-gnu-4-7.s: Likewise. * ld-mips-elf/attr-gnu-4-70.d: Likewise. * ld-mips-elf/attr-gnu-4-71.d: Likewise. * ld-mips-elf/attr-gnu-4-72.d: Likewise. * ld-mips-elf/attr-gnu-4-73.d: Likewise. * ld-mips-elf/attr-gnu-4-74.d: Likewise. * ld-mips-elf/attr-gnu-4-75.d: Likewise. * ld-mips-elf/attr-gnu-4-76.d: Likewise. * ld-mips-elf/attr-gnu-4-77.d: Likewise. * ld-mips-elf/attr-gnu-4-78.d: Likewise. * ld-mips-elf/attr-gnu-4-8.s: Likewise. * ld-mips-elf/attr-gnu-4-81.d: Likewise. * ld-mips-elf/empty.s: Likewise. * ld-mips-elf/attr-gnu-4-00.d: Adjust expected output. * ld-mips-elf/attr-gnu-4-01.d: Likewise. * ld-mips-elf/attr-gnu-4-02.d: Likewise. * ld-mips-elf/attr-gnu-4-03.d: Likewise. * ld-mips-elf/attr-gnu-4-04.d: Likewise. * ld-mips-elf/attr-gnu-4-05.d: Likewise. * ld-mips-elf/attr-gnu-4-10.d: Likewise. * ld-mips-elf/attr-gnu-4-11.d: Likewise. * ld-mips-elf/attr-gnu-4-14.d: Likewise. * ld-mips-elf/attr-gnu-4-15.d: Likewise. * ld-mips-elf/attr-gnu-4-2.s: Likewise. * ld-mips-elf/attr-gnu-4-20.d: Likewise. * ld-mips-elf/attr-gnu-4-22.d: Likewise. * ld-mips-elf/attr-gnu-4-24.d: Likewise. * ld-mips-elf/attr-gnu-4-25.d: Likewise. * ld-mips-elf/attr-gnu-4-3.s: Likewise. * ld-mips-elf/attr-gnu-4-30.d: Likewise. * ld-mips-elf/attr-gnu-4-33.d: Likewise. * ld-mips-elf/attr-gnu-4-34.d: Likewise. * ld-mips-elf/attr-gnu-4-35.d: Likewise. * ld-mips-elf/attr-gnu-4-40.d: Likewise. * ld-mips-elf/attr-gnu-4-41.d: Likewise. * ld-mips-elf/attr-gnu-4-42.d: Likewise. * ld-mips-elf/attr-gnu-4-43.d: Likewise. * ld-mips-elf/attr-gnu-4-44.d: Likewise. * ld-mips-elf/attr-gnu-4-45.d: Likewise. * ld-mips-elf/attr-gnu-4-5.s: Likewise. * ld-mips-elf/attr-gnu-4-51.d: Likewise. * ld-mips-elf/attr-gnu-8-00.d: Likewise. * ld-mips-elf/attr-gnu-8-01.d: Likewise. * ld-mips-elf/attr-gnu-8-02.d: Likewise. * ld-mips-elf/attr-gnu-8-10.d: Likewise. * ld-mips-elf/attr-gnu-8-11.d: Likewise. * ld-mips-elf/attr-gnu-8-20.d: Likewise. * ld-mips-elf/attr-gnu-8-22.d: Likewise. * ld-mips-elf/jalx-2.dd: Likewise. * ld-mips-elf/mips16-pic-1.gd: Likewise. * ld-mips-elf/mips16-pic-2.gd: Likewise. * ld-mips-elf/mips16-pic-3.gd: Likewise. * ld-mips-elf/mips16-pic-4a.gd: Likewise. * ld-mips-elf/multi-got-no-shared.d: Likewise. * ld-mips-elf/nan-2008.d: Likewise. * ld-mips-elf/nan-legacy.d: Rework test. * ld-mips-elf/pic-and-nonpic-3a.gd: Likewise. * ld-mips-elf/pic-and-nonpic-3b.gd: Likewise. * ld-mips-elf/pic-and-nonpic-5b.gd: Likewise. * ld-mips-elf/pic-and-nonpic-6.ld: Likewise. * ld-mips-elf/rel32-n32.d: Likewise. * ld-mips-elf/rel32-o32.d: Likewise. * ld-mips-elf/rel64.d: Likewise. * ld-mips-elf/tls-multi-got-1.r: Likewise. * ld-elf/group.ld: Discard .MIPS.abiflags and .gnu.attributes. * ld-elf/orphan-region.ld: Likewise. * ld-elf/orphan.ld: Likewise. * ld-mips-elf/compressed-plt-1.ld: Likewise. * ld-mips-elf/dyn-sec64.ld: Likewise. * ld-mips-elf/got-dump-1.ld: Likewise. * ld-mips-elf/got-dump-2.ld: Likewise. * ld-mips-elf/got-page-1.ld: Likewise. * ld-mips-elf/mips-dyn.ld: Likewise. * ld-mips-elf/mips-lib.ld: Likewise. * ld-mips-elf/pic-and-nonpic-3a.ld: Likewise. * ld-mips-elf/pic-and-nonpic-3b.ld: Likewise. * ld-mips-elf/pic-and-nonpic-4b.ld: Likewise. * ld-mips-elf/pic-and-nonpic-5b.ld: Likewise. * ld-mips-elf/region1.t: Likewise. * ld-mips-elf/stub-dynsym-1.ld: Likewise. * ld-mips-elf/tls-hidden3.ld: Likewise. * ld-mips-elf/vxworks1.ld: Likewise. * ld-scripts/overlay-size.t: Likewise. * ld-mips-elf/elf-rel-got-n32-embed.d: Remove .MIPS.abiflags from objects. * ld-mips-elf/elf-rel-got-n32.d: Likewise. * ld-mips-elf/elf-rel-got-n64-embed.d: Likewise. * ld-mips-elf/elf-rel-got-n64-linux.d: Likewise. * ld-mips-elf/elf-rel-got-n64.d: Likewise. * ld-mips-elf/elf-rel-xgot-n32.d: Likewise. * ld-mips-elf/elf-rel-xgot-n32-embed.d: Likewise. * ld-mips-elf/elf-rel-xgot-n64.d: Likewise. * ld-mips-elf/elf-rel-xgot-n64-linux.d: Likewise. * ld-mips-elf/elf-rel-xgot-n64-embed.d: Likewise. * ld-mips-elf/mips-elf.exp: Add new tests.
2014-07-29 12:27:59 +02:00
// .MIPS.abiflags section.
PT_MIPS_ABIFLAGS = 0x70000003,
// Platform architecture compatibility information
PT_AARCH64_ARCHEXT = 0x70000000,
// Exception unwind tables
PT_AARCH64_UNWIND = 0x70000001,
// 4k page table size
PT_S390_PGSTE = 0x70000000,
2006-09-25 23:29:06 +02:00
};
// The valid bit flags found in the Phdr p_flags field.
enum PF
{
PF_X = 0x1,
PF_W = 0x2,
PF_R = 0x4,
PF_MASKOS = 0x0ff00000,
PF_MASKPROC = 0xf0000000
};
2006-08-05 01:10:59 +02:00
// Symbol binding from Sym st_info field.
enum STB
{
STB_LOCAL = 0,
STB_GLOBAL = 1,
STB_WEAK = 2,
STB_LOOS = 10,
* config/obj-elf.c (obj_elf_type): Add code to support a type of gnu_unique_object. * doc/as.texinfo: Document new feature of .type directive. * NEWS: Mention support for gnu_unique_object symbol type. * common.h (STB_GNU_UNIQUE): Define. * NEWS: Mention the linker's support for symbols with a binding of STB_GNU_UNIQUE. * gas/elf/type.s: Add unique global symbol definition. * gas/elf/type.e: Add expected readelf output for global unique symbol. * elfcpp.h (enum STB): Add STB_GNU_UNIQUE. * readelf.c (get_symbol_binding): For Linux targeted files return UNIQUE for symbols with the STB_GNU_UNIQUE binding. * doc/binutils.texi: Document the meaning of the 'u' symbol binding in the output of nm and objdump --syms. * elf-bfd.h (struct elf_link_hash_entry): Add unique_global field. * elf.c (swap_out_syms): Set binding to STB_GNU_UNIQUE for symbols with the BSF_GNU_UNIQUE flag bit set. * elfcode.h (elf_slurp_symbol_table): Set the BSF_GNU_UNIQUE flag for symbols with STB_GNU_UNIQUE binding. * elflink.c (_bfd_elf_merge_symbol): Set unique_global for symbols with the STB_GNU_UNIQUE binding. (elf_link_add_object_symbols): Set the BSF_GNU_UNIQUE flag for symbols with STB_GNU_UNIQUE binding. Set STB_GNU_UNIQUE for symbols with the unique_global field set. (elf_link_output_extsym): Set unique_global field for symbols with the STB_GNU_UNIQUE binding. * syms.c (struct bfd_symbol): Define BSF_GNU_UNIQUE flag bit. (bfd_print_symbol_vandf): Print a 'u' character for BSF_GNU_UNIQUE symbols. (bfd_decode_symclass): Return a 'u' character for BSF_GNU_UNIQUE symbols. * bfd-in2.h: Regenerate.
2009-07-23 15:00:30 +02:00
STB_GNU_UNIQUE = 10,
2006-08-05 01:10:59 +02:00
STB_HIOS = 12,
STB_LOPROC = 13,
STB_HIPROC = 15
};
// Symbol types from Sym st_info field.
enum STT
{
STT_NOTYPE = 0,
STT_OBJECT = 1,
STT_FUNC = 2,
STT_SECTION = 3,
STT_FILE = 4,
STT_COMMON = 5,
STT_TLS = 6,
// GNU extension: symbol value points to a function which is called
// at runtime to determine the final value of the symbol.
include/elf 2009-04-30 Nick Clifton <nickc@redhat.com> * common.h (STT_GNU_IFUNC): Define. elfcpp 2009-04-30 Nick Clifton <nickc@redhat.com> * (enum STT): Add STT_GNU_IFUNC. gas 2009-04-30 Nick Clifton <nickc@redhat.com> * config/obj-elf.c (obj_elf_type): Add support for a gnu_indirect_function type. * config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups against indirect function symbols. * doc/as.texinfo (.type): Document the support for the gnu_indirect_function symbol type. * NEWS: Mention the new feature. gas/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * gas/elf/elf.exp: Extend type test to include an ifunc symbol. Provide an alternative test for targets which do not support ifunc symbols. (type.s): Add entry for an ifunc symbol. (type.e): Add ifunc entry to expected symbol dump. (section2.e-armelf): Add entry for ifunc symbol. (type-noifunc.s): New file. (type-noifunc.e): New file. bfd/ 2009-04-30 Nick Clifton <nickc@redhat.com> * elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs section pointer. (struct elf_obj_data): Add has_ifunc_symbols boolean. * elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags into a STT_GNU_IFUNC symbol type. (_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function type. (_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if the binary contains ifunc symbols. * elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC symbol type into a BSF_GNU_INDIRECT_FUNCTION flag. * elf32-i386.c (is_indirect_function): New function. (elf_i386_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf_i386_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): New function. Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. (elf_backend_add_symbol_hook): Define. (elf_i386_post_process_headers): Rename to elf_i388_fbsd_post_process_headers. * elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro. (is_indirect_function): New function. (elf64_x86_64_check_relocs): Create an ifunc output section. (allocate_dynrelocs): Create dynamic relocs in the ifunc output section if necessary. (elf64_x86_64_relocate_section): Emit a reloc against an ifunc symbol if necessary. (elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the elf_obj_data structure if an ifunc symbol is encountered. (elf_backend_post_process_headers): Define. * elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT if we have ifunc symbols to handle. (get_ifunc_reloc_section_name): New function. Computes the name for an ifunc section. (_bfd_elf_make_ifunc_reloc_section): New function. Creates a section to hold ifunc relocs. * syms.c (BSF_GNU_INDIRECT_FUNCTION): Define. (bfd_print_symbol_vandf): Handle ifunc symbols. (bfd_decode_symclass): Likewise. * bfd-in2.h: Regenerate. binutils 2009-04-30 Nick Clifton <nickc@redhat.com> * readelf.c (dump_relocations): Display a relocation against an ifunc symbol as if it were a function invocation. (get_symbol_type): Handle STT_GNU_IFUNC. ld 2009-04-30 Nick Clifton <nickc@redhat.com> * NEWS: Mention support for IFUNC symbols. ld/testsuite 2009-04-30 Nick Clifton <nickc@redhat.com> * ld-ifunc: New directory. * ld-ifunc/ifunc.exp: New file: Run the IFUNC tests. * ld-ifunc/prog.c: New file. * ld-ifunc/lib.c: New file.
2009-04-30 17:47:13 +02:00
STT_GNU_IFUNC = 10,
STT_LOOS = 10,
2006-08-05 01:10:59 +02:00
STT_HIOS = 12,
STT_LOPROC = 13,
STT_HIPROC = 15,
// The section type that must be used for register symbols on
// Sparc. These symbols initialize a global register.
STT_SPARC_REGISTER = 13,
// ARM: a THUMB function. This is not defined in ARM ELF Specification but
// used by the GNU tool-chain.
STT_ARM_TFUNC = 13
2006-08-05 01:10:59 +02:00
};
inline STB
elf_st_bind(unsigned char info)
{
return static_cast<STB>(info >> 4);
}
inline STT
elf_st_type(unsigned char info)
{
return static_cast<STT>(info & 0xf);
}
inline unsigned char
elf_st_info(STB bind, STT type)
{
return ((static_cast<unsigned char>(bind) << 4)
+ (static_cast<unsigned char>(type) & 0xf));
}
2006-08-05 01:10:59 +02:00
// Symbol visibility from Sym st_other field.
enum STV
{
STV_DEFAULT = 0,
STV_INTERNAL = 1,
STV_HIDDEN = 2,
STV_PROTECTED = 3
};
inline STV
elf_st_visibility(unsigned char other)
{
return static_cast<STV>(other & 0x3);
}
inline unsigned char
elf_st_nonvis(unsigned char other)
{
return static_cast<STV>(other >> 2);
}
2006-09-07 23:21:41 +02:00
inline unsigned char
elf_st_other(STV vis, unsigned char nonvis)
{
return ((nonvis << 2)
+ (static_cast<unsigned char>(vis) & 3));
}
// Reloc information from Rel/Rela r_info field.
template<int size>
unsigned int
elf_r_sym(typename Elf_types<size>::Elf_WXword);
template<>
inline unsigned int
elf_r_sym<32>(Elf_Word v)
{
return v >> 8;
}
template<>
inline unsigned int
elf_r_sym<64>(Elf_Xword v)
{
return v >> 32;
}
template<int size>
unsigned int
elf_r_type(typename Elf_types<size>::Elf_WXword);
template<>
inline unsigned int
elf_r_type<32>(Elf_Word v)
{
return v & 0xff;
}
template<>
inline unsigned int
elf_r_type<64>(Elf_Xword v)
{
return v & 0xffffffff;
}
template<int size>
typename Elf_types<size>::Elf_WXword
elf_r_info(unsigned int s, unsigned int t);
template<>
inline Elf_Word
elf_r_info<32>(unsigned int s, unsigned int t)
{
return (s << 8) + (t & 0xff);
}
template<>
inline Elf_Xword
elf_r_info<64>(unsigned int s, unsigned int t)
{
return (static_cast<Elf_Xword>(s) << 32) + (t & 0xffffffff);
}
// Dynamic tags found in the PT_DYNAMIC segment.
enum DT
{
DT_NULL = 0,
DT_NEEDED = 1,
DT_PLTRELSZ = 2,
DT_PLTGOT = 3,
DT_HASH = 4,
DT_STRTAB = 5,
DT_SYMTAB = 6,
DT_RELA = 7,
DT_RELASZ = 8,
DT_RELAENT = 9,
DT_STRSZ = 10,
DT_SYMENT = 11,
DT_INIT = 12,
DT_FINI = 13,
DT_SONAME = 14,
DT_RPATH = 15,
DT_SYMBOLIC = 16,
DT_REL = 17,
DT_RELSZ = 18,
DT_RELENT = 19,
DT_PLTREL = 20,
DT_DEBUG = 21,
DT_TEXTREL = 22,
DT_JMPREL = 23,
DT_BIND_NOW = 24,
DT_INIT_ARRAY = 25,
DT_FINI_ARRAY = 26,
DT_INIT_ARRAYSZ = 27,
DT_FINI_ARRAYSZ = 28,
DT_RUNPATH = 29,
DT_FLAGS = 30,
2009-10-30 Doug Kwan <dougkwan@google.com> elfcpp/ChangeLog: * 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. gold/ChangeLog: * arm.cc (Arm_relobj::processor_specific_flags): New method definition. (Arm_relobj::do_read_symbols): New method declaration. (Arm_relobj::processor_specific_flags_): New data member declaration. (Arm_dynobj): New class definition. (Target_arm::do_finalize_sections): Add input_objects parameter. (Target_arm::do_adjust_elf_header): New method declaration. (Target_arm::are_eabi_versions_compatible, (Target_arm::merge_processor_specific_flags): New method declaration. (Target_arm::do_make_elf_object): New overloaded method definitions and declaration. (Arm_relobj::do_read_symbols): New method definition. (Arm_dynobj::do_read_symbols): Ditto. (Target_arm::do_finalize_sections): Add input_objects parameters. Merge processor-specific flags from all input objects. (Target_arm::are_eabi_versions_compatible, Target_arm::merge_processor_specific_flags, Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object): New method definitions. * i386.cc (Target_i386::do_finalize_sections): Add unnamed Input_objects pointer type parameter. * layout.cc (Layout::finalize): Pass input objects to target's. finalize_sections function. * output.cc (Output_file_header::do_sized_write): Set ELF file header's processor-specific flags. * powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed Input_objects pointer type parameter. * sparc.cc (Target_sparc::do_finalize_sections): Same. * target.h (Input_objects): New forward class declaration. (Target::processor_specific_flags, Target::are_processor_specific_flags_sect): New method definitions. (Target::finalize_sections): Add input_objects parameter. (Target::Target): Initialize processor_specific_flags_ and are_processor_specific_flags_set_. (Target::do_finalize_sections): Add unnamed Input_objects pointer type parameter. (Target::set_processor_specific_flags): New method definition. (Target::processor_specific_flags_, Target::are_processor_specific_flags_set_): New data member declarations. * x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed Input_objects pointer type parameter.
2009-10-30 19:49:59 +01:00
// This is used to mark a range of dynamic tags. It is not really
// a tag value.
DT_ENCODING = 32,
2009-10-30 Doug Kwan <dougkwan@google.com> elfcpp/ChangeLog: * 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. gold/ChangeLog: * arm.cc (Arm_relobj::processor_specific_flags): New method definition. (Arm_relobj::do_read_symbols): New method declaration. (Arm_relobj::processor_specific_flags_): New data member declaration. (Arm_dynobj): New class definition. (Target_arm::do_finalize_sections): Add input_objects parameter. (Target_arm::do_adjust_elf_header): New method declaration. (Target_arm::are_eabi_versions_compatible, (Target_arm::merge_processor_specific_flags): New method declaration. (Target_arm::do_make_elf_object): New overloaded method definitions and declaration. (Arm_relobj::do_read_symbols): New method definition. (Arm_dynobj::do_read_symbols): Ditto. (Target_arm::do_finalize_sections): Add input_objects parameters. Merge processor-specific flags from all input objects. (Target_arm::are_eabi_versions_compatible, Target_arm::merge_processor_specific_flags, Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object): New method definitions. * i386.cc (Target_i386::do_finalize_sections): Add unnamed Input_objects pointer type parameter. * layout.cc (Layout::finalize): Pass input objects to target's. finalize_sections function. * output.cc (Output_file_header::do_sized_write): Set ELF file header's processor-specific flags. * powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed Input_objects pointer type parameter. * sparc.cc (Target_sparc::do_finalize_sections): Same. * target.h (Input_objects): New forward class declaration. (Target::processor_specific_flags, Target::are_processor_specific_flags_sect): New method definitions. (Target::finalize_sections): Add input_objects parameter. (Target::Target): Initialize processor_specific_flags_ and are_processor_specific_flags_set_. (Target::do_finalize_sections): Add unnamed Input_objects pointer type parameter. (Target::set_processor_specific_flags): New method definition. (Target::processor_specific_flags_, Target::are_processor_specific_flags_set_): New data member declarations. * x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed Input_objects pointer type parameter.
2009-10-30 19:49:59 +01:00
DT_PREINIT_ARRAY = 32,
DT_PREINIT_ARRAYSZ = 33,
DT_LOOS = 0x6000000d,
DT_HIOS = 0x6ffff000,
DT_LOPROC = 0x70000000,
DT_HIPROC = 0x7fffffff,
// The remaining values are extensions used by GNU or Solaris.
DT_VALRNGLO = 0x6ffffd00,
DT_GNU_PRELINKED = 0x6ffffdf5,
DT_GNU_CONFLICTSZ = 0x6ffffdf6,
DT_GNU_LIBLISTSZ = 0x6ffffdf7,
DT_CHECKSUM = 0x6ffffdf8,
DT_PLTPADSZ = 0x6ffffdf9,
DT_MOVEENT = 0x6ffffdfa,
DT_MOVESZ = 0x6ffffdfb,
DT_FEATURE = 0x6ffffdfc,
DT_POSFLAG_1 = 0x6ffffdfd,
DT_SYMINSZ = 0x6ffffdfe,
DT_SYMINENT = 0x6ffffdff,
DT_VALRNGHI = 0x6ffffdff,
DT_ADDRRNGLO = 0x6ffffe00,
DT_GNU_HASH = 0x6ffffef5,
DT_TLSDESC_PLT = 0x6ffffef6,
DT_TLSDESC_GOT = 0x6ffffef7,
DT_GNU_CONFLICT = 0x6ffffef8,
DT_GNU_LIBLIST = 0x6ffffef9,
DT_CONFIG = 0x6ffffefa,
DT_DEPAUDIT = 0x6ffffefb,
DT_AUDIT = 0x6ffffefc,
DT_PLTPAD = 0x6ffffefd,
DT_MOVETAB = 0x6ffffefe,
DT_SYMINFO = 0x6ffffeff,
DT_ADDRRNGHI = 0x6ffffeff,
DT_RELACOUNT = 0x6ffffff9,
DT_RELCOUNT = 0x6ffffffa,
DT_FLAGS_1 = 0x6ffffffb,
DT_VERDEF = 0x6ffffffc,
DT_VERDEFNUM = 0x6ffffffd,
DT_VERNEED = 0x6ffffffe,
DT_VERNEEDNUM = 0x6fffffff,
DT_VERSYM = 0x6ffffff0,
// Specify the value of _GLOBAL_OFFSET_TABLE_.
DT_PPC_GOT = 0x70000000,
[GOLD] PowerPC tls_get_addr_optimize This implements the special __tls_get_addr_opt call stub for powerpc gold that returns __thread variable addresses without actually making a call to __tls_get_addr in most cases. Shared libraries that are loaded at program load time (ie. dlopen is not used) have a known layout for their __thread variables, and thus DTPMOD64/DPTREL64 pairs describing those variables can be set up by ld.so for the __tls_get_addr_opt call stub fast exit. Ref https://sourceware.org/ml/libc-alpha/2015-03/msg00626.html I really, really wish I'd used a differently versioned __tls_get_addr symbol than the base symbol to indicate glibc support for the optimized call, rather than having glibc export __tls_get_addr_opt. A lot of the messing around here, flipping symbols from __tls_get_addr to __tls_get_addr_opt, is caused by that decision. About the only benefit is that a user can see at a glance that their disassembled code is calling __tls_get_addr via the fancy call stub.. Anyway, we need references to __tls_get_addr to seem like they were to __tls_get_addr_opt, and in cases like the tsan interceptor, a definition of __tls_get_addr to seem like one of __tls_get_addr_opt as well. That's the reason for Symbol::clear_in_reg and Symbol_table::clone, and why symbols are substituted in Scan::global and other places dealing with dynamic linking. elfcpp/ * elfcpp.h (DT_PPC_OPT): Define. * powerpc.h (PPC_OPT_TLS): Define. gold/ * options.h (tls_get_addr_optimize): New option. * symtab.h (Symbol::clear_in_reg, clone): New functions. (Sized_symbol::clone): New function. (Symbol_table::clone): New function. * resolve.cc (Symbol::clone, Sized_symbol::clone): New functions. * powerpc.cc (Target_powerpc::has_tls_get_addr_opt_, tls_get_addr_, tls_get_addr_opt_): New vars. (Target_powerpc::tls_get_addr_opt, tls_get_addr, is_tls_get_addr_opt, replace_tls_get_addr, set_has_tls_get_addr_opt, stk_linker): New functions. (Target_powerpc::Track_tls::maybe_skip_tls_get_addr_call): Add target param. Update callers. Compare symbols rather than names. (Target_powerpc::do_define_standard_symbols): Init tls_get_addr_ and tls_get_addr_opt_. (Target_powerpc::Branch_info::mark_pltcall): Translate tls_get_addr sym to tls_get_addr_opt. (Target_powerpc::Branch_info::make_stub): Likewise. (Stub_table::define_stub_syms): Likewise. (Target_powerpc::Scan::global): Likewise. (Target_powerpc::Relocate::relocate): Likewise. (add_3_12_2, add_3_12_13, bctrl, beqlr, cmpdi_11_0, cmpwi_11_0, ld_11_1, ld_11_3, ld_12_3, lwz_11_3, lwz_12_3, mr_0_3, mr_3_0, mtlr_11, std_11_1): New constants. (Stub_table::eh_frame_added_): Delete. (Stub_table::tls_get_addr_opt_bctrl_, plt_fde_len_, plt_fde_): New vars. (Stub_table::init_plt_fde): New functions. (Stub_table::add_eh_frame, replace_eh_frame): Move definition out of line. Init and use plt_fde_. (Stub_table::plt_call_size): Return size for tls_get_addr stub. Extract alignment code to.. (Stub_table::plt_call_align): ..this new function. Adjust all callers. (Stub_table::add_plt_call_entry): Set has_tls_get_addr_opt and tls_get_addr_opt_bctrl, and align after that. (Stub_table::do_write): Write out tls_get_addr stub. (Target_powerpc::do_finalize_sections): Emit DT_PPC_OPT PPC_OPT_TLS/PPC64_OPT_TLS bit. (Target_powerpc::Relocate::relocate): Don't check for or modify nop following bl for tls_get_addr stub.
2017-08-29 08:25:33 +02:00
// Specify whether various optimisations are possible.
DT_PPC_OPT = 0x70000001,
// Specify the start of the .glink section.
DT_PPC64_GLINK = 0x70000000,
// Specify the start and size of the .opd section.
DT_PPC64_OPD = 0x70000001,
DT_PPC64_OPDSZ = 0x70000002,
// Specify whether various optimisations are possible.
DT_PPC64_OPT = 0x70000003,
// The index of an STT_SPARC_REGISTER symbol within the DT_SYMTAB
// symbol table. One dynamic entry exists for every STT_SPARC_REGISTER
// symbol in the symbol table.
DT_SPARC_REGISTER = 0x70000001,
// MIPS specific dynamic array tags.
// 32 bit version number for runtime linker interface.
DT_MIPS_RLD_VERSION = 0x70000001,
// Time stamp.
DT_MIPS_TIME_STAMP = 0x70000002,
// Checksum of external strings and common sizes.
DT_MIPS_ICHECKSUM = 0x70000003,
// Index of version string in string table.
DT_MIPS_IVERSION = 0x70000004,
// 32 bits of flags.
DT_MIPS_FLAGS = 0x70000005,
// Base address of the segment.
DT_MIPS_BASE_ADDRESS = 0x70000006,
// ???
DT_MIPS_MSYM = 0x70000007,
// Address of .conflict section.
DT_MIPS_CONFLICT = 0x70000008,
// Address of .liblist section.
DT_MIPS_LIBLIST = 0x70000009,
// Number of local global offset table entries.
DT_MIPS_LOCAL_GOTNO = 0x7000000a,
// Number of entries in the .conflict section.
DT_MIPS_CONFLICTNO = 0x7000000b,
// Number of entries in the .liblist section.
DT_MIPS_LIBLISTNO = 0x70000010,
// Number of entries in the .dynsym section.
DT_MIPS_SYMTABNO = 0x70000011,
// Index of first external dynamic symbol not referenced locally.
DT_MIPS_UNREFEXTNO = 0x70000012,
// Index of first dynamic symbol in global offset table.
DT_MIPS_GOTSYM = 0x70000013,
// Number of page table entries in global offset table.
DT_MIPS_HIPAGENO = 0x70000014,
// Address of run time loader map, used for debugging.
DT_MIPS_RLD_MAP = 0x70000016,
// Delta C++ class definition.
DT_MIPS_DELTA_CLASS = 0x70000017,
// Number of entries in DT_MIPS_DELTA_CLASS.
DT_MIPS_DELTA_CLASS_NO = 0x70000018,
// Delta C++ class instances.
DT_MIPS_DELTA_INSTANCE = 0x70000019,
// Number of entries in DT_MIPS_DELTA_INSTANCE.
DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a,
// Delta relocations.
DT_MIPS_DELTA_RELOC = 0x7000001b,
// Number of entries in DT_MIPS_DELTA_RELOC.
DT_MIPS_DELTA_RELOC_NO = 0x7000001c,
// Delta symbols that Delta relocations refer to.
DT_MIPS_DELTA_SYM = 0x7000001d,
// Number of entries in DT_MIPS_DELTA_SYM.
DT_MIPS_DELTA_SYM_NO = 0x7000001e,
// Delta symbols that hold class declarations.
DT_MIPS_DELTA_CLASSSYM = 0x70000020,
// Number of entries in DT_MIPS_DELTA_CLASSSYM.
DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021,
// Flags indicating information about C++ flavor.
DT_MIPS_CXX_FLAGS = 0x70000022,
// Pixie information (???).
DT_MIPS_PIXIE_INIT = 0x70000023,
// Address of .MIPS.symlib
DT_MIPS_SYMBOL_LIB = 0x70000024,
// The GOT index of the first PTE for a segment
DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025,
// The GOT index of the first PTE for a local symbol
DT_MIPS_LOCAL_GOTIDX = 0x70000026,
// The GOT index of the first PTE for a hidden symbol
DT_MIPS_HIDDEN_GOTIDX = 0x70000027,
// The GOT index of the first PTE for a protected symbol
DT_MIPS_PROTECTED_GOTIDX = 0x70000028,
// Address of `.MIPS.options'.
DT_MIPS_OPTIONS = 0x70000029,
// Address of `.interface'.
DT_MIPS_INTERFACE = 0x7000002a,
// ???
DT_MIPS_DYNSTR_ALIGN = 0x7000002b,
// Size of the .interface section.
DT_MIPS_INTERFACE_SIZE = 0x7000002c,
// Size of rld_text_resolve function stored in the GOT.
DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d,
// Default suffix of DSO to be added by rld on dlopen() calls.
DT_MIPS_PERF_SUFFIX = 0x7000002e,
// Size of compact relocation section (O32).
DT_MIPS_COMPACT_SIZE = 0x7000002f,
// GP value for auxiliary GOTs.
DT_MIPS_GP_VALUE = 0x70000030,
// Address of auxiliary .dynamic.
DT_MIPS_AUX_DYNAMIC = 0x70000031,
// Address of the base of the PLTGOT.
DT_MIPS_PLTGOT = 0x70000032,
// Points to the base of a writable PLT.
DT_MIPS_RWPLT = 0x70000034,
// Relative offset of run time loader map, used for debugging.
DT_MIPS_RLD_MAP_REL = 0x70000035,
DT_AUXILIARY = 0x7ffffffd,
DT_USED = 0x7ffffffe,
DT_FILTER = 0x7fffffff
};
// Flags found in the DT_FLAGS dynamic element.
enum DF
{
DF_ORIGIN = 0x1,
DF_SYMBOLIC = 0x2,
DF_TEXTREL = 0x4,
DF_BIND_NOW = 0x8,
DF_STATIC_TLS = 0x10
};
// Flags found in the DT_FLAGS_1 dynamic element.
enum DF_1
{
DF_1_NOW = 0x1,
DF_1_GLOBAL = 0x2,
DF_1_GROUP = 0x4,
DF_1_NODELETE = 0x8,
DF_1_LOADFLTR = 0x10,
DF_1_INITFIRST = 0x20,
DF_1_NOOPEN = 0x40,
DF_1_ORIGIN = 0x80,
DF_1_DIRECT = 0x100,
DF_1_TRANS = 0x200,
DF_1_INTERPOSE = 0x400,
DF_1_NODEFLIB = 0x800,
DF_1_NODUMP = 0x1000,
DF_1_CONLFAT = 0x2000
};
// Version numbers which appear in the vd_version field of a Verdef
// structure.
const int VER_DEF_NONE = 0;
const int VER_DEF_CURRENT = 1;
// Version numbers which appear in the vn_version field of a Verneed
// structure.
const int VER_NEED_NONE = 0;
const int VER_NEED_CURRENT = 1;
// Bit flags which appear in vd_flags of Verdef and vna_flags of
// Vernaux.
const int VER_FLG_BASE = 0x1;
const int VER_FLG_WEAK = 0x2;
const int VER_FLG_INFO = 0x4;
// Special constants found in the SHT_GNU_versym entries.
const int VER_NDX_LOCAL = 0;
const int VER_NDX_GLOBAL = 1;
// A SHT_GNU_versym section holds 16-bit words. This bit is set if
// the symbol is hidden and can only be seen when referenced using an
// explicit version number. This is a GNU extension.
const int VERSYM_HIDDEN = 0x8000;
// This is the mask for the rest of the data in a word read from a
// SHT_GNU_versym section.
const int VERSYM_VERSION = 0x7fff;
// Note descriptor type codes for notes in a non-core file with an
// empty name.
enum
{
// A version string.
NT_VERSION = 1,
// An architecture string.
NT_ARCH = 2
};
// Note descriptor type codes for notes in a non-core file with the
// name "GNU".
enum
{
// The minimum ABI level. This is used by the dynamic linker to
// describe the minimal kernel version on which a shared library may
// be used. Th value should be four words. Word 0 is an OS
// descriptor (see below). Word 1 is the major version of the ABI.
// Word 2 is the minor version. Word 3 is the subminor version.
NT_GNU_ABI_TAG = 1,
// Hardware capabilities information. Word 0 is the number of
// entries. Word 1 is a bitmask of enabled entries. The rest of
// the descriptor is a series of entries, where each entry is a
// single byte followed by a nul terminated string. The byte gives
// the bit number to test if enabled in the bitmask.
NT_GNU_HWCAP = 2,
// The build ID as set by the linker's --build-id option. The
// format of the descriptor depends on the build ID style.
NT_GNU_BUILD_ID = 3,
// The version of gold used to link. Th descriptor is just a
// string.
2018-06-22 18:27:39 +02:00
NT_GNU_GOLD_VERSION = 4,
// Program property note, as described in "Linux Extensions to the gABI".
NT_GNU_PROPERTY_TYPE_0 = 5
};
// The OS values which may appear in word 0 of a NT_GNU_ABI_TAG note.
enum
{
ELF_NOTE_OS_LINUX = 0,
ELF_NOTE_OS_GNU = 1,
ELF_NOTE_OS_SOLARIS2 = 2,
ELF_NOTE_OS_FREEBSD = 3,
ELF_NOTE_OS_NETBSD = 4,
ELF_NOTE_OS_SYLLABLE = 5
};
2018-06-22 18:27:39 +02:00
// Program property types for NT_GNU_PROPERTY_TYPE_0.
enum
{
GNU_PROPERTY_STACK_SIZE = 1,
GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
GNU_PROPERTY_LOPROC = 0xc0000000,
GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
GNU_PROPERTY_HIPROC = 0xdfffffff,
GNU_PROPERTY_LOUSER = 0xe0000000,
GNU_PROPERTY_HIUSER = 0xffffffff
};
2006-08-05 01:10:59 +02:00
} // End namespace elfcpp.
// Include internal details after defining the types.
#include "elfcpp_internal.h"
namespace elfcpp
{
// The offset of the ELF file header in the ELF file.
const int file_header_offset = 0;
// ELF structure sizes.
template<int size>
struct Elf_sizes
{
// Size of ELF file header.
static const int ehdr_size = sizeof(internal::Ehdr_data<size>);
// Size of ELF segment header.
static const int phdr_size = sizeof(internal::Phdr_data<size>);
2006-08-05 01:10:59 +02:00
// Size of ELF section header.
static const int shdr_size = sizeof(internal::Shdr_data<size>);
// Size of ELF compression header.
static const int chdr_size = sizeof(internal::Chdr_data<size>);
2006-08-05 01:10:59 +02:00
// Size of ELF symbol table entry.
static const int sym_size = sizeof(internal::Sym_data<size>);
// Sizes of ELF reloc entries.
static const int rel_size = sizeof(internal::Rel_data<size>);
static const int rela_size = sizeof(internal::Rela_data<size>);
// Size of ELF dynamic entry.
static const int dyn_size = sizeof(internal::Dyn_data<size>);
2006-12-06 01:02:36 +01:00
// Size of ELF version structures.
static const int verdef_size = sizeof(internal::Verdef_data);
static const int verdaux_size = sizeof(internal::Verdaux_data);
static const int verneed_size = sizeof(internal::Verneed_data);
static const int vernaux_size = sizeof(internal::Vernaux_data);
2006-08-05 01:10:59 +02:00
};
// Accessor class for the ELF file header.
template<int size, bool big_endian>
class Ehdr
{
public:
Ehdr(const unsigned char* p)
: p_(reinterpret_cast<const internal::Ehdr_data<size>*>(p))
{ }
template<typename File>
Ehdr(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Ehdr_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
2006-08-05 01:10:59 +02:00
const unsigned char*
get_e_ident() const
{ return this->p_->e_ident; }
Elf_Half
get_e_type() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_type); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_machine() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_machine); }
2006-08-05 01:10:59 +02:00
Elf_Word
get_e_version() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->e_version); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Addr
get_e_entry() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->e_entry); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Off
get_e_phoff() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->e_phoff); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Off
get_e_shoff() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->e_shoff); }
2006-08-05 01:10:59 +02:00
Elf_Word
get_e_flags() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->e_flags); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_ehsize() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_ehsize); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_phentsize() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_phentsize); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_phnum() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_phnum); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_shentsize() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_shentsize); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_shnum() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_shnum); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_e_shstrndx() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->e_shstrndx); }
2006-08-05 01:10:59 +02:00
private:
const internal::Ehdr_data<size>* p_;
};
// Write class for the ELF file header.
template<int size, bool big_endian>
class Ehdr_write
{
public:
Ehdr_write(unsigned char* p)
: p_(reinterpret_cast<internal::Ehdr_data<size>*>(p))
{ }
void
put_e_ident(const unsigned char v[EI_NIDENT]) const
{ memcpy(this->p_->e_ident, v, EI_NIDENT); }
void
put_e_type(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_type = Convert<16, big_endian>::convert_host(v); }
void
put_e_machine(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_machine = Convert<16, big_endian>::convert_host(v); }
void
put_e_version(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_version = Convert<32, big_endian>::convert_host(v); }
void
put_e_entry(typename Elf_types<size>::Elf_Addr v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_entry = Convert<size, big_endian>::convert_host(v); }
void
put_e_phoff(typename Elf_types<size>::Elf_Off v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_phoff = Convert<size, big_endian>::convert_host(v); }
void
put_e_shoff(typename Elf_types<size>::Elf_Off v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_shoff = Convert<size, big_endian>::convert_host(v); }
void
put_e_flags(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_flags = Convert<32, big_endian>::convert_host(v); }
void
put_e_ehsize(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_ehsize = Convert<16, big_endian>::convert_host(v); }
void
put_e_phentsize(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_phentsize = Convert<16, big_endian>::convert_host(v); }
void
put_e_phnum(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_phnum = Convert<16, big_endian>::convert_host(v); }
void
put_e_shentsize(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_shentsize = Convert<16, big_endian>::convert_host(v); }
void
put_e_shnum(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_shnum = Convert<16, big_endian>::convert_host(v); }
void
put_e_shstrndx(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->e_shstrndx = Convert<16, big_endian>::convert_host(v); }
private:
internal::Ehdr_data<size>* p_;
};
2006-08-05 01:10:59 +02:00
// Accessor class for an ELF section header.
template<int size, bool big_endian>
class Shdr
{
public:
Shdr(const unsigned char* p)
: p_(reinterpret_cast<const internal::Shdr_data<size>*>(p))
{ }
template<typename File>
Shdr(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Shdr_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
2006-08-05 01:10:59 +02:00
Elf_Word
get_sh_name() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->sh_name); }
2006-08-05 01:10:59 +02:00
Elf_Word
get_sh_type() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->sh_type); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_WXword
get_sh_flags() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->sh_flags); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Addr
get_sh_addr() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->sh_addr); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Off
get_sh_offset() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->sh_offset); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_WXword
get_sh_size() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->sh_size); }
2006-08-05 01:10:59 +02:00
Elf_Word
get_sh_link() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->sh_link); }
2006-08-05 01:10:59 +02:00
Elf_Word
get_sh_info() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->sh_info); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_WXword
get_sh_addralign() const
{ return
2006-11-06 23:45:08 +01:00
Convert<size, big_endian>::convert_host(this->p_->sh_addralign); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_WXword
get_sh_entsize() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->sh_entsize); }
2006-08-05 01:10:59 +02:00
private:
const internal::Shdr_data<size>* p_;
};
// Write class for an ELF section header.
template<int size, bool big_endian>
class Shdr_write
{
public:
Shdr_write(unsigned char* p)
: p_(reinterpret_cast<internal::Shdr_data<size>*>(p))
{ }
void
put_sh_name(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_name = Convert<32, big_endian>::convert_host(v); }
void
put_sh_type(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_type = Convert<32, big_endian>::convert_host(v); }
void
put_sh_flags(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_flags = Convert<size, big_endian>::convert_host(v); }
void
put_sh_addr(typename Elf_types<size>::Elf_Addr v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_addr = Convert<size, big_endian>::convert_host(v); }
void
put_sh_offset(typename Elf_types<size>::Elf_Off v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_offset = Convert<size, big_endian>::convert_host(v); }
void
put_sh_size(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_size = Convert<size, big_endian>::convert_host(v); }
void
put_sh_link(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_link = Convert<32, big_endian>::convert_host(v); }
void
put_sh_info(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_info = Convert<32, big_endian>::convert_host(v); }
void
put_sh_addralign(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_addralign = Convert<size, big_endian>::convert_host(v); }
void
put_sh_entsize(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->sh_entsize = Convert<size, big_endian>::convert_host(v); }
private:
internal::Shdr_data<size>* p_;
};
// Accessor class for an ELF compression header.
template<int size, bool big_endian>
class Chdr
{
public:
Chdr(const unsigned char* p)
: p_(reinterpret_cast<const internal::Chdr_data<size>*>(p))
{ }
template<typename File>
Chdr(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Chdr_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
Elf_Word
get_ch_type() const
{ return Convert<size, big_endian>::convert_host(this->p_->ch_type); }
typename Elf_types<size>::Elf_WXword
get_ch_size() const
{ return Convert<size, big_endian>::convert_host(this->p_->ch_size); }
typename Elf_types<size>::Elf_WXword
get_ch_addralign() const
{ return
Convert<size, big_endian>::convert_host(this->p_->ch_addralign); }
private:
const internal::Chdr_data<size>* p_;
};
// Write class for an ELF compression header.
template<int size, bool big_endian>
class Chdr_write
{
public:
Chdr_write(unsigned char* p)
: p_(reinterpret_cast<internal::Chdr_data<size>*>(p))
{ }
void
put_ch_type(typename Elf_types<size>::Elf_WXword v)
{ this->p_->ch_type = Convert<size, big_endian>::convert_host(v); }
void
put_ch_size(typename Elf_types<size>::Elf_WXword v)
{ this->p_->ch_size = Convert<size, big_endian>::convert_host(v); }
void
put_ch_addralign(typename Elf_types<size>::Elf_WXword v)
{ this->p_->ch_addralign = Convert<size, big_endian>::convert_host(v); }
void
put_ch_reserved(Elf_Word);
private:
internal::Chdr_data<size>* p_;
};
template<>
inline void
elfcpp::Chdr_write<64, true>::put_ch_reserved(Elf_Word v)
{
this->p_->ch_reserved = v;
}
template<>
inline void
elfcpp::Chdr_write<64, false>::put_ch_reserved(Elf_Word v)
{
this->p_->ch_reserved = v;
}
2006-09-25 23:29:06 +02:00
// Accessor class for an ELF segment header.
template<int size, bool big_endian>
class Phdr
{
public:
Phdr(const unsigned char* p)
: p_(reinterpret_cast<const internal::Phdr_data<size>*>(p))
{ }
template<typename File>
Phdr(File* file, typename File::Location loc)
: p_(reinterpret_cast<internal::Phdr_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
2006-09-25 23:29:06 +02:00
Elf_Word
get_p_type() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->p_type); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_Off
get_p_offset() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_offset); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_Addr
get_p_vaddr() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_vaddr); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_Addr
get_p_paddr() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_paddr); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_WXword
get_p_filesz() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_filesz); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_WXword
get_p_memsz() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_memsz); }
2006-09-25 23:29:06 +02:00
Elf_Word
get_p_flags() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->p_flags); }
2006-09-25 23:29:06 +02:00
typename Elf_types<size>::Elf_WXword
get_p_align() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->p_align); }
2006-09-25 23:29:06 +02:00
private:
const internal::Phdr_data<size>* p_;
};
// Write class for an ELF segment header.
template<int size, bool big_endian>
class Phdr_write
{
public:
Phdr_write(unsigned char* p)
: p_(reinterpret_cast<internal::Phdr_data<size>*>(p))
{ }
void
put_p_type(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_type = Convert<32, big_endian>::convert_host(v); }
void
put_p_offset(typename Elf_types<size>::Elf_Off v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_offset = Convert<size, big_endian>::convert_host(v); }
void
put_p_vaddr(typename Elf_types<size>::Elf_Addr v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_vaddr = Convert<size, big_endian>::convert_host(v); }
void
put_p_paddr(typename Elf_types<size>::Elf_Addr v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_paddr = Convert<size, big_endian>::convert_host(v); }
void
put_p_filesz(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_filesz = Convert<size, big_endian>::convert_host(v); }
void
put_p_memsz(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_memsz = Convert<size, big_endian>::convert_host(v); }
void
put_p_flags(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_flags = Convert<32, big_endian>::convert_host(v); }
void
put_p_align(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->p_align = Convert<size, big_endian>::convert_host(v); }
private:
internal::Phdr_data<size>* p_;
};
2006-08-05 01:10:59 +02:00
// Accessor class for an ELF symbol table entry.
template<int size, bool big_endian>
class Sym
{
public:
Sym(const unsigned char* p)
: p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
{ }
template<typename File>
Sym(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Sym_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
2006-08-05 01:10:59 +02:00
Elf_Word
get_st_name() const
2006-11-06 23:45:08 +01:00
{ return Convert<32, big_endian>::convert_host(this->p_->st_name); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_Addr
get_st_value() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->st_value); }
2006-08-05 01:10:59 +02:00
typename Elf_types<size>::Elf_WXword
get_st_size() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->st_size); }
2006-08-05 01:10:59 +02:00
unsigned char
get_st_info() const
{ return this->p_->st_info; }
STB
get_st_bind() const
{ return elf_st_bind(this->get_st_info()); }
STT
get_st_type() const
{ return elf_st_type(this->get_st_info()); }
2006-08-05 01:10:59 +02:00
unsigned char
get_st_other() const
{ return this->p_->st_other; }
STV
get_st_visibility() const
{ return elf_st_visibility(this->get_st_other()); }
unsigned char
get_st_nonvis() const
{ return elf_st_nonvis(this->get_st_other()); }
2006-08-05 01:10:59 +02:00
Elf_Half
get_st_shndx() const
2006-11-06 23:45:08 +01:00
{ return Convert<16, big_endian>::convert_host(this->p_->st_shndx); }
2006-08-05 01:10:59 +02:00
private:
const internal::Sym_data<size>* p_;
};
2006-09-07 23:21:41 +02:00
// Writer class for an ELF symbol table entry.
template<int size, bool big_endian>
class Sym_write
{
public:
Sym_write(unsigned char* p)
: p_(reinterpret_cast<internal::Sym_data<size>*>(p))
{ }
void
put_st_name(Elf_Word v)
2006-11-06 23:45:08 +01:00
{ this->p_->st_name = Convert<32, big_endian>::convert_host(v); }
2006-09-07 23:21:41 +02:00
void
put_st_value(typename Elf_types<size>::Elf_Addr v)
2006-11-06 23:45:08 +01:00
{ this->p_->st_value = Convert<size, big_endian>::convert_host(v); }
2006-09-07 23:21:41 +02:00
void
put_st_size(typename Elf_types<size>::Elf_WXword v)
2006-11-06 23:45:08 +01:00
{ this->p_->st_size = Convert<size, big_endian>::convert_host(v); }
2006-09-07 23:21:41 +02:00
void
put_st_info(unsigned char v)
{ this->p_->st_info = v; }
void
put_st_info(STB bind, STT type)
{ this->p_->st_info = elf_st_info(bind, type); }
void
put_st_other(unsigned char v)
{ this->p_->st_other = v; }
void
put_st_other(STV vis, unsigned char nonvis)
{ this->p_->st_other = elf_st_other(vis, nonvis); }
void
put_st_shndx(Elf_Half v)
2006-11-06 23:45:08 +01:00
{ this->p_->st_shndx = Convert<16, big_endian>::convert_host(v); }
2006-09-07 23:21:41 +02:00
Sym<size, big_endian>
sym()
{ return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); }
private:
internal::Sym_data<size>* p_;
};
// Accessor classes for an ELF REL relocation entry.
template<int size, bool big_endian>
class Rel
{
public:
Rel(const unsigned char* p)
: p_(reinterpret_cast<const internal::Rel_data<size>*>(p))
{ }
template<typename File>
Rel(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Rel_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
typename Elf_types<size>::Elf_Addr
get_r_offset() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
typename Elf_types<size>::Elf_WXword
get_r_info() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->r_info); }
private:
const internal::Rel_data<size>* p_;
};
// Writer class for an ELF Rel relocation.
template<int size, bool big_endian>
class Rel_write
{
public:
Rel_write(unsigned char* p)
: p_(reinterpret_cast<internal::Rel_data<size>*>(p))
{ }
void
put_r_offset(typename Elf_types<size>::Elf_Addr v)
{ this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
void
put_r_info(typename Elf_types<size>::Elf_WXword v)
{ this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
private:
internal::Rel_data<size>* p_;
};
// Accessor class for an ELF Rela relocation.
template<int size, bool big_endian>
class Rela
{
public:
Rela(const unsigned char* p)
: p_(reinterpret_cast<const internal::Rela_data<size>*>(p))
{ }
template<typename File>
Rela(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Rela_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
typename Elf_types<size>::Elf_Addr
get_r_offset() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->r_offset); }
typename Elf_types<size>::Elf_WXword
get_r_info() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->r_info); }
typename Elf_types<size>::Elf_Swxword
get_r_addend() const
2006-11-06 23:45:08 +01:00
{ return Convert<size, big_endian>::convert_host(this->p_->r_addend); }
private:
const internal::Rela_data<size>* p_;
};
// Writer class for an ELF Rela relocation.
template<int size, bool big_endian>
class Rela_write
{
public:
Rela_write(unsigned char* p)
: p_(reinterpret_cast<internal::Rela_data<size>*>(p))
{ }
void
put_r_offset(typename Elf_types<size>::Elf_Addr v)
{ this->p_->r_offset = Convert<size, big_endian>::convert_host(v); }
void
put_r_info(typename Elf_types<size>::Elf_WXword v)
{ this->p_->r_info = Convert<size, big_endian>::convert_host(v); }
void
put_r_addend(typename Elf_types<size>::Elf_Swxword v)
{ this->p_->r_addend = Convert<size, big_endian>::convert_host(v); }
private:
internal::Rela_data<size>* p_;
};
Refactor gold to enable support for MIPS-64 relocation format. For MIPS-64, the r_info field in the relocation format is replaced by several individual fields, including r_sym and r_type. To enable support for this format, I've refactored target-independent code to remove almost all uses of the r_info field. (I've left alone a couple of routines used only for incremental linking, which I can update if/when the MIPS target adds support for incremental linking.) For routines that are already templated on a Classify_reloc class (namely, gc_process_relocs, relocate_section, and relocate_relocs), I've extended the Classify_reloc interface to include sh_type (which no longer needs to be a separate template parameter) as well as get_r_sym() and get_r_type() methods for extracting the r_sym and r_type fields. For scan_relocatable_relocs, I've extended the Default_scan_relocatable_relocs class by converting it to a class template with Classify_reloc as a template parameter. For the remaining routines that need to access r_sym, I've added a virtual Target::get_r_sym() method with an override for the MIPS target. In elfcpp, I've added Mips64_rel, etc., accessor classes and corresponding internal data structures. The MIPS target uses these new classes within its own Mips_classify_reloc class. The Mips64_ accessor classes also expose the r_ssym, r_type2, and r_type3 fields from the relocation. These changes should be functionally the same for all but the MIPS target. elfcpp/ * elfcpp.h (Mips64_rel, Mips64_rel_write): New classes. (Mips64_rela, Mips64_rela_write): New classes. * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs. gold/ * gc.h (get_embedded_addend_size): Remove sh_type parameter. (gc_process_relocs): Remove sh_type template parameter. Use Classify_reloc to access r_sym, r_type, and r_addend fields. * object.h (Sized_relobj_file::split_stack_adjust): Add target parameter. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. * reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA specializations) Remove. * reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h. (Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan(). (Sized_relobj_file::emit_relocs_scan_reltype): Remove. (Sized_relobj_file::split_stack_adjust): Add target parameter. Adjust all callers. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call Target::get_r_sym() to get r_sym field from relocations. (Track_relocs::next_symndx): Call Target::get_r_sym(). * target-reloc.h (scan_relocs): Remove sh_type template parameter; add Classify_reloc template parameter. Use for accessing r_sym and r_type. (relocate_section): Likewise. (Default_classify_reloc): New class (renamed and moved from reloc.cc). (Default_scan_relocatable_relocs): Remove sh_type template parameter. (Default_scan_relocatable_relocs::Reltype): New typedef. (Default_scan_relocatable_relocs::reloc_size): New const. (Default_scan_relocatable_relocs::sh_type): New const. (Default_scan_relocatable_relocs::get_r_sym): New method. (Default_scan_relocatable_relocs::get_r_type): New method. (Default_emit_relocs_strategy): New class. (scan_relocatable_relocs): Replace sh_type template parameter with Scan_relocatable_relocs class. Use it to access r_sym and r_type fields. (relocate_relocs): Replace sh_type template parameter with Classify_reloc class. Use it to access r_sym and r_type fields. * target.h (Target::is_call_to_non_split): Replace r_type parameter with pointer to relocation. Adjust all callers. (Target::do_is_call_to_non_split): Likewise. (Target::emit_relocs_scan): New virtual method. (Sized_target::get_r_sym): New virtual method. * target.cc (Target::do_is_call_to_non_split): Replace r_type parameter with pointer to relocation. * aarch64.cc (Target_aarch64::emit_relocs_scan): New method. (Target_aarch64::Relocatable_size_for_reloc): Remove. (Target_aarch64::gc_process_relocs): Use Default_classify_reloc. (Target_aarch64::scan_relocs): Likewise. (Target_aarch64::relocate_section): Likewise. (Target_aarch64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_aarch64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_aarch64::relocate_relocs): Use Default_classify_reloc. * arm.cc (Target_arm::Arm_scan_relocatable_relocs): Remove sh_type template parameter. (Target_arm::emit_relocs_scan): New method. (Target_arm::Relocatable_size_for_reloc): Replace with... (Target_arm::Classify_reloc): ...this. (Target_arm::gc_process_relocs): Use Classify_reloc. (Target_arm::scan_relocs): Likewise. (Target_arm::relocate_section): Likewise. (Target_arm::scan_relocatable_relocs): Likewise. (Target_arm::relocate_relocs): Likewise. * i386.cc (Target_i386::emit_relocs_scan): New method. (Target_i386::Relocatable_size_for_reloc): Replace with... (Target_i386::Classify_reloc): ...this. (Target_i386::gc_process_relocs): Use Classify_reloc. (Target_i386::scan_relocs): Likewise. (Target_i386::relocate_section): Likewise. (Target_i386::scan_relocatable_relocs): Likewise. (Target_i386::relocate_relocs): Likewise. * mips.cc (Mips_scan_relocatable_relocs): Remove sh_type template parameter. (Mips_reloc_types): New class template. (Mips_classify_reloc): New class template. (Target_mips::Reltype): New typedef. (Target_mips::Relatype): New typedef. (Target_mips::emit_relocs_scan): New method. (Target_mips::get_r_sym): New method. (Target_mips::Relocatable_size_for_reloc): Replace with Mips_classify_reloc. (Target_mips::copy_reloc): Use Mips_classify_reloc. (Target_mips::gc_process_relocs): Likewise. (Target_mips::scan_relocs): Likewise. (Target_mips::relocate_section): Likewise. (Target_mips::scan_relocatable_relocs): Likewise. (Target_mips::relocate_relocs): Likewise. (mips_get_size_for_reloc): New function, factored out from Relocatable_size_for_reloc::get_size_for_reloc. (Target_mips::Scan::local): Use Mips_classify_reloc. (Target_mips::Scan::global): Likewise. (Target_mips::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::emit_relocs_scan): New method. (Target_powerpc::Relocatable_size_for_reloc): Remove. (Target_powerpc::gc_process_relocs): Use Default_classify_reloc. (Target_powerpc::scan_relocs): Likewise. (Target_powerpc::relocate_section): Likewise. (Powerpc_scan_relocatable_reloc): Convert to class template. (Powerpc_scan_relocatable_reloc::Reltype): New typedef. (Powerpc_scan_relocatable_reloc::reloc_size): New const. (Powerpc_scan_relocatable_reloc::sh_type): New const. (Powerpc_scan_relocatable_reloc::get_r_sym): New method. (Powerpc_scan_relocatable_reloc::get_r_type): New method. (Target_powerpc::scan_relocatable_relocs): Use Powerpc_scan_relocatable_reloc. (Target_powerpc::relocate_relocs): Use Default_classify_reloc. * s390.cc (Target_s390::emit_relocs_scan): New method. (Target_s390::Relocatable_size_for_reloc): Remove. (Target_s390::gc_process_relocs): Use Default_classify_reloc. (Target_s390::scan_relocs): Likewise. (Target_s390::relocate_section): Likewise. (Target_s390::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_s390::scan_relocatable_relocs): Use Default_classify_reloc. (Target_s390::relocate_relocs): Use Default_classify_reloc. * sparc.cc (Target_sparc::emit_relocs_scan): New method. (Target_sparc::Relocatable_size_for_reloc): Remove. (Target_sparc::gc_process_relocs): Use Default_classify_reloc. (Target_sparc::scan_relocs): Likewise. (Target_sparc::relocate_section): Likewise. (Target_sparc::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_sparc::scan_relocatable_relocs): Use Default_classify_reloc. (Target_sparc::relocate_relocs): Use Default_classify_reloc. * tilegx.cc (Target_tilegx::emit_relocs_scan): New method. (Target_tilegx::Relocatable_size_for_reloc): Remove. (Target_tilegx::gc_process_relocs): Use Default_classify_reloc. (Target_tilegx::scan_relocs): Likewise. (Target_tilegx::relocate_section): Likewise. (Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_tilegx::scan_relocatable_relocs): Use Default_classify_reloc. (Target_tilegx::relocate_relocs): Use Default_classify_reloc. * x86_64.cc (Target_x86_64::emit_relocs_scan): New method. (Target_x86_64::Relocatable_size_for_reloc): Remove. (Target_x86_64::gc_process_relocs): Use Default_classify_reloc. (Target_x86_64::scan_relocs): Likewise. (Target_x86_64::relocate_section): Likewise. (Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_x86_64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_x86_64::relocate_relocs): Use Default_classify_reloc. * testsuite/testfile.cc (Target_test::emit_relocs_scan): New method.
2015-12-11 16:43:59 +01:00
// MIPS-64 has a non-standard relocation layout.
template<bool big_endian>
class Mips64_rel
{
public:
Mips64_rel(const unsigned char* p)
: p_(reinterpret_cast<const internal::Mips64_rel_data*>(p))
{ }
template<typename File>
Mips64_rel(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Mips64_rel_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
typename Elf_types<64>::Elf_Addr
get_r_offset() const
{ return Convert<64, big_endian>::convert_host(this->p_->r_offset); }
Elf_Word
get_r_sym() const
{ return Convert<32, big_endian>::convert_host(this->p_->r_sym); }
unsigned char
get_r_ssym() const
{ return this->p_->r_ssym; }
unsigned char
get_r_type() const
{ return this->p_->r_type; }
unsigned char
get_r_type2() const
{ return this->p_->r_type2; }
unsigned char
get_r_type3() const
{ return this->p_->r_type3; }
private:
const internal::Mips64_rel_data* p_;
};
template<bool big_endian>
class Mips64_rel_write
{
public:
Mips64_rel_write(unsigned char* p)
: p_(reinterpret_cast<internal::Mips64_rel_data*>(p))
{ }
void
put_r_offset(typename Elf_types<64>::Elf_Addr v)
{ this->p_->r_offset = Convert<64, big_endian>::convert_host(v); }
void
put_r_sym(Elf_Word v)
{ this->p_->r_sym = Convert<32, big_endian>::convert_host(v); }
void
put_r_ssym(unsigned char v)
{ this->p_->r_ssym = v; }
void
put_r_type(unsigned char v)
{ this->p_->r_type = v; }
void
put_r_type2(unsigned char v)
{ this->p_->r_type2 = v; }
void
put_r_type3(unsigned char v)
{ this->p_->r_type3 = v; }
private:
internal::Mips64_rel_data* p_;
};
template<bool big_endian>
class Mips64_rela
{
public:
Mips64_rela(const unsigned char* p)
: p_(reinterpret_cast<const internal::Mips64_rela_data*>(p))
{ }
template<typename File>
Mips64_rela(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Mips64_rela_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
typename Elf_types<64>::Elf_Addr
get_r_offset() const
{ return Convert<64, big_endian>::convert_host(this->p_->r_offset); }
Elf_Word
get_r_sym() const
{ return Convert<32, big_endian>::convert_host(this->p_->r_sym); }
unsigned char
get_r_ssym() const
{ return this->p_->r_ssym; }
unsigned char
get_r_type() const
{ return this->p_->r_type; }
unsigned char
get_r_type2() const
{ return this->p_->r_type2; }
unsigned char
get_r_type3() const
{ return this->p_->r_type3; }
typename Elf_types<64>::Elf_Swxword
get_r_addend() const
{ return Convert<64, big_endian>::convert_host(this->p_->r_addend); }
private:
const internal::Mips64_rela_data* p_;
};
template<bool big_endian>
class Mips64_rela_write
{
public:
Mips64_rela_write(unsigned char* p)
: p_(reinterpret_cast<internal::Mips64_rela_data*>(p))
{ }
void
put_r_offset(typename Elf_types<64>::Elf_Addr v)
{ this->p_->r_offset = Convert<64, big_endian>::convert_host(v); }
void
put_r_sym(Elf_Word v)
{ this->p_->r_sym = Convert<32, big_endian>::convert_host(v); }
void
put_r_ssym(unsigned char v)
{ this->p_->r_ssym = v; }
void
put_r_type(unsigned char v)
{ this->p_->r_type = v; }
void
put_r_type2(unsigned char v)
{ this->p_->r_type2 = v; }
void
put_r_type3(unsigned char v)
{ this->p_->r_type3 = v; }
void
put_r_addend(typename Elf_types<64>::Elf_Swxword v)
{ this->p_->r_addend = Convert<64, big_endian>::convert_host(v); }
private:
internal::Mips64_rela_data* p_;
};
// Accessor classes for entries in the ELF SHT_DYNAMIC section aka
// PT_DYNAMIC segment.
template<int size, bool big_endian>
class Dyn
{
public:
Dyn(const unsigned char* p)
: p_(reinterpret_cast<const internal::Dyn_data<size>*>(p))
{ }
template<typename File>
Dyn(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Dyn_data<size>*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
typename Elf_types<size>::Elf_Swxword
get_d_tag() const
{ return Convert<size, big_endian>::convert_host(this->p_->d_tag); }
typename Elf_types<size>::Elf_WXword
get_d_val() const
{ return Convert<size, big_endian>::convert_host(this->p_->d_val); }
typename Elf_types<size>::Elf_Addr
get_d_ptr() const
{ return Convert<size, big_endian>::convert_host(this->p_->d_val); }
private:
const internal::Dyn_data<size>* p_;
};
// Write class for an entry in the SHT_DYNAMIC section.
template<int size, bool big_endian>
class Dyn_write
{
public:
Dyn_write(unsigned char* p)
: p_(reinterpret_cast<internal::Dyn_data<size>*>(p))
{ }
void
put_d_tag(typename Elf_types<size>::Elf_Swxword v)
{ this->p_->d_tag = Convert<size, big_endian>::convert_host(v); }
void
put_d_val(typename Elf_types<size>::Elf_WXword v)
{ this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
void
put_d_ptr(typename Elf_types<size>::Elf_Addr v)
{ this->p_->d_val = Convert<size, big_endian>::convert_host(v); }
private:
internal::Dyn_data<size>* p_;
};
// Accessor classes for entries in the ELF SHT_GNU_verdef section.
template<int size, bool big_endian>
class Verdef
{
public:
Verdef(const unsigned char* p)
: p_(reinterpret_cast<const internal::Verdef_data*>(p))
{ }
template<typename File>
Verdef(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Verdef_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
Elf_Half
get_vd_version() const
{ return Convert<16, big_endian>::convert_host(this->p_->vd_version); }
Elf_Half
get_vd_flags() const
{ return Convert<16, big_endian>::convert_host(this->p_->vd_flags); }
Elf_Half
get_vd_ndx() const
{ return Convert<16, big_endian>::convert_host(this->p_->vd_ndx); }
Elf_Half
get_vd_cnt() const
{ return Convert<16, big_endian>::convert_host(this->p_->vd_cnt); }
Elf_Word
get_vd_hash() const
{ return Convert<32, big_endian>::convert_host(this->p_->vd_hash); }
Elf_Word
get_vd_aux() const
{ return Convert<32, big_endian>::convert_host(this->p_->vd_aux); }
Elf_Word
get_vd_next() const
{ return Convert<32, big_endian>::convert_host(this->p_->vd_next); }
private:
const internal::Verdef_data* p_;
};
2006-12-06 01:02:36 +01:00
template<int size, bool big_endian>
class Verdef_write
{
public:
Verdef_write(unsigned char* p)
: p_(reinterpret_cast<internal::Verdef_data*>(p))
{ }
void
set_vd_version(Elf_Half v)
{ this->p_->vd_version = Convert<16, big_endian>::convert_host(v); }
void
set_vd_flags(Elf_Half v)
{ this->p_->vd_flags = Convert<16, big_endian>::convert_host(v); }
void
set_vd_ndx(Elf_Half v)
{ this->p_->vd_ndx = Convert<16, big_endian>::convert_host(v); }
void
set_vd_cnt(Elf_Half v)
{ this->p_->vd_cnt = Convert<16, big_endian>::convert_host(v); }
void
set_vd_hash(Elf_Word v)
{ this->p_->vd_hash = Convert<32, big_endian>::convert_host(v); }
void
set_vd_aux(Elf_Word v)
{ this->p_->vd_aux = Convert<32, big_endian>::convert_host(v); }
void
set_vd_next(Elf_Word v)
{ this->p_->vd_next = Convert<32, big_endian>::convert_host(v); }
private:
internal::Verdef_data* p_;
};
// Accessor classes for auxiliary entries in the ELF SHT_GNU_verdef
// section.
template<int size, bool big_endian>
class Verdaux
{
public:
Verdaux(const unsigned char* p)
: p_(reinterpret_cast<const internal::Verdaux_data*>(p))
{ }
template<typename File>
Verdaux(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Verdaux_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
Elf_Word
get_vda_name() const
{ return Convert<32, big_endian>::convert_host(this->p_->vda_name); }
Elf_Word
get_vda_next() const
{ return Convert<32, big_endian>::convert_host(this->p_->vda_next); }
private:
const internal::Verdaux_data* p_;
};
2006-12-06 01:02:36 +01:00
template<int size, bool big_endian>
class Verdaux_write
{
public:
Verdaux_write(unsigned char* p)
: p_(reinterpret_cast<internal::Verdaux_data*>(p))
{ }
void
set_vda_name(Elf_Word v)
{ this->p_->vda_name = Convert<32, big_endian>::convert_host(v); }
void
set_vda_next(Elf_Word v)
{ this->p_->vda_next = Convert<32, big_endian>::convert_host(v); }
private:
internal::Verdaux_data* p_;
};
// Accessor classes for entries in the ELF SHT_GNU_verneed section.
template<int size, bool big_endian>
class Verneed
{
public:
Verneed(const unsigned char* p)
: p_(reinterpret_cast<const internal::Verneed_data*>(p))
{ }
template<typename File>
Verneed(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Verneed_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
Elf_Half
get_vn_version() const
{ return Convert<16, big_endian>::convert_host(this->p_->vn_version); }
Elf_Half
get_vn_cnt() const
{ return Convert<16, big_endian>::convert_host(this->p_->vn_cnt); }
Elf_Word
get_vn_file() const
{ return Convert<32, big_endian>::convert_host(this->p_->vn_file); }
Elf_Word
get_vn_aux() const
{ return Convert<32, big_endian>::convert_host(this->p_->vn_aux); }
Elf_Word
get_vn_next() const
{ return Convert<32, big_endian>::convert_host(this->p_->vn_next); }
private:
const internal::Verneed_data* p_;
};
2006-12-06 01:02:36 +01:00
template<int size, bool big_endian>
class Verneed_write
{
public:
Verneed_write(unsigned char* p)
: p_(reinterpret_cast<internal::Verneed_data*>(p))
{ }
void
set_vn_version(Elf_Half v)
{ this->p_->vn_version = Convert<16, big_endian>::convert_host(v); }
void
set_vn_cnt(Elf_Half v)
{ this->p_->vn_cnt = Convert<16, big_endian>::convert_host(v); }
void
set_vn_file(Elf_Word v)
{ this->p_->vn_file = Convert<32, big_endian>::convert_host(v); }
void
set_vn_aux(Elf_Word v)
{ this->p_->vn_aux = Convert<32, big_endian>::convert_host(v); }
void
set_vn_next(Elf_Word v)
{ this->p_->vn_next = Convert<32, big_endian>::convert_host(v); }
private:
internal::Verneed_data* p_;
};
// Accessor classes for auxiliary entries in the ELF SHT_GNU_verneed
// section.
template<int size, bool big_endian>
class Vernaux
{
public:
Vernaux(const unsigned char* p)
: p_(reinterpret_cast<const internal::Vernaux_data*>(p))
{ }
template<typename File>
Vernaux(File* file, typename File::Location loc)
: p_(reinterpret_cast<const internal::Vernaux_data*>(
file->view(loc.file_offset, loc.data_size).data()))
{ }
Elf_Word
get_vna_hash() const
{ return Convert<32, big_endian>::convert_host(this->p_->vna_hash); }
Elf_Half
get_vna_flags() const
{ return Convert<16, big_endian>::convert_host(this->p_->vna_flags); }
Elf_Half
get_vna_other() const
{ return Convert<16, big_endian>::convert_host(this->p_->vna_other); }
Elf_Word
get_vna_name() const
{ return Convert<32, big_endian>::convert_host(this->p_->vna_name); }
Elf_Word
get_vna_next() const
{ return Convert<32, big_endian>::convert_host(this->p_->vna_next); }
private:
const internal::Vernaux_data* p_;
};
2006-12-06 01:02:36 +01:00
template<int size, bool big_endian>
class Vernaux_write
{
public:
Vernaux_write(unsigned char* p)
: p_(reinterpret_cast<internal::Vernaux_data*>(p))
{ }
void
set_vna_hash(Elf_Word v)
{ this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); }
void
set_vna_flags(Elf_Half v)
{ this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); }
void
set_vna_other(Elf_Half v)
{ this->p_->vna_other = Convert<16, big_endian>::convert_host(v); }
void
set_vna_name(Elf_Word v)
{ this->p_->vna_name = Convert<32, big_endian>::convert_host(v); }
void
set_vna_next(Elf_Word v)
{ this->p_->vna_next = Convert<32, big_endian>::convert_host(v); }
private:
internal::Vernaux_data* p_;
};
2006-08-05 01:10:59 +02:00
} // End namespace elfcpp.
#endif // !defined(ELFPCP_H)