New types and OS/ABI in dump

Added some types and strings, table for OS/ABI, added OS/ABI and ABI version to dump
This commit is contained in:
tgotic 2022-09-22 11:23:23 +02:00 committed by Serge Lamikhov-Center
parent cccc78a37b
commit c546c16222
3 changed files with 84 additions and 7 deletions

View File

@ -359,6 +359,7 @@ constexpr unsigned char ELFOSABI_NONE = 0; // No extensions or unspecified
constexpr unsigned char ELFOSABI_HPUX = 1; // Hewlett-Packard HP-UX
constexpr unsigned char ELFOSABI_NETBSD = 2; // NetBSD
constexpr unsigned char ELFOSABI_LINUX = 3; // Linux
constexpr unsigned char ELFOSABI_HURD = 4; // GNU Hurd
constexpr unsigned char ELFOSABI_SOLARIS = 6; // Sun Solaris
constexpr unsigned char ELFOSABI_AIX = 7; // AIX
constexpr unsigned char ELFOSABI_IRIX = 8; // IRIX
@ -370,6 +371,10 @@ constexpr unsigned char ELFOSABI_OPENVMS = 13; // Open VMS
constexpr unsigned char ELFOSABI_NSK = 14; // Hewlett-Packard Non-Stop Kernel
constexpr unsigned char ELFOSABI_AROS = 15; // Amiga Research OS
constexpr unsigned char ELFOSABI_FENIXOS = 16; // The FenixOS highly scalable multi-core OS
constexpr unsigned char ELFOSABI_NUXI = 17; // Nuxi CloudABI
constexpr unsigned char ELFOSABI_OPENVOS = 18; // Stratus Technologies OpenVOS
constexpr unsigned char ELFOSABI_ARM = 97; // ARM
constexpr unsigned char ELFOSABI_STANDALONE = 255; // Standalone (embedded) application
// 64-255 Architecture-specific value range
// AMDGPU OS for HSA compatible compute kernels
@ -517,6 +522,11 @@ constexpr Elf_Word SHT_GNU_versym = 0x6fffffff;
constexpr Elf_Word SHT_LOOS = 0x60000000;
constexpr Elf_Word SHT_HIOS = 0x6fffffff;
constexpr Elf_Word SHT_LOPROC = 0x70000000;
constexpr Elf_Word SHT_ARM_EXIDX = 0x70000001;
constexpr Elf_Word SHT_ARM_PREEMPTMAP = 0x70000002;
constexpr Elf_Word SHT_ARM_ATTRIBUTES = 0x70000003;
constexpr Elf_Word SHT_ARM_DEBUGOVERLAY = 0x70000004;
constexpr Elf_Word SHT_ARM_OVERLAYSECTION = 0x70000005;
constexpr Elf_Word SHT_HIPROC = 0x7FFFFFFF;
constexpr Elf_Word SHT_LOUSER = 0x80000000;
constexpr Elf_Word SHT_HIUSER = 0xFFFFFFFF;
@ -953,6 +963,7 @@ constexpr Elf_Word PT_PAX_FLAGS = 0X65041580;
constexpr Elf_Word PT_OPENBSD_RANDOMIZE = 0X65A3DBE6;
constexpr Elf_Word PT_OPENBSD_WXNEEDED = 0X65A3DBE7;
constexpr Elf_Word PT_OPENBSD_BOOTDATA = 0X65A41BE6;
constexpr Elf_Word PT_SUNWBSS = 0X6FFFFFFA;
constexpr Elf_Word PT_SUNWSTACK = 0X6FFFFFFB;
constexpr Elf_Word PT_HIOS = 0X6FFFFFFF;
constexpr Elf_Word PT_LOPROC = 0X70000000;
@ -1001,13 +1012,28 @@ constexpr Elf_Word DT_ENCODING = 32;
constexpr Elf_Word DT_PREINIT_ARRAY = 32;
constexpr Elf_Word DT_PREINIT_ARRAYSZ = 33;
constexpr Elf_Word DT_MAXPOSTAGS = 34;
constexpr Elf_Word DT_GNU_HASH = 0x6ffffef5;
constexpr Elf_Word DT_VERSYM = 0x6ffffff0;
constexpr Elf_Word DT_FLAGS_1 = 0x6ffffffb;
constexpr Elf_Word DT_VERNEED = 0x6ffffffe;
constexpr Elf_Word DT_VERNEEDNUM = 0x6fffffff;
constexpr Elf_Word DT_LOOS = 0x6000000D;
constexpr Elf_Word DT_HIOS = 0x6ffff000;
constexpr Elf_Word DT_GNU_HASH = 0x6ffffef5;
constexpr Elf_Word DT_TLSDESC_PLT = 0x6ffffef6;
constexpr Elf_Word DT_TLSDESC_GOT = 0x6ffffef7;
constexpr Elf_Word DT_GNU_CONFLICT = 0x6ffffef8;
constexpr Elf_Word DT_GNU_LIBLIST = 0x6ffffef9;
constexpr Elf_Word DT_CONFIG = 0x6ffffefa;
constexpr Elf_Word DT_DEPAUDIT = 0x6ffffefb;
constexpr Elf_Word DT_AUDIT = 0x6ffffefc;
constexpr Elf_Word DT_PLTPAD = 0x6ffffefd;
constexpr Elf_Word DT_MOVETAB = 0x6ffffefe;
constexpr Elf_Word DT_SYMINFO = 0x6ffffeff;
constexpr Elf_Word DT_ADDRRNGHI = 0x6ffffeff;
constexpr Elf_Word DT_VERSYM = 0x6ffffff0;
constexpr Elf_Word DT_RELACOUNT = 0x6ffffff9;
constexpr Elf_Word DT_RELCOUNT = 0x6ffffffa;
constexpr Elf_Word DT_FLAGS_1 = 0x6ffffffb;
constexpr Elf_Word DT_VERDEF = 0x6ffffffc;
constexpr Elf_Word DT_VERDEFNUM = 0x6ffffffd;
constexpr Elf_Word DT_VERNEED = 0x6ffffffe;
constexpr Elf_Word DT_VERNEEDNUM = 0x6fffffff;
constexpr Elf_Word DT_LOPROC = 0x70000000;
constexpr Elf_Word DT_HIPROC = 0x7FFFFFFF;

View File

@ -51,6 +51,33 @@ static const struct endian_table_t
{ ELFDATA2MSB, "Big endian" },
};
static const struct os_abi_table_t
{
const unsigned char key;
const char* str;
} os_abi_table[] = {
{ ELFOSABI_NONE, "UNIX System V" },
{ ELFOSABI_HPUX, "Hewlett-Packard HP-UX" },
{ ELFOSABI_NETBSD, "NetBSD" },
{ ELFOSABI_LINUX, "Linux" },
{ ELFOSABI_HURD, "GNU Hurd" },
{ ELFOSABI_SOLARIS, "Sun Solaris" },
{ ELFOSABI_AIX, "AIX" },
{ ELFOSABI_IRIX, "IRIX" },
{ ELFOSABI_FREEBSD, "FreeBSD" },
{ ELFOSABI_TRU64, "Compaq TRU64 UNIX" },
{ ELFOSABI_MODESTO, "Novell Modesto" },
{ ELFOSABI_OPENBSD, "Open BSD" },
{ ELFOSABI_OPENVMS, "Open VMS" },
{ ELFOSABI_NSK, "Hewlett-Packard Non-Stop Kernel" },
{ ELFOSABI_AROS, "Amiga Research OS" },
{ ELFOSABI_FENIXOS, "FenixOS" },
{ ELFOSABI_NUXI, "Nuxi CloudABI" },
{ ELFOSABI_OPENVOS, "OpenVOS" },
{ ELFOSABI_ARM, "ARM" },
{ ELFOSABI_STANDALONE, "Standalone (embedded)" },
};
static const struct version_table_t
{
const Elf64_Word key;
@ -369,6 +396,11 @@ static const struct section_type_table_t
{ SHT_GNU_verdef, "GNU_verdef" },
{ SHT_GNU_verneed, "GNU_verneed" },
{ SHT_GNU_versym, "GNU_versym" },
{ SHT_ARM_EXIDX, "ARM_EXIDX" },
{ SHT_ARM_PREEMPTMAP, "ARM_PREEMPTMAP" },
{ SHT_ARM_ATTRIBUTES, "ARM_ATTRIBUTES" },
{ SHT_ARM_DEBUGOVERLAY, "ARM_DEBUGOVERLAY" },
{ SHT_ARM_OVERLAYSECTION, "ARM_OVERLAYSECTION" },
};
@ -395,6 +427,7 @@ static const struct segment_type_table_t
{ PT_OPENBSD_RANDOMIZE, "OPENBSD_RANDOMIZE" },
{ PT_OPENBSD_WXNEEDED, "OPENBSD_WXNEEDED " },
{ PT_OPENBSD_BOOTDATA, "OPENBSD_BOOTDATA " },
{ PT_SUNWBSS, "PT_SUNWBSS" },
{ PT_SUNWSTACK, "SUNWSTACK" },
};
@ -472,8 +505,23 @@ static const struct dynamic_tag_t
{ DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ" },
{ DT_MAXPOSTAGS, "MAXPOSTAGS" },
{ DT_GNU_HASH, "GNU_HASH" },
{ DT_TLSDESC_PLT, "TLSDESC_PLT" },
{ DT_TLSDESC_GOT, "TLSDESC_GOT" },
{ DT_GNU_CONFLICT, "GNU_CONFLICT" },
{ DT_GNU_LIBLIST, "GNU_LIBLIST" },
{ DT_CONFIG, "CONFIG" },
{ DT_DEPAUDIT, "DEPAUDIT" },
{ DT_AUDIT, "AUDIT" },
{ DT_PLTPAD, "PLTPAD" },
{ DT_MOVETAB, "MOVETAB" },
{ DT_SYMINFO, "SYMINFO" },
{ DT_ADDRRNGHI, "ADDRRNGHI" },
{ DT_VERSYM, "VERSYM" },
{ DT_RELACOUNT, "RELACOUNT"},
{ DT_RELCOUNT, "RELCOUNT"},
{ DT_FLAGS_1, "FLAGS_1" },
{ DT_VERDEF, "VERDEF" },
{ DT_VERDEFNUM, "VERDEFNUM" },
{ DT_VERNEED, "VERNEED" },
{ DT_VERNEEDNUM, "VERNEEDNUM" },
};
@ -652,6 +700,8 @@ class dump
<< std::endl
<< " ELFVersion: " << str_version( reader.get_elf_version() )
<< std::endl
<< " OS/ABI: " << str_os_abi(reader.get_os_abi()) << std::endl
<< " ABI Version:" << (int)reader.get_abi_version() << std::endl
<< " Type: " << str_type( reader.get_type() ) << std::endl
<< " Machine: " << str_machine( reader.get_machine() )
<< std::endl
@ -1193,6 +1243,7 @@ class dump
STR_FUNC_TABLE( class )
STR_FUNC_TABLE( endian )
STR_FUNC_TABLE( version )
STR_FUNC_TABLE( os_abi )
STR_FUNC_TABLE( type )
STR_FUNC_TABLE( machine )
STR_FUNC_TABLE( section_type )

View File

@ -551,8 +551,8 @@ template <class S> class symbol_section_accessor_template
private:
const elfio& elf_file;
S* symbol_section;
Elf_Half hash_section_index;
const section* hash_section;
Elf_Half hash_section_index{ 0 };
const section* hash_section{ nullptr };
};
using symbol_section_accessor = symbol_section_accessor_template<section>;