clang-format
This commit is contained in:
parent
568859d16f
commit
f598fa13a9
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -1,6 +1,5 @@
|
||||
* @markus-oberhumer @jreiser
|
||||
|
||||
/src/p_elf* @jreiser
|
||||
/src/p_lx_* @jreiser
|
||||
/src/p_mach* @jreiser
|
||||
/src/p_unix* @jreiser
|
||||
|
||||
@ -98,7 +98,7 @@ endif
|
||||
ifeq ($(shell uname),Linux)
|
||||
# Markus loves clang-format, but John hates it; find a compromise
|
||||
CLANG_FORMAT_EXCLUDE_FILES += miniacc.h stub/%.h
|
||||
CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmlin%
|
||||
CLANG_FORMAT_EXCLUDE_FILES += p_lx_% p_mach% p_unix% p_vmlin%
|
||||
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
|
||||
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
|
||||
CLANG_FORMAT_FILES += $(sort $(wildcard ../misc/cmake/try_compile/*.[ch]*))
|
||||
|
||||
406
src/p_elf.h
406
src/p_elf.h
@ -35,95 +35,87 @@ namespace N_Elf {
|
||||
|
||||
// integral types
|
||||
template <class THalf, class TWord, class TXword, class TAddr, class TOff>
|
||||
struct ElfITypes
|
||||
{
|
||||
typedef THalf Half;
|
||||
typedef TWord Word;
|
||||
typedef TXword Xword;
|
||||
typedef TAddr Addr;
|
||||
typedef TOff Off;
|
||||
typedef THalf Section;
|
||||
typedef THalf Versym;
|
||||
struct ElfITypes {
|
||||
typedef THalf Half;
|
||||
typedef TWord Word;
|
||||
typedef TXword Xword;
|
||||
typedef TAddr Addr;
|
||||
typedef TOff Off;
|
||||
typedef THalf Section;
|
||||
typedef THalf Versym;
|
||||
};
|
||||
|
||||
|
||||
// The ELF file header. This appears at the start of every ELF file.
|
||||
template <class TElfITypes>
|
||||
packed_struct(Ehdr) {
|
||||
typedef typename TElfITypes::Half Half;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
typedef typename TElfITypes::Half Half;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
|
||||
unsigned char e_ident[16]; /* Magic number and other info */
|
||||
Half e_type; /* Object file type */
|
||||
Half e_machine; /* Architecture */
|
||||
Word e_version; /* Object file version */
|
||||
Addr e_entry; /* Entry point virtual address */
|
||||
Off e_phoff; /* Program header table file offset */
|
||||
Off e_shoff; /* Section header table file offset */
|
||||
Word e_flags; /* Processor-specific flags */
|
||||
Half e_ehsize; /* ELF header size in bytes */
|
||||
Half e_phentsize; /* Program header table entry size */
|
||||
Half e_phnum; /* Program header table entry count */
|
||||
Half e_shentsize; /* Section header table entry size */
|
||||
Half e_shnum; /* Section header table entry count */
|
||||
Half e_shstrndx; /* Section header string table index */
|
||||
unsigned char e_ident[16]; /* Magic number and other info */
|
||||
Half e_type; /* Object file type */
|
||||
Half e_machine; /* Architecture */
|
||||
Word e_version; /* Object file version */
|
||||
Addr e_entry; /* Entry point virtual address */
|
||||
Off e_phoff; /* Program header table file offset */
|
||||
Off e_shoff; /* Section header table file offset */
|
||||
Word e_flags; /* Processor-specific flags */
|
||||
Half e_ehsize; /* ELF header size in bytes */
|
||||
Half e_phentsize; /* Program header table entry size */
|
||||
Half e_phnum; /* Program header table entry count */
|
||||
Half e_shentsize; /* Section header table entry size */
|
||||
Half e_shnum; /* Section header table entry count */
|
||||
Half e_shstrndx; /* Section header string table index */
|
||||
|
||||
# define WANT_EHDR_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_EHDR_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Dyn) {
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
|
||||
Xword d_tag;
|
||||
Addr d_val;
|
||||
|
||||
# define WANT_DYN_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_DYN_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Rel) {
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
|
||||
Addr r_offset;
|
||||
Xword r_info;
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Rela) {
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
|
||||
Addr r_offset;
|
||||
Xword r_info;
|
||||
Xword r_addend;
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(External_Note) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
|
||||
Word xn_namesz; // includes terminating '\0'
|
||||
Word xn_namesz; // includes terminating '\0'
|
||||
Word xn_datasz;
|
||||
Word xn_type;
|
||||
//char xn_name[N]; // terminate with '\0'
|
||||
//char xn_data[M]; // aligned to 0 mod 4
|
||||
// char xn_name[N]; // terminate with '\0'
|
||||
// char xn_data[M]; // aligned to 0 mod 4
|
||||
};
|
||||
|
||||
|
||||
} // namespace N_Elf
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// N_Elf32
|
||||
**************************************************************************/
|
||||
@ -132,72 +124,69 @@ namespace N_Elf32 {
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Phdr) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
|
||||
Word p_type; /* Segment type */
|
||||
Off p_offset; /* Segment file offset */
|
||||
Addr p_vaddr; /* Segment virtual address */
|
||||
Addr p_paddr; /* Segment physical address */
|
||||
Word p_filesz; /* Segment size in file */
|
||||
Word p_memsz; /* Segment size in memory */
|
||||
Word p_flags; /* Segment flags */
|
||||
Word p_align; /* Segment alignment */
|
||||
Word p_type; /* Segment type */
|
||||
Off p_offset; /* Segment file offset */
|
||||
Addr p_vaddr; /* Segment virtual address */
|
||||
Addr p_paddr; /* Segment physical address */
|
||||
Word p_filesz; /* Segment size in file */
|
||||
Word p_memsz; /* Segment size in memory */
|
||||
Word p_flags; /* Segment flags */
|
||||
Word p_align; /* Segment alignment */
|
||||
|
||||
# define WANT_PHDR_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_PHDR_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Shdr) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
|
||||
Word sh_name; /* Section name (string tbl index) */
|
||||
Word sh_type; /* Section type */
|
||||
Word sh_flags; /* Section flags */
|
||||
Addr sh_addr; /* Section virtual addr at execution */
|
||||
Off sh_offset; /* Section file offset */
|
||||
Word sh_size; /* Section size in bytes */
|
||||
Word sh_link; /* Link to another section */
|
||||
Word sh_info; /* Additional section information */
|
||||
Word sh_addralign; /* Section alignment */
|
||||
Word sh_entsize; /* Entry size if section holds table */
|
||||
Word sh_name; /* Section name (string tbl index) */
|
||||
Word sh_type; /* Section type */
|
||||
Word sh_flags; /* Section flags */
|
||||
Addr sh_addr; /* Section virtual addr at execution */
|
||||
Off sh_offset; /* Section file offset */
|
||||
Word sh_size; /* Section size in bytes */
|
||||
Word sh_link; /* Link to another section */
|
||||
Word sh_info; /* Additional section information */
|
||||
Word sh_addralign; /* Section alignment */
|
||||
Word sh_entsize; /* Entry size if section holds table */
|
||||
|
||||
# define WANT_SHDR_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_SHDR_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Sym) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Section Section;
|
||||
|
||||
Word st_name; /* symbol name (index into string table) */
|
||||
Addr st_value; /* symbol value */
|
||||
Word st_size; /* symbol size */
|
||||
unsigned char st_info; /* symbol type and binding */
|
||||
unsigned char st_other; /* symbol visibility */
|
||||
Section st_shndx; /* section index */
|
||||
Word st_name; /* symbol name (index into string table) */
|
||||
Addr st_value; /* symbol value */
|
||||
Word st_size; /* symbol size */
|
||||
unsigned char st_info; /* symbol type and binding */
|
||||
unsigned char st_other; /* symbol visibility */
|
||||
Section st_shndx; /* section index */
|
||||
|
||||
# define WANT_SYM_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_SYM_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace N_Elf32
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// N_Elf64
|
||||
**************************************************************************/
|
||||
@ -206,75 +195,72 @@ namespace N_Elf64 {
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Phdr) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
|
||||
Word p_type; /* Segment type */
|
||||
Word p_flags; /* Segment flags */
|
||||
Off p_offset; /* Segment file offset */
|
||||
Addr p_vaddr; /* Segment virtual address */
|
||||
Addr p_paddr; /* Segment physical address */
|
||||
Xword p_filesz; /* Segment size in file */
|
||||
Xword p_memsz; /* Segment size in memory */
|
||||
Xword p_align; /* Segment alignment */
|
||||
Word p_type; /* Segment type */
|
||||
Word p_flags; /* Segment flags */
|
||||
Off p_offset; /* Segment file offset */
|
||||
Addr p_vaddr; /* Segment virtual address */
|
||||
Addr p_paddr; /* Segment physical address */
|
||||
Xword p_filesz; /* Segment size in file */
|
||||
Xword p_memsz; /* Segment size in memory */
|
||||
Xword p_align; /* Segment alignment */
|
||||
|
||||
# define WANT_PHDR_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_PHDR_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Shdr) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Off Off;
|
||||
|
||||
Word sh_name; /* Section name (string tbl index) */
|
||||
Word sh_type; /* Section type */
|
||||
Xword sh_flags; /* Section flags */
|
||||
Addr sh_addr; /* Section virtual addr at execution */
|
||||
Off sh_offset; /* Section file offset */
|
||||
Xword sh_size; /* Section size in bytes */
|
||||
Word sh_link; /* Link to another section */
|
||||
Word sh_info; /* Additional section information */
|
||||
Xword sh_addralign; /* Section alignment */
|
||||
Xword sh_entsize; /* Entry size if section holds table */
|
||||
Word sh_name; /* Section name (string tbl index) */
|
||||
Word sh_type; /* Section type */
|
||||
Xword sh_flags; /* Section flags */
|
||||
Addr sh_addr; /* Section virtual addr at execution */
|
||||
Off sh_offset; /* Section file offset */
|
||||
Xword sh_size; /* Section size in bytes */
|
||||
Word sh_link; /* Link to another section */
|
||||
Word sh_info; /* Additional section information */
|
||||
Xword sh_addralign; /* Section alignment */
|
||||
Xword sh_entsize; /* Entry size if section holds table */
|
||||
|
||||
# define WANT_SHDR_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_SHDR_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
};
|
||||
|
||||
|
||||
template <class TElfITypes>
|
||||
packed_struct(Sym) {
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Word Word;
|
||||
typedef typename TElfITypes::Xword Xword;
|
||||
typedef typename TElfITypes::Addr Addr;
|
||||
typedef typename TElfITypes::Section Section;
|
||||
|
||||
Word st_name; /* symbol name (index into string table) */
|
||||
unsigned char st_info; /* symbol type and binding */
|
||||
unsigned char st_other; /* symbol visibility */
|
||||
Section st_shndx; /* section index */
|
||||
Addr st_value; /* symbol value */
|
||||
Xword st_size; /* symbol size */
|
||||
Word st_name; /* symbol name (index into string table) */
|
||||
unsigned char st_info; /* symbol type and binding */
|
||||
unsigned char st_other; /* symbol visibility */
|
||||
Section st_shndx; /* section index */
|
||||
Addr st_value; /* symbol value */
|
||||
Xword st_size; /* symbol size */
|
||||
|
||||
# define WANT_SYM_ENUM 1
|
||||
# include "p_elf_enum.h"
|
||||
#define WANT_SYM_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x>>4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace N_Elf64
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// aggregate types into an ElfClass
|
||||
**************************************************************************/
|
||||
@ -282,8 +268,7 @@ packed_struct(Sym) {
|
||||
namespace N_Elf {
|
||||
|
||||
template <class TP>
|
||||
struct ElfClass_32
|
||||
{
|
||||
struct ElfClass_32 {
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types (target endianness)
|
||||
@ -293,24 +278,24 @@ struct ElfClass_32
|
||||
typedef N_Elf::ElfITypes<TE16, TE32, TE32, TE32, TE32> ElfITypes;
|
||||
|
||||
// ELF types
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
typedef N_Elf32::Phdr<ElfITypes> Phdr;
|
||||
typedef N_Elf32::Shdr<ElfITypes> Shdr;
|
||||
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||
typedef N_Elf32::Sym <ElfITypes> Sym;
|
||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||
typedef N_Elf ::Dyn<ElfITypes> Dyn;
|
||||
typedef N_Elf ::Rel<ElfITypes> Rel;
|
||||
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||
typedef N_Elf32::Sym<ElfITypes> Sym;
|
||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
BeLePolicy::compileTimeAssertions();
|
||||
COMPILE_TIME_ASSERT(sizeof(Ehdr) == 52)
|
||||
COMPILE_TIME_ASSERT(sizeof(Phdr) == 32)
|
||||
COMPILE_TIME_ASSERT(sizeof(Shdr) == 40)
|
||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 8)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rel) == 8)
|
||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 8)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rel) == 8)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rela) == 12)
|
||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(External_Note) == 12)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||
@ -323,10 +308,8 @@ struct ElfClass_32
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class TP>
|
||||
struct ElfClass_64
|
||||
{
|
||||
struct ElfClass_64 {
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types (target endianness)
|
||||
@ -336,24 +319,24 @@ struct ElfClass_64
|
||||
typedef N_Elf::ElfITypes<TE16, TE32, TE64, TE64, TE64> ElfITypes;
|
||||
|
||||
// ELF types
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
typedef N_Elf64::Phdr<ElfITypes> Phdr;
|
||||
typedef N_Elf64::Shdr<ElfITypes> Shdr;
|
||||
typedef N_Elf ::Dyn <ElfITypes> Dyn;
|
||||
typedef N_Elf ::Rel <ElfITypes> Rel;
|
||||
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||
typedef N_Elf64::Sym <ElfITypes> Sym;
|
||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||
typedef N_Elf ::Dyn<ElfITypes> Dyn;
|
||||
typedef N_Elf ::Rel<ElfITypes> Rel;
|
||||
typedef N_Elf ::Rela<ElfITypes> Rela;
|
||||
typedef N_Elf64::Sym<ElfITypes> Sym;
|
||||
typedef N_Elf ::External_Note<ElfITypes> External_Note;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
BeLePolicy::compileTimeAssertions();
|
||||
COMPILE_TIME_ASSERT(sizeof(Ehdr) == 64)
|
||||
COMPILE_TIME_ASSERT(sizeof(Phdr) == 56)
|
||||
COMPILE_TIME_ASSERT(sizeof(Shdr) == 64)
|
||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rel) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(Dyn) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rel) == 16)
|
||||
COMPILE_TIME_ASSERT(sizeof(Rela) == 24)
|
||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 24)
|
||||
COMPILE_TIME_ASSERT(sizeof(Sym) == 24)
|
||||
COMPILE_TIME_ASSERT(sizeof(External_Note) == 12)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Ehdr)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(Phdr)
|
||||
@ -366,17 +349,14 @@ struct ElfClass_64
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace N_Elf
|
||||
|
||||
|
||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::HostPolicy> ElfClass_Host32;
|
||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::HostPolicy> ElfClass_Host64;
|
||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::BEPolicy> ElfClass_BE32;
|
||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::BEPolicy> ElfClass_BE64;
|
||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::LEPolicy> ElfClass_LE32;
|
||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
||||
|
||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::BEPolicy> ElfClass_BE32;
|
||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::BEPolicy> ElfClass_BE64;
|
||||
typedef N_Elf::ElfClass_32<N_BELE_CTP::LEPolicy> ElfClass_LE32;
|
||||
typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
||||
|
||||
/*************************************************************************
|
||||
// shortcuts
|
||||
@ -385,55 +365,55 @@ typedef N_Elf::ElfClass_64<N_BELE_CTP::LEPolicy> ElfClass_LE64;
|
||||
typedef ElfClass_Host32::Ehdr Elf32_Ehdr;
|
||||
typedef ElfClass_Host32::Phdr Elf32_Phdr;
|
||||
typedef ElfClass_Host32::Shdr Elf32_Shdr;
|
||||
typedef ElfClass_Host32::Dyn Elf32_Dyn;
|
||||
typedef ElfClass_Host32::Rel Elf32_Rel;
|
||||
typedef ElfClass_Host32::Dyn Elf32_Dyn;
|
||||
typedef ElfClass_Host32::Rel Elf32_Rel;
|
||||
typedef ElfClass_Host32::Rela Elf32_Rela;
|
||||
typedef ElfClass_Host32::Sym Elf32_Sym;
|
||||
typedef ElfClass_Host32::External_Note Elf32_External_Note;
|
||||
typedef ElfClass_Host32::Sym Elf32_Sym;
|
||||
typedef ElfClass_Host32::External_Note Elf32_External_Note;
|
||||
|
||||
typedef ElfClass_Host64::Ehdr Elf64_Ehdr;
|
||||
typedef ElfClass_Host64::Phdr Elf64_Phdr;
|
||||
typedef ElfClass_Host64::Shdr Elf64_Shdr;
|
||||
typedef ElfClass_Host64::Dyn Elf64_Dyn;
|
||||
typedef ElfClass_Host64::Rel Elf64_Rel;
|
||||
typedef ElfClass_Host64::Dyn Elf64_Dyn;
|
||||
typedef ElfClass_Host64::Rel Elf64_Rel;
|
||||
typedef ElfClass_Host64::Rela Elf64_Rela;
|
||||
typedef ElfClass_Host64::Sym Elf64_Sym;
|
||||
typedef ElfClass_Host64::External_Note Elf64_External_Note;
|
||||
typedef ElfClass_Host64::Sym Elf64_Sym;
|
||||
typedef ElfClass_Host64::External_Note Elf64_External_Note;
|
||||
|
||||
typedef ElfClass_BE32::Ehdr Elf_BE32_Ehdr;
|
||||
typedef ElfClass_BE32::Phdr Elf_BE32_Phdr;
|
||||
typedef ElfClass_BE32::Shdr Elf_BE32_Shdr;
|
||||
typedef ElfClass_BE32::Dyn Elf_BE32_Dyn;
|
||||
typedef ElfClass_BE32::Rel Elf_BE32_Rel;
|
||||
typedef ElfClass_BE32::Rela Elf_BE32_Rela;
|
||||
typedef ElfClass_BE32::Sym Elf_BE32_Sym;
|
||||
typedef ElfClass_BE32::External_Note Elf_BE32_External_Note;
|
||||
typedef ElfClass_BE32::Ehdr Elf_BE32_Ehdr;
|
||||
typedef ElfClass_BE32::Phdr Elf_BE32_Phdr;
|
||||
typedef ElfClass_BE32::Shdr Elf_BE32_Shdr;
|
||||
typedef ElfClass_BE32::Dyn Elf_BE32_Dyn;
|
||||
typedef ElfClass_BE32::Rel Elf_BE32_Rel;
|
||||
typedef ElfClass_BE32::Rela Elf_BE32_Rela;
|
||||
typedef ElfClass_BE32::Sym Elf_BE32_Sym;
|
||||
typedef ElfClass_BE32::External_Note Elf_BE32_External_Note;
|
||||
|
||||
typedef ElfClass_BE64::Ehdr Elf_BE64_Ehdr;
|
||||
typedef ElfClass_BE64::Phdr Elf_BE64_Phdr;
|
||||
typedef ElfClass_BE64::Shdr Elf_BE64_Shdr;
|
||||
typedef ElfClass_BE64::Dyn Elf_BE64_Dyn;
|
||||
typedef ElfClass_BE64::Rel Elf_BE64_Rel;
|
||||
typedef ElfClass_BE64::Rela Elf_BE64_Rela;
|
||||
typedef ElfClass_BE64::Sym Elf_BE64_Sym;
|
||||
typedef ElfClass_BE64::External_Note Elf_BE64_External_Note;
|
||||
typedef ElfClass_BE64::Ehdr Elf_BE64_Ehdr;
|
||||
typedef ElfClass_BE64::Phdr Elf_BE64_Phdr;
|
||||
typedef ElfClass_BE64::Shdr Elf_BE64_Shdr;
|
||||
typedef ElfClass_BE64::Dyn Elf_BE64_Dyn;
|
||||
typedef ElfClass_BE64::Rel Elf_BE64_Rel;
|
||||
typedef ElfClass_BE64::Rela Elf_BE64_Rela;
|
||||
typedef ElfClass_BE64::Sym Elf_BE64_Sym;
|
||||
typedef ElfClass_BE64::External_Note Elf_BE64_External_Note;
|
||||
|
||||
typedef ElfClass_LE32::Ehdr Elf_LE32_Ehdr;
|
||||
typedef ElfClass_LE32::Phdr Elf_LE32_Phdr;
|
||||
typedef ElfClass_LE32::Shdr Elf_LE32_Shdr;
|
||||
typedef ElfClass_LE32::Dyn Elf_LE32_Dyn;
|
||||
typedef ElfClass_LE32::Rel Elf_LE32_Rel;
|
||||
typedef ElfClass_LE32::Rela Elf_LE32_Rela;
|
||||
typedef ElfClass_LE32::Sym Elf_LE32_Sym;
|
||||
typedef ElfClass_LE32::External_Note Elf_LE32_External_Note;
|
||||
typedef ElfClass_LE32::Ehdr Elf_LE32_Ehdr;
|
||||
typedef ElfClass_LE32::Phdr Elf_LE32_Phdr;
|
||||
typedef ElfClass_LE32::Shdr Elf_LE32_Shdr;
|
||||
typedef ElfClass_LE32::Dyn Elf_LE32_Dyn;
|
||||
typedef ElfClass_LE32::Rel Elf_LE32_Rel;
|
||||
typedef ElfClass_LE32::Rela Elf_LE32_Rela;
|
||||
typedef ElfClass_LE32::Sym Elf_LE32_Sym;
|
||||
typedef ElfClass_LE32::External_Note Elf_LE32_External_Note;
|
||||
|
||||
typedef ElfClass_LE64::Ehdr Elf_LE64_Ehdr;
|
||||
typedef ElfClass_LE64::Phdr Elf_LE64_Phdr;
|
||||
typedef ElfClass_LE64::Shdr Elf_LE64_Shdr;
|
||||
typedef ElfClass_LE64::Dyn Elf_LE64_Dyn;
|
||||
typedef ElfClass_LE64::Rel Elf_LE64_Rel;
|
||||
typedef ElfClass_LE64::Rela Elf_LE64_Rela;
|
||||
typedef ElfClass_LE64::Sym Elf_LE64_Sym;
|
||||
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
|
||||
typedef ElfClass_LE64::Ehdr Elf_LE64_Ehdr;
|
||||
typedef ElfClass_LE64::Phdr Elf_LE64_Phdr;
|
||||
typedef ElfClass_LE64::Shdr Elf_LE64_Shdr;
|
||||
typedef ElfClass_LE64::Dyn Elf_LE64_Dyn;
|
||||
typedef ElfClass_LE64::Rel Elf_LE64_Rel;
|
||||
typedef ElfClass_LE64::Rela Elf_LE64_Rela;
|
||||
typedef ElfClass_LE64::Sym Elf_LE64_Sym;
|
||||
typedef ElfClass_LE64::External_Note Elf_LE64_External_Note;
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
484
src/p_elf_enum.h
484
src/p_elf_enum.h
@ -25,7 +25,6 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// Use the preprocessor to work around
|
||||
// - that the types embedding these enums have to be PODs, and
|
||||
@ -36,294 +35,291 @@
|
||||
|
||||
#ifdef WANT_EHDR_ENUM
|
||||
#undef WANT_EHDR_ENUM
|
||||
enum { // indices for e_ident[16]
|
||||
EI_CLASS = 4,
|
||||
EI_DATA = 5, /* Data encoding */
|
||||
EI_VERSION = 6,
|
||||
EI_OSABI = 7,
|
||||
EI_ABIVERSION = 8,
|
||||
};
|
||||
enum { // e_ident[EI_CLASS]
|
||||
ELFCLASS32 = 1, /* 32-bit objects */
|
||||
ELFCLASS64 = 2, /* 64-bit objects */
|
||||
};
|
||||
enum { // e_ident[EI_DATA]
|
||||
ELFDATA2LSB = 1, /* 2's complement, little endian */
|
||||
ELFDATA2MSB = 2, /* 2's complement, big endian */
|
||||
};
|
||||
enum { // e_ident[EI_OSABI]
|
||||
ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
|
||||
ELFOSABI_NETBSD = 2,
|
||||
ELFOSABI_LINUX = 3,
|
||||
ELFOSABI_SOLARIS = 6,
|
||||
ELFOSABI_AIX = 7,
|
||||
ELFOSABI_FREEBSD = 9,
|
||||
ELFOSABI_OPENBSD = 12,
|
||||
ELFOSABI_ARM = 97,
|
||||
ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
|
||||
};
|
||||
enum { // e_type
|
||||
ET_NONE = 0, /* No file type */
|
||||
ET_REL = 1, /* Relocatable file */
|
||||
ET_EXEC = 2, /* Executable file */
|
||||
ET_DYN = 3, /* Shared object file */
|
||||
ET_CORE = 4, /* Core file */
|
||||
};
|
||||
enum { // e_machine
|
||||
EM_386 = 3, // i386
|
||||
EM_MIPS = 8,
|
||||
EM_MIPS_RS3_LE = 10, // MIPS R3000 little-endian
|
||||
EM_PPC = 20,
|
||||
EM_PPC64 = 21,
|
||||
EM_ARM = 40,
|
||||
EM_X86_64 = 62, // amd64
|
||||
EM_AMD64 = EM_X86_64,
|
||||
EM_AARCH64 = 183, // arm64
|
||||
EM_ARM64 = EM_AARCH64,
|
||||
EM_RISCV = 243, // risc-v
|
||||
EM_LOONGARCH = 258,
|
||||
};
|
||||
enum { // e_version
|
||||
EV_CURRENT = 1,
|
||||
};
|
||||
enum { // indices for e_ident[16]
|
||||
EI_CLASS = 4,
|
||||
EI_DATA = 5, /* Data encoding */
|
||||
EI_VERSION = 6,
|
||||
EI_OSABI = 7,
|
||||
EI_ABIVERSION = 8,
|
||||
};
|
||||
enum { // e_ident[EI_CLASS]
|
||||
ELFCLASS32 = 1, /* 32-bit objects */
|
||||
ELFCLASS64 = 2, /* 64-bit objects */
|
||||
};
|
||||
enum { // e_ident[EI_DATA]
|
||||
ELFDATA2LSB = 1, /* 2's complement, little endian */
|
||||
ELFDATA2MSB = 2, /* 2's complement, big endian */
|
||||
};
|
||||
enum { // e_ident[EI_OSABI]
|
||||
ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
|
||||
ELFOSABI_NETBSD = 2,
|
||||
ELFOSABI_LINUX = 3,
|
||||
ELFOSABI_SOLARIS = 6,
|
||||
ELFOSABI_AIX = 7,
|
||||
ELFOSABI_FREEBSD = 9,
|
||||
ELFOSABI_OPENBSD = 12,
|
||||
ELFOSABI_ARM = 97,
|
||||
ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
|
||||
};
|
||||
enum { // e_type
|
||||
ET_NONE = 0, /* No file type */
|
||||
ET_REL = 1, /* Relocatable file */
|
||||
ET_EXEC = 2, /* Executable file */
|
||||
ET_DYN = 3, /* Shared object file */
|
||||
ET_CORE = 4, /* Core file */
|
||||
};
|
||||
enum { // e_machine
|
||||
EM_386 = 3, // i386
|
||||
EM_MIPS = 8,
|
||||
EM_MIPS_RS3_LE = 10, // MIPS R3000 little-endian
|
||||
EM_PPC = 20,
|
||||
EM_PPC64 = 21,
|
||||
EM_ARM = 40,
|
||||
EM_X86_64 = 62, // amd64
|
||||
EM_AMD64 = EM_X86_64,
|
||||
EM_AARCH64 = 183, // arm64
|
||||
EM_ARM64 = EM_AARCH64,
|
||||
EM_RISCV = 243, // risc-v
|
||||
EM_LOONGARCH = 258,
|
||||
};
|
||||
enum { // e_version
|
||||
EV_CURRENT = 1,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_PHDR_ENUM
|
||||
#undef WANT_PHDR_ENUM
|
||||
enum { // p_type
|
||||
PT_NULL = 0, /* Ignore: a "comment" */
|
||||
PT_LOAD = 1, /* Loadable program segment */
|
||||
PT_DYNAMIC = 2, /* Dynamic linking information */
|
||||
PT_INTERP = 3, /* Name of program interpreter */
|
||||
PT_NOTE = 4, /* Auxiliary information (esp. OpenBSD) */
|
||||
PT_PHDR = 6, /* Entry for header table itself */
|
||||
PT_NUM = 8, /* Number of defined types in low range */
|
||||
PT_GNU_STACK = 0x6474e551, /* Indicates stack executability */
|
||||
PT_GNU_RELRO = 0x6474e552, /* Read-only after relocation */
|
||||
};
|
||||
enum { // p_type
|
||||
PT_NULL = 0, /* Ignore: a "comment" */
|
||||
PT_LOAD = 1, /* Loadable program segment */
|
||||
PT_DYNAMIC = 2, /* Dynamic linking information */
|
||||
PT_INTERP = 3, /* Name of program interpreter */
|
||||
PT_NOTE = 4, /* Auxiliary information (esp. OpenBSD) */
|
||||
PT_PHDR = 6, /* Entry for header table itself */
|
||||
PT_NUM = 8, /* Number of defined types in low range */
|
||||
PT_GNU_STACK = 0x6474e551, /* Indicates stack executability */
|
||||
PT_GNU_RELRO = 0x6474e552, /* Read-only after relocation */
|
||||
};
|
||||
|
||||
enum { // p_flags
|
||||
PF_X = 1, /* Segment is executable */
|
||||
PF_W = 2, /* Segment is writable */
|
||||
PF_R = 4, /* Segment is readable */
|
||||
};
|
||||
enum { // p_flags
|
||||
PF_X = 1, /* Segment is executable */
|
||||
PF_W = 2, /* Segment is writable */
|
||||
PF_R = 4, /* Segment is readable */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_SHDR_ENUM
|
||||
#undef WANT_SHDR_ENUM
|
||||
enum { // sh_type
|
||||
SHT_NULL = 0, /* Section header table entry unused */
|
||||
SHT_PROGBITS = 1, /* Program data */
|
||||
SHT_SYMTAB = 2, /* Symbol table */
|
||||
SHT_STRTAB = 3, /* String table */
|
||||
SHT_RELA = 4, /* Relocation entries with addends */
|
||||
SHT_HASH = 5, /* Symbol hash table */
|
||||
SHT_DYNAMIC = 6, /* Dynamic linking information */
|
||||
SHT_NOTE = 7, /* Notes */
|
||||
SHT_NOBITS = 8, /* Program space with no data (bss) */
|
||||
SHT_REL = 9, /* Relocation entries, no addends */
|
||||
SHT_SHLIB = 10, /* Reserved */
|
||||
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
|
||||
/* 12, 13 hole */
|
||||
SHT_INIT_ARRAY = 14, /* Array of constructors */
|
||||
SHT_FINI_ARRAY = 15, /* Array of destructors */
|
||||
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
|
||||
SHT_GROUP = 17, /* Section group */
|
||||
SHT_SYMTAB_SHNDX = 18, /* Extended section indices */
|
||||
SHT_GNU_HASH = 0x6ffffff6, /* GNU-style hash table. */
|
||||
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
|
||||
SHT_GNU_verdef = 0x6ffffffd, /* Version definition section. */
|
||||
SHT_GNU_verneed = 0x6ffffffe, /* Version needs section. */
|
||||
SHT_GNU_versym = 0x6fffffff, /* Version symbol table. */
|
||||
enum { // sh_type
|
||||
SHT_NULL = 0, /* Section header table entry unused */
|
||||
SHT_PROGBITS = 1, /* Program data */
|
||||
SHT_SYMTAB = 2, /* Symbol table */
|
||||
SHT_STRTAB = 3, /* String table */
|
||||
SHT_RELA = 4, /* Relocation entries with addends */
|
||||
SHT_HASH = 5, /* Symbol hash table */
|
||||
SHT_DYNAMIC = 6, /* Dynamic linking information */
|
||||
SHT_NOTE = 7, /* Notes */
|
||||
SHT_NOBITS = 8, /* Program space with no data (bss) */
|
||||
SHT_REL = 9, /* Relocation entries, no addends */
|
||||
SHT_SHLIB = 10, /* Reserved */
|
||||
SHT_DYNSYM = 11, /* Dynamic linker symbol table */
|
||||
/* 12, 13 hole */
|
||||
SHT_INIT_ARRAY = 14, /* Array of constructors */
|
||||
SHT_FINI_ARRAY = 15, /* Array of destructors */
|
||||
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
|
||||
SHT_GROUP = 17, /* Section group */
|
||||
SHT_SYMTAB_SHNDX = 18, /* Extended section indices */
|
||||
SHT_GNU_HASH = 0x6ffffff6, /* GNU-style hash table. */
|
||||
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
|
||||
SHT_GNU_verdef = 0x6ffffffd, /* Version definition section. */
|
||||
SHT_GNU_verneed = 0x6ffffffe, /* Version needs section. */
|
||||
SHT_GNU_versym = 0x6fffffff, /* Version symbol table. */
|
||||
|
||||
SHT_LOOS = 0x60000000, /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */
|
||||
SHT_LOPROC = 0x70000000, /* Start of processor-specific */
|
||||
SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3), /* ARM attributes section. */
|
||||
};
|
||||
SHT_LOOS = 0x60000000, /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */
|
||||
SHT_LOPROC = 0x70000000, /* Start of processor-specific */
|
||||
SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3), /* ARM attributes section. */
|
||||
};
|
||||
|
||||
enum { // sh_flags
|
||||
SHF_WRITE = (1 << 0), /* Writable */
|
||||
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
|
||||
SHF_EXECINSTR = (1 << 2), /* Executable */
|
||||
SHF_MERGE = (1 << 4), /* Might be merged */
|
||||
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
|
||||
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
|
||||
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
|
||||
};
|
||||
enum { // sh_flags
|
||||
SHF_WRITE = (1 << 0), /* Writable */
|
||||
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
|
||||
SHF_EXECINSTR = (1 << 2), /* Executable */
|
||||
SHF_MERGE = (1 << 4), /* Might be merged */
|
||||
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
|
||||
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
|
||||
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_DYN_ENUM
|
||||
#undef WANT_DYN_ENUM
|
||||
enum { // d_tag
|
||||
DT_NULL = 0, /* End flag */
|
||||
DT_NEEDED = 1, /* Name of needed library */
|
||||
DT_PLTRELSZ = 2, /* Size in bytes of PLT relocs */
|
||||
DT_PLTGOT = 3, /* Processor defined value */
|
||||
DT_HASH = 4, /* Hash table of symbol names */
|
||||
DT_STRTAB = 5, /* String table */
|
||||
DT_SYMTAB = 6, /* Symbol table */
|
||||
DT_RELA = 7, /* Relocations which do contain an addend */
|
||||
DT_RELASZ = 8, /* Total size of Rela relocs */
|
||||
DT_RELAENT = 9, /* Size of one RELA relocation */
|
||||
DT_STRSZ = 10, /* Size of string table */
|
||||
DT_SYMENT = 11, /* Size of one symbol table entry */
|
||||
DT_INIT = 12, /* Address of init function */
|
||||
DT_FINI = 13, /* Address of termination function */
|
||||
enum { // d_tag
|
||||
DT_NULL = 0, /* End flag */
|
||||
DT_NEEDED = 1, /* Name of needed library */
|
||||
DT_PLTRELSZ = 2, /* Size in bytes of PLT relocs */
|
||||
DT_PLTGOT = 3, /* Processor defined value */
|
||||
DT_HASH = 4, /* Hash table of symbol names */
|
||||
DT_STRTAB = 5, /* String table */
|
||||
DT_SYMTAB = 6, /* Symbol table */
|
||||
DT_RELA = 7, /* Relocations which do contain an addend */
|
||||
DT_RELASZ = 8, /* Total size of Rela relocs */
|
||||
DT_RELAENT = 9, /* Size of one RELA relocation */
|
||||
DT_STRSZ = 10, /* Size of string table */
|
||||
DT_SYMENT = 11, /* Size of one symbol table entry */
|
||||
DT_INIT = 12, /* Address of init function */
|
||||
DT_FINI = 13, /* Address of termination function */
|
||||
|
||||
DT_REL = 17, /* Relocations which contain no addend */
|
||||
DT_RELSZ = 18, /* Total size of Rel relocs */
|
||||
DT_RELENT = 19, /* Size of one Rel relocation */
|
||||
DT_PLTREL = 20, /* Type of reloc in PLT */
|
||||
DT_TEXTREL = 22, /* Reloc might modify .text */
|
||||
DT_JMPREL = 23, /* Address of PLT relocs */
|
||||
DT_INIT_ARRAY = 25, /* Array with addresses of init fct */
|
||||
DT_FINI_ARRAY = 26, /* Array with addresses of fini fct */
|
||||
DT_INIT_ARRAYSZ= 27, /* size in bytes */
|
||||
DT_FINI_ARRAYSZ= 28, /* size in bytes */
|
||||
DT_PREINIT_ARRAY = 32, /* Array with addresses of preinit fct*/
|
||||
DT_PREINIT_ARRAYSZ= 33, /* size in bytes */
|
||||
DT_NUM = 35, /* end of easy range */
|
||||
DT_REL = 17, /* Relocations which contain no addend */
|
||||
DT_RELSZ = 18, /* Total size of Rel relocs */
|
||||
DT_RELENT = 19, /* Size of one Rel relocation */
|
||||
DT_PLTREL = 20, /* Type of reloc in PLT */
|
||||
DT_TEXTREL = 22, /* Reloc might modify .text */
|
||||
DT_JMPREL = 23, /* Address of PLT relocs */
|
||||
DT_INIT_ARRAY = 25, /* Array with addresses of init fct */
|
||||
DT_FINI_ARRAY = 26, /* Array with addresses of fini fct */
|
||||
DT_INIT_ARRAYSZ = 27, /* size in bytes */
|
||||
DT_FINI_ARRAYSZ = 28, /* size in bytes */
|
||||
DT_PREINIT_ARRAY = 32, /* Array with addresses of preinit fct*/
|
||||
DT_PREINIT_ARRAYSZ = 33, /* size in bytes */
|
||||
DT_NUM = 35, /* end of easy range */
|
||||
|
||||
DT_CHECKSUM = 0x6ffffdf8, /* Only for prelink? */
|
||||
DT_GNU_HASH = 0x6ffffef5, /* GNU-style hash table */
|
||||
DT_VERSYM = 0x6ffffff0, /* version[] for each symbol */
|
||||
DT_FLAGS_1 = 0x6ffffffb, /* DF_1_* */
|
||||
DT_VERDEF = 0x6ffffffc, /* version definitions[] */
|
||||
DT_VERNEED = 0x6ffffffe, /* version[] needed */
|
||||
};
|
||||
enum { // DT_FLAGS_1
|
||||
DF_1_NOW = 0x00000001, /* Set RTLD_NOW for this object. */
|
||||
DF_1_PIE = 0x08000000, // Position-Independent Executable (main program)
|
||||
};
|
||||
DT_CHECKSUM = 0x6ffffdf8, /* Only for prelink? */
|
||||
DT_GNU_HASH = 0x6ffffef5, /* GNU-style hash table */
|
||||
DT_VERSYM = 0x6ffffff0, /* version[] for each symbol */
|
||||
DT_FLAGS_1 = 0x6ffffffb, /* DF_1_* */
|
||||
DT_VERDEF = 0x6ffffffc, /* version definitions[] */
|
||||
DT_VERNEED = 0x6ffffffe, /* version[] needed */
|
||||
};
|
||||
enum { // DT_FLAGS_1
|
||||
DF_1_NOW = 0x00000001, /* Set RTLD_NOW for this object. */
|
||||
DF_1_PIE = 0x08000000, // Position-Independent Executable (main program)
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_SYM_ENUM
|
||||
#undef WANT_SYM_ENUM
|
||||
enum { // st_bind (high 4 bits of st_info)
|
||||
STB_LOCAL = 0, /* Local symbol */
|
||||
STB_GLOBAL = 1, /* Global symbol */
|
||||
STB_WEAK = 2, /* Weak symbol */
|
||||
};
|
||||
enum { // st_bind (high 4 bits of st_info)
|
||||
STB_LOCAL = 0, /* Local symbol */
|
||||
STB_GLOBAL = 1, /* Global symbol */
|
||||
STB_WEAK = 2, /* Weak symbol */
|
||||
};
|
||||
|
||||
enum { // st_type (low 4 bits of st_info)
|
||||
STT_NOTYPE = 0, /* Symbol type is unspecified */
|
||||
STT_OBJECT = 1, /* Symbol is a data object */
|
||||
STT_FUNC = 2, /* Symbol is a code object */
|
||||
STT_SECTION = 3, /* Symbol associated with a section */
|
||||
STT_FILE = 4, /* Symbol's name is file name */
|
||||
STT_COMMON = 5, /* Symbol is a common data object */
|
||||
STT_TLS = 6, /* Symbol is thread-local data object*/
|
||||
};
|
||||
enum { // st_type (low 4 bits of st_info)
|
||||
STT_NOTYPE = 0, /* Symbol type is unspecified */
|
||||
STT_OBJECT = 1, /* Symbol is a data object */
|
||||
STT_FUNC = 2, /* Symbol is a code object */
|
||||
STT_SECTION = 3, /* Symbol associated with a section */
|
||||
STT_FILE = 4, /* Symbol's name is file name */
|
||||
STT_COMMON = 5, /* Symbol is a common data object */
|
||||
STT_TLS = 6, /* Symbol is thread-local data object*/
|
||||
};
|
||||
|
||||
enum { // st_other (visibility)
|
||||
STV_DEFAULT = 0, /* Default symbol visibility rules */
|
||||
STV_INTERNAL = 1, /* Processor specific hidden class */
|
||||
STV_HIDDEN = 2, /* Sym unavailable in other modules */
|
||||
STV_PROTECTED= 3, /* Not preemptible, not exported */
|
||||
};
|
||||
enum { // st_other (visibility)
|
||||
STV_DEFAULT = 0, /* Default symbol visibility rules */
|
||||
STV_INTERNAL = 1, /* Processor specific hidden class */
|
||||
STV_HIDDEN = 2, /* Sym unavailable in other modules */
|
||||
STV_PROTECTED = 3, /* Not preemptible, not exported */
|
||||
};
|
||||
|
||||
enum { // st_shndx
|
||||
SHN_UNDEF = 0, /* Undefined section */
|
||||
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
|
||||
SHN_COMMON = 0xfff2, /* Associated symbol is common */
|
||||
};
|
||||
enum { // st_shndx
|
||||
SHN_UNDEF = 0, /* Undefined section */
|
||||
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
|
||||
SHN_COMMON = 0xfff2, /* Associated symbol is common */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WANT_REL_ENUM //{
|
||||
#ifdef WANT_REL_ENUM //{
|
||||
#undef WANT_REL_ENUM
|
||||
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
||||
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned)x; }
|
||||
static inline unsigned ELF32_R_SYM(unsigned x) { return x >> 8; }
|
||||
static inline unsigned ELF64_R_SYM(upx_uint64_t x) { return x >> 32; }
|
||||
static inline unsigned ELF32_R_INFO(unsigned sym, unsigned type)
|
||||
{ return (sym << 8) + (type & 0xff); }
|
||||
static inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type)
|
||||
{ return ((upx_uint64_t)sym << 32) + type; }
|
||||
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
||||
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned) x; }
|
||||
static inline unsigned ELF32_R_SYM(unsigned x) { return x >> 8; }
|
||||
static inline unsigned ELF64_R_SYM(upx_uint64_t x) { return x >> 32; }
|
||||
static inline unsigned ELF32_R_INFO(unsigned sym, unsigned type) {
|
||||
return (sym << 8) + (type & 0xff);
|
||||
}
|
||||
static inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type) {
|
||||
return ((upx_uint64_t) sym << 32) + type;
|
||||
}
|
||||
|
||||
# undef R_PPC_RELATIVE
|
||||
# undef R_PPC64_RELATIVE
|
||||
# undef R_PPC_JMP_SLOT
|
||||
# undef R_PPC64_JMP_SLOT
|
||||
enum { // relocation types
|
||||
R_386_RELATIVE = 8,
|
||||
R_AARCH64_RELATIVE = 1027,
|
||||
R_ARM_RELATIVE = 23,
|
||||
R_PPC_RELATIVE = 22,
|
||||
R_PPC64_RELATIVE = R_PPC_RELATIVE,
|
||||
R_X86_64_RELATIVE = 8,
|
||||
#undef R_PPC_RELATIVE
|
||||
#undef R_PPC64_RELATIVE
|
||||
#undef R_PPC_JMP_SLOT
|
||||
#undef R_PPC64_JMP_SLOT
|
||||
enum { // relocation types
|
||||
R_386_RELATIVE = 8,
|
||||
R_AARCH64_RELATIVE = 1027,
|
||||
R_ARM_RELATIVE = 23,
|
||||
R_PPC_RELATIVE = 22,
|
||||
R_PPC64_RELATIVE = R_PPC_RELATIVE,
|
||||
R_X86_64_RELATIVE = 8,
|
||||
|
||||
R_386_JMP_SLOT = 7,
|
||||
R_AARCH64_JUMP_SLOT = 1026,
|
||||
R_ARM_JUMP_SLOT = 22,
|
||||
R_PPC_JMP_SLOT = 21,
|
||||
R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT,
|
||||
R_X86_64_JUMP_SLOT = 7,
|
||||
R_386_JMP_SLOT = 7,
|
||||
R_AARCH64_JUMP_SLOT = 1026,
|
||||
R_ARM_JUMP_SLOT = 22,
|
||||
R_PPC_JMP_SLOT = 21,
|
||||
R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT,
|
||||
R_X86_64_JUMP_SLOT = 7,
|
||||
|
||||
R_386_32 = 1,
|
||||
R_ARM_ABS32 = 2,
|
||||
R_ARM_GLOB_DAT = 21,
|
||||
R_MIPS_32 = 2,
|
||||
R_386_32 = 1,
|
||||
R_ARM_ABS32 = 2,
|
||||
R_ARM_GLOB_DAT = 21,
|
||||
R_MIPS_32 = 2,
|
||||
|
||||
R_386_GLOB_DAT = 6,
|
||||
R_X86_64_64 = 1,
|
||||
R_AARCH64_ABS64 = 257,
|
||||
R_AARCH64_GLOB_DAT = 1025,
|
||||
R_386_GLOB_DAT = 6,
|
||||
R_X86_64_64 = 1,
|
||||
R_AARCH64_ABS64 = 257,
|
||||
R_AARCH64_GLOB_DAT = 1025,
|
||||
|
||||
};
|
||||
#endif //}
|
||||
};
|
||||
#endif //}
|
||||
|
||||
#ifdef WANT_NHDR_ENUM
|
||||
#undef WANT_NHDR_ENUM
|
||||
enum { // ELF PT_NOTE types
|
||||
enum { // ELF PT_NOTE types
|
||||
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||
NT_GNU_ABI_TAG = 1,
|
||||
NT_GNU_HWCAP = 2,
|
||||
NT_GNU_BUILD_ID = 3,
|
||||
NT_GNU_ABI_TAG = 1,
|
||||
NT_GNU_HWCAP = 2,
|
||||
NT_GNU_BUILD_ID = 3,
|
||||
|
||||
#define ELF_NOTE_OPENBSD_NAME "OpenBSD\0"
|
||||
NHDR_OPENBSD_TAG = 1,
|
||||
NHDR_OPENBSD_TAG = 1,
|
||||
|
||||
#define ELF_NOTE_NETBSD_NAME "NetBSD\0"
|
||||
NHDR_NETBSD_TAG = 1,
|
||||
NHDR_CHECKSUM_TAG = 2,
|
||||
NHDR_PAX_TAG = 3,
|
||||
};
|
||||
NHDR_NETBSD_TAG = 1,
|
||||
NHDR_CHECKSUM_TAG = 2,
|
||||
NHDR_PAX_TAG = 3,
|
||||
};
|
||||
|
||||
enum { // descsz descriptor sizes
|
||||
GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
|
||||
NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
|
||||
OPENBSD_DESCSZ = 4, // 32-bit zero
|
||||
// CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
|
||||
PAX_DESCSZ = 4, // 32-bit mask
|
||||
};
|
||||
enum { // descsz descriptor sizes
|
||||
GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
|
||||
NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
|
||||
OPENBSD_DESCSZ = 4, // 32-bit zero
|
||||
// CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
|
||||
PAX_DESCSZ = 4, // 32-bit mask
|
||||
};
|
||||
|
||||
enum { // GNU OS/version
|
||||
GNU_OS_LINUX = 0,
|
||||
GNU_OS_HURD = 1,
|
||||
GNU_OS_SOLARIS = 2,
|
||||
};
|
||||
enum { // GNU OS/version
|
||||
GNU_OS_LINUX = 0,
|
||||
GNU_OS_HURD = 1,
|
||||
GNU_OS_SOLARIS = 2,
|
||||
};
|
||||
|
||||
enum { // NetBSD checksum methods
|
||||
CHECKSUM_CRC32 = 1,
|
||||
CHECKSUM_MD5 = 2,
|
||||
CHECKSUM_SHA1 = 3,
|
||||
CHECKSUM_SHA256 = 4,
|
||||
};
|
||||
enum { // NetBSD checksum methods
|
||||
CHECKSUM_CRC32 = 1,
|
||||
CHECKSUM_MD5 = 2,
|
||||
CHECKSUM_SHA1 = 3,
|
||||
CHECKSUM_SHA256 = 4,
|
||||
};
|
||||
|
||||
#define ELF_NOTE_PAX_NAME "PaX\0"
|
||||
enum { // NetBSD PaX bit values
|
||||
PAX_MPROTECT = (1<<0), /* force enable Mprotect */
|
||||
PAX_NOMPROTECT = (1<<1), /* force disable Mprotect */
|
||||
PAX_GUARD = (1<<2), /* force enable SEGVguard */
|
||||
PAX_NOGUARD = (1<<3), /* force disable SEGVguard */
|
||||
PAX_ASLR = (1<<4), /* force enable ASLR */
|
||||
PAX_NOASLR = (1<<5), /* force disable ASLR */
|
||||
};
|
||||
enum { // NetBSD PaX bit values
|
||||
PAX_MPROTECT = (1 << 0), /* force enable Mprotect */
|
||||
PAX_NOMPROTECT = (1 << 1), /* force disable Mprotect */
|
||||
PAX_GUARD = (1 << 2), /* force enable SEGVguard */
|
||||
PAX_NOGUARD = (1 << 3), /* force disable SEGVguard */
|
||||
PAX_ASLR = (1 << 4), /* force enable ASLR */
|
||||
PAX_NOASLR = (1 << 5), /* force disable ASLR */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user