X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=elfcpp%2Felfcpp.h;h=7abc9e3ac0a7603fc82ef9600edf4bb24eb41ce9;hb=d8045f234d8865a7a7bfce71e81fcbeaf4098a7e;hp=ba85b3d5b2a295b706b4d4100b9713e783bf6542;hpb=a3ad94edd406b9abc26493761764d4034dda69fa;p=deliverable%2Fbinutils-gdb.git diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h index ba85b3d5b2..7abc9e3ac0 100644 --- a/elfcpp/elfcpp.h +++ b/elfcpp/elfcpp.h @@ -1,11 +1,39 @@ // elfcpp.h -- main header file for elfcpp -*- C++ -*- +// Copyright 2006, 2007, 2008, Free Software Foundation, Inc. +// Written by Ian Lance Taylor . + +// This file is part of elfcpp. + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public License +// as published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// In addition to the permissions in the GNU Library General Public +// License, the Free Software Foundation gives you unlimited +// permission to link the compiled version of this file into +// combinations with other programs, and to distribute those +// combinations without any restriction coming from the use of this +// file. (The Library Public License restrictions do apply in other +// respects; for example, they cover modification of the file, and +/// distribution when not linked into a combined executable.) + +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +// 02110-1301, USA. + // This is the external interface for elfcpp. #ifndef ELFCPP_H #define ELFCPP_H -#include "elfcpp_config.h" #include "elfcpp_swap.h" #include @@ -287,7 +315,12 @@ enum SHN_ABS = 0xfff1, SHN_COMMON = 0xfff2, SHN_XINDEX = 0xffff, - SHN_HIRESERVE = 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, }; // The valid values found in the Shdr sh_type field. @@ -318,6 +351,12 @@ enum SHT SHT_LOUSER = 0x80000000, SHT_HIUSER = 0xffffffff, // The remaining values are not in the standard. + // Incremental build data. + SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700, + // Object attributes. + SHT_GNU_ATTRIBUTES = 0x6ffffff5, + // GNU style dynamic hash table. + SHT_GNU_HASH = 0x6ffffff6, // List of prelink dependencies. SHT_GNU_LIBLIST = 0x6ffffff7, // Versions defined by file. @@ -329,6 +368,12 @@ enum SHT // Symbol versions, SHT_SUNW_versym = 0x6fffffff, SHT_GNU_versym = 0x6fffffff, + + SHT_SPARC_GOTDATA = 0x70000000, + + // Link editor is to sort the entries in this section based on the + // address specified in the associated symbol table entry. + SHT_ORDERED = 0x7fffffff, }; // The valid bit flags found in the Shdr sh_flags field. @@ -346,7 +391,19 @@ enum SHF SHF_GROUP = 0x200, SHF_TLS = 0x400, SHF_MASKOS = 0x0ff00000, - SHF_MASKPROC = 0xf0000000 + 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, }; // Bit flags which appear in the first 32-bit word of the section data @@ -421,9 +478,14 @@ enum STT STT_COMMON = 5, STT_TLS = 6, STT_LOOS = 10, + STT_GNU_IFUNC = 10, STT_HIOS = 12, STT_LOPROC = 13, - STT_HIPROC = 15 + 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, }; inline STB @@ -612,6 +674,21 @@ enum DT DT_VERSYM = 0x6ffffff0, + // Specify the value of _GLOBAL_OFFSET_TABLE_. + DT_PPC_GOT = 0x70000000, + + // Specify the start of the .glink section. + DT_PPC64_GLINK = 0x70000000, + + // Specify the start and size of the .opd section. + DT_PPC64_OPD = 0x70000001, + DT_PPC64_OPDSZ = 0x70000002, + + // The index of an STT_SPARC_REGISTER symbol within the DT_SYMTAB + // symbol table. One dynamic entry exists for every STT_SPARC_REGISTER + // symbol in the symbol table. + DT_SPARC_REGISTER = 0x70000001, + DT_AUXILIARY = 0x7ffffffd, DT_USED = 0x7ffffffe, DT_FILTER = 0x7fffffff @@ -628,6 +705,26 @@ enum DF 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. @@ -662,6 +759,54 @@ const int VERSYM_HIDDEN = 0x8000; const int VERSYM_VERSION = 0x7fff; +// Note descriptor type codes for notes in a non-core file with an +// empty name. + +enum +{ + // A version string. + NT_VERSION = 1, + // An architecture string. + NT_ARCH = 2 +}; + +// Note descriptor type codes for notes in a non-core file with the +// name "GNU". + +enum +{ + // The minimum ABI level. This is used by the dynamic linker to + // describe the minimal kernel version on which a shared library may + // be used. Th value should be four words. Word 0 is an OS + // descriptor (see below). Word 1 is the major version of the ABI. + // Word 2 is the minor version. Word 3 is the subminor version. + NT_GNU_ABI_TAG = 1, + // Hardware capabilities information. Word 0 is the number of + // entries. Word 1 is a bitmask of enabled entries. The rest of + // the descriptor is a series of entries, where each entry is a + // single byte followed by a nul terminated string. The byte gives + // the bit number to test if enabled in the bitmask. + NT_GNU_HWCAP = 2, + // The build ID as set by the linker's --build-id option. The + // format of the descriptor depends on the build ID style. + NT_GNU_BUILD_ID = 3, + // The version of gold used to link. Th descriptor is just a + // string. + NT_GNU_GOLD_VERSION = 4 +}; + +// The OS values which may appear in word 0 of a NT_GNU_ABI_TAG note. + +enum +{ + ELF_NOTE_OS_LINUX = 0, + ELF_NOTE_OS_GNU = 1, + ELF_NOTE_OS_SOLARIS2 = 2, + ELF_NOTE_OS_FREEBSD = 3, + ELF_NOTE_OS_NETBSD = 4, + ELF_NOTE_OS_SYLLABLE = 5 +}; + } // End namespace elfcpp. // Include internal details after defining the types. @@ -692,6 +837,11 @@ struct Elf_sizes static const int rela_size = sizeof(internal::Rela_data); // Size of ELF dynamic entry. static const int dyn_size = sizeof(internal::Dyn_data); + // Size of ELF version structures. + static const int verdef_size = sizeof(internal::Verdef_data); + static const int verdaux_size = sizeof(internal::Verdaux_data); + static const int verneed_size = sizeof(internal::Verneed_data); + static const int vernaux_size = sizeof(internal::Vernaux_data); }; // Accessor class for the ELF file header. @@ -787,7 +937,7 @@ class Ehdr_write void put_e_type(Elf_Half v) { this->p_->e_type = Convert<16, big_endian>::convert_host(v); } - + void put_e_machine(Elf_Half v) { this->p_->e_machine = Convert<16, big_endian>::convert_host(v); } @@ -1378,6 +1528,46 @@ class Verdef const internal::Verdef_data* p_; }; +template +class Verdef_write +{ + public: + Verdef_write(unsigned char* p) + : p_(reinterpret_cast(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. @@ -1407,6 +1597,26 @@ class Verdaux const internal::Verdaux_data* p_; }; +template +class Verdaux_write +{ + public: + Verdaux_write(unsigned char* p) + : p_(reinterpret_cast(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 @@ -1447,6 +1657,38 @@ class Verneed const internal::Verneed_data* p_; }; +template +class Verneed_write +{ + public: + Verneed_write(unsigned char* p) + : p_(reinterpret_cast(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. @@ -1488,6 +1730,37 @@ class Vernaux const internal::Vernaux_data* p_; }; +template +class Vernaux_write +{ + public: + Vernaux_write(unsigned char* p) + : p_(reinterpret_cast(p)) + { } + + void + set_vna_hash(Elf_Word v) + { this->p_->vna_hash = Convert<32, big_endian>::convert_host(v); } + + void + set_vna_flags(Elf_Half v) + { this->p_->vna_flags = Convert<16, big_endian>::convert_host(v); } + + void + set_vna_other(Elf_Half v) + { this->p_->vna_other = Convert<16, big_endian>::convert_host(v); } + + void + set_vna_name(Elf_Word v) + { this->p_->vna_name = Convert<32, big_endian>::convert_host(v); } + + void + set_vna_next(Elf_Word v) + { this->p_->vna_next = Convert<32, big_endian>::convert_host(v); } + + private: + internal::Vernaux_data* p_; +}; } // End namespace elfcpp.