elflib
Version:
ELF file reader and writer
379 lines (378 loc) • 17.1 kB
JavaScript
/** The architecture of the ELF file, either 32 or 64 bits. //* uint8 */
export var Class;
(function (Class) {
Class[Class["None"] = 0] = "None";
Class[Class["ELF32"] = 1] = "ELF32";
Class[Class["ELF64"] = 2] = "ELF64";
})(Class || (Class = {}));
/** The endianness of the data in the ELF file. //* uint8 */
export var Endian;
(function (Endian) {
Endian[Endian["None"] = 0] = "None";
Endian[Endian["Little"] = 1] = "Little";
Endian[Endian["Big"] = 2] = "Big";
})(Endian || (Endian = {}));
/** The version of the ELF file. There is currently only one version. //* uint8 */
export var Version;
(function (Version) {
Version[Version["None"] = 0] = "None";
Version[Version["Current"] = 1] = "Current";
})(Version || (Version = {}));
/** The type of Application Binary Interface. //* uint8 */
export var ABI;
(function (ABI) {
ABI[ABI["SystemV"] = 0] = "SystemV";
ABI[ABI["HPUX"] = 1] = "HPUX";
ABI[ABI["NetBSD"] = 2] = "NetBSD";
ABI[ABI["Linux"] = 3] = "Linux";
ABI[ABI["GNUHurd"] = 4] = "GNUHurd";
ABI[ABI["Solaris"] = 6] = "Solaris";
ABI[ABI["AIX"] = 7] = "AIX";
ABI[ABI["IRIX"] = 8] = "IRIX";
ABI[ABI["FreeBSD"] = 9] = "FreeBSD";
ABI[ABI["Tru64"] = 10] = "Tru64";
ABI[ABI["NovelloModesto"] = 11] = "NovelloModesto";
ABI[ABI["OpenBSD"] = 12] = "OpenBSD";
ABI[ABI["OpenVMS"] = 13] = "OpenVMS";
ABI[ABI["NonStopKernel"] = 14] = "NonStopKernel";
ABI[ABI["AROS"] = 15] = "AROS";
ABI[ABI["FenixOS"] = 16] = "FenixOS";
ABI[ABI["CloudABI"] = 17] = "CloudABI";
ABI[ABI["ARMEABI"] = 64] = "ARMEABI";
ABI[ABI["ARM"] = 97] = "ARM";
ABI[ABI["CafeOS"] = 202] = "CafeOS";
ABI[ABI["Standalone"] = 255] = "Standalone";
})(ABI || (ABI = {}));
/** The type of ELF file. Executables are ELF files, while some other files (like .o or .so files)
* are also ELF files but of different types. //? uint16 */
export var Type;
(function (Type) {
Type[Type["None"] = 0] = "None";
Type[Type["Relocatable"] = 1] = "Relocatable";
Type[Type["Executable"] = 2] = "Executable";
Type[Type["Shared"] = 3] = "Shared";
Type[Type["Core"] = 4] = "Core";
Type[Type["RPL"] = 65025] = "RPL";
})(Type || (Type = {}));
/** The type of Instruction Set Architecture. //? uint16 */
export var ISA;
(function (ISA) {
ISA[ISA["None"] = 0] = "None";
ISA[ISA["M32"] = 1] = "M32";
ISA[ISA["SPARC"] = 2] = "SPARC";
ISA[ISA["x86"] = 3] = "x86";
ISA[ISA["ISA68K"] = 4] = "ISA68K";
ISA[ISA["ISA88K"] = 5] = "ISA88K";
ISA[ISA["IAMCU"] = 6] = "IAMCU";
ISA[ISA["ISA860"] = 7] = "ISA860";
ISA[ISA["MIPS"] = 8] = "MIPS";
ISA[ISA["S370"] = 9] = "S370";
ISA[ISA["MIPS_RS3_LE"] = 10] = "MIPS_RS3_LE";
ISA[ISA["PARISC"] = 15] = "PARISC";
ISA[ISA["VPP500"] = 17] = "VPP500";
ISA[ISA["SPARC32PLUS"] = 18] = "SPARC32PLUS";
ISA[ISA["ISA960"] = 19] = "ISA960";
ISA[ISA["PPC"] = 20] = "PPC";
ISA[ISA["PPC64"] = 21] = "PPC64";
ISA[ISA["S390"] = 22] = "S390";
ISA[ISA["SPU"] = 23] = "SPU";
ISA[ISA["V800"] = 36] = "V800";
ISA[ISA["FR20"] = 37] = "FR20";
ISA[ISA["RH32"] = 38] = "RH32";
ISA[ISA["RCE"] = 39] = "RCE";
ISA[ISA["ARM"] = 40] = "ARM";
ISA[ISA["FAKE_ALPHA"] = 41] = "FAKE_ALPHA";
ISA[ISA["SH"] = 42] = "SH";
ISA[ISA["SPARCV9"] = 43] = "SPARCV9";
ISA[ISA["TRICORE"] = 44] = "TRICORE";
ISA[ISA["ARC"] = 45] = "ARC";
ISA[ISA["H8_300"] = 46] = "H8_300";
ISA[ISA["H8_300H"] = 47] = "H8_300H";
ISA[ISA["H8S"] = 48] = "H8S";
ISA[ISA["H8_500"] = 49] = "H8_500";
ISA[ISA["IA_64"] = 50] = "IA_64";
ISA[ISA["MIPS_X"] = 51] = "MIPS_X";
ISA[ISA["COLDFIRE"] = 52] = "COLDFIRE";
ISA[ISA["ISA68HC12"] = 53] = "ISA68HC12";
ISA[ISA["MMA"] = 54] = "MMA";
ISA[ISA["PCP"] = 55] = "PCP";
ISA[ISA["NCPU"] = 56] = "NCPU";
ISA[ISA["NDR1"] = 57] = "NDR1";
ISA[ISA["STARCORE"] = 58] = "STARCORE";
ISA[ISA["ME16"] = 59] = "ME16";
ISA[ISA["ST100"] = 60] = "ST100";
ISA[ISA["TINYJ"] = 61] = "TINYJ";
ISA[ISA["X86_64"] = 62] = "X86_64";
ISA[ISA["PDSP"] = 63] = "PDSP";
ISA[ISA["PDP10"] = 64] = "PDP10";
ISA[ISA["PDP11"] = 65] = "PDP11";
ISA[ISA["FX66"] = 66] = "FX66";
ISA[ISA["ST9PLUS"] = 67] = "ST9PLUS";
ISA[ISA["ST7"] = 68] = "ST7";
ISA[ISA["ISA68HC16"] = 69] = "ISA68HC16";
ISA[ISA["ISA68HC11"] = 70] = "ISA68HC11";
ISA[ISA["ISA68HC08"] = 71] = "ISA68HC08";
ISA[ISA["ISA68HC05"] = 72] = "ISA68HC05";
ISA[ISA["SVX"] = 73] = "SVX";
ISA[ISA["ST19"] = 74] = "ST19";
ISA[ISA["VAX"] = 75] = "VAX";
ISA[ISA["CRIS"] = 76] = "CRIS";
ISA[ISA["JAVELIN"] = 77] = "JAVELIN";
ISA[ISA["FIREPATH"] = 78] = "FIREPATH";
ISA[ISA["ZSP"] = 79] = "ZSP";
ISA[ISA["MMIX"] = 80] = "MMIX";
ISA[ISA["HUANY"] = 81] = "HUANY";
ISA[ISA["PRISM"] = 82] = "PRISM";
ISA[ISA["AVR"] = 83] = "AVR";
ISA[ISA["FR30"] = 84] = "FR30";
ISA[ISA["D10V"] = 85] = "D10V";
ISA[ISA["D30V"] = 86] = "D30V";
ISA[ISA["V850"] = 87] = "V850";
ISA[ISA["M32R"] = 88] = "M32R";
ISA[ISA["MN10300"] = 89] = "MN10300";
ISA[ISA["MN10200"] = 90] = "MN10200";
ISA[ISA["PJ"] = 91] = "PJ";
ISA[ISA["OPENRISC"] = 92] = "OPENRISC";
ISA[ISA["ARC_COMPACT"] = 93] = "ARC_COMPACT";
ISA[ISA["XTENSA"] = 94] = "XTENSA";
ISA[ISA["VIDEOCORE"] = 95] = "VIDEOCORE";
ISA[ISA["TMM_GPP"] = 96] = "TMM_GPP";
ISA[ISA["NS32K"] = 97] = "NS32K";
ISA[ISA["TPC"] = 98] = "TPC";
ISA[ISA["SNP1K"] = 99] = "SNP1K";
ISA[ISA["ST200"] = 100] = "ST200";
ISA[ISA["IP2K"] = 101] = "IP2K";
ISA[ISA["MAX"] = 102] = "MAX";
ISA[ISA["CR"] = 103] = "CR";
ISA[ISA["F2MC16"] = 104] = "F2MC16";
ISA[ISA["MSP430"] = 105] = "MSP430";
ISA[ISA["BLACKFIN"] = 106] = "BLACKFIN";
ISA[ISA["SE_C33"] = 107] = "SE_C33";
ISA[ISA["SEP"] = 108] = "SEP";
ISA[ISA["ARCA"] = 109] = "ARCA";
ISA[ISA["UNICORE"] = 110] = "UNICORE";
ISA[ISA["EXCESS"] = 111] = "EXCESS";
ISA[ISA["DXP"] = 112] = "DXP";
ISA[ISA["ALTERA_NIOS2"] = 113] = "ALTERA_NIOS2";
ISA[ISA["CRX"] = 114] = "CRX";
ISA[ISA["XGATE"] = 115] = "XGATE";
ISA[ISA["C166"] = 116] = "C166";
ISA[ISA["M16C"] = 117] = "M16C";
ISA[ISA["DSPIC30F"] = 118] = "DSPIC30F";
ISA[ISA["CE"] = 119] = "CE";
ISA[ISA["M32C"] = 120] = "M32C";
ISA[ISA["TSK3000"] = 131] = "TSK3000";
ISA[ISA["RS08"] = 132] = "RS08";
ISA[ISA["SHARC"] = 133] = "SHARC";
ISA[ISA["ECOG2"] = 134] = "ECOG2";
ISA[ISA["SCORE7"] = 135] = "SCORE7";
ISA[ISA["DSP24"] = 136] = "DSP24";
ISA[ISA["VIDEOCORE3"] = 137] = "VIDEOCORE3";
ISA[ISA["LATTICEMICO32"] = 138] = "LATTICEMICO32";
ISA[ISA["SE_C17"] = 139] = "SE_C17";
ISA[ISA["TI_C6000"] = 140] = "TI_C6000";
ISA[ISA["TI_C2000"] = 141] = "TI_C2000";
ISA[ISA["TI_C5500"] = 142] = "TI_C5500";
ISA[ISA["TI_ARP32"] = 143] = "TI_ARP32";
ISA[ISA["TI_PRU"] = 144] = "TI_PRU";
ISA[ISA["MMDSP_PLUS"] = 160] = "MMDSP_PLUS";
ISA[ISA["CYPRESS_M8C"] = 161] = "CYPRESS_M8C";
ISA[ISA["R32C"] = 162] = "R32C";
ISA[ISA["TRIMEDIA"] = 163] = "TRIMEDIA";
ISA[ISA["QDSP6"] = 164] = "QDSP6";
ISA[ISA["ISA8051"] = 165] = "ISA8051";
ISA[ISA["STXP7X"] = 166] = "STXP7X";
ISA[ISA["NDS32"] = 167] = "NDS32";
ISA[ISA["ECOG1X"] = 168] = "ECOG1X";
ISA[ISA["MAXQ30"] = 169] = "MAXQ30";
ISA[ISA["XIMO16"] = 170] = "XIMO16";
ISA[ISA["MANIK"] = 171] = "MANIK";
ISA[ISA["CRAYNV2"] = 172] = "CRAYNV2";
ISA[ISA["RX"] = 173] = "RX";
ISA[ISA["METAG"] = 174] = "METAG";
ISA[ISA["MCST_ELBRUS"] = 175] = "MCST_ELBRUS";
ISA[ISA["ECOG16"] = 176] = "ECOG16";
ISA[ISA["CR16"] = 177] = "CR16";
ISA[ISA["ETPU"] = 178] = "ETPU";
ISA[ISA["SLE9X"] = 179] = "SLE9X";
ISA[ISA["L10M"] = 180] = "L10M";
ISA[ISA["K10M"] = 181] = "K10M";
ISA[ISA["AARCH64"] = 183] = "AARCH64";
ISA[ISA["AVR32"] = 185] = "AVR32";
ISA[ISA["STM8"] = 186] = "STM8";
ISA[ISA["TILE64"] = 187] = "TILE64";
ISA[ISA["TILEPRO"] = 188] = "TILEPRO";
ISA[ISA["MICROBLAZE"] = 189] = "MICROBLAZE";
ISA[ISA["CUDA"] = 190] = "CUDA";
ISA[ISA["TILEGX"] = 191] = "TILEGX";
ISA[ISA["CLOUDSHIELD"] = 192] = "CLOUDSHIELD";
ISA[ISA["COREA_1ST"] = 193] = "COREA_1ST";
ISA[ISA["COREA_2ND"] = 194] = "COREA_2ND";
ISA[ISA["ARC_COMPACT2"] = 195] = "ARC_COMPACT2";
ISA[ISA["OPEN8"] = 196] = "OPEN8";
ISA[ISA["RL78"] = 197] = "RL78";
ISA[ISA["VIDEOCORE5"] = 198] = "VIDEOCORE5";
ISA[ISA["ISA78KOR"] = 199] = "ISA78KOR";
ISA[ISA["ISA56800EX"] = 200] = "ISA56800EX";
ISA[ISA["BA1"] = 201] = "BA1";
ISA[ISA["BA2"] = 202] = "BA2";
ISA[ISA["XCORE"] = 203] = "XCORE";
ISA[ISA["MCHP_PIC"] = 204] = "MCHP_PIC";
ISA[ISA["KM32"] = 210] = "KM32";
ISA[ISA["KMX32"] = 211] = "KMX32";
ISA[ISA["EMX16"] = 212] = "EMX16";
ISA[ISA["EMX8"] = 213] = "EMX8";
ISA[ISA["KVARC"] = 214] = "KVARC";
ISA[ISA["CDP"] = 215] = "CDP";
ISA[ISA["COGE"] = 216] = "COGE";
ISA[ISA["COOL"] = 217] = "COOL";
ISA[ISA["NORC"] = 218] = "NORC";
ISA[ISA["CSR_KALIMBA"] = 219] = "CSR_KALIMBA";
ISA[ISA["Z80"] = 220] = "Z80";
ISA[ISA["VISIUM"] = 221] = "VISIUM";
ISA[ISA["FT32"] = 222] = "FT32";
ISA[ISA["MOXIE"] = 223] = "MOXIE";
ISA[ISA["AMDGPU"] = 224] = "AMDGPU";
ISA[ISA["RISCV"] = 243] = "RISCV";
ISA[ISA["BPF"] = 247] = "BPF";
ISA[ISA["CSKY"] = 252] = "CSKY";
})(ISA || (ISA = {}));
/** The type of a segment (program header entry). //! uint32 */
export var SegmentType;
(function (SegmentType) {
SegmentType[SegmentType["Null"] = 0] = "Null";
SegmentType[SegmentType["Load"] = 1] = "Load";
SegmentType[SegmentType["Dynamic"] = 2] = "Dynamic";
SegmentType[SegmentType["Interp"] = 3] = "Interp";
SegmentType[SegmentType["Note"] = 4] = "Note";
SegmentType[SegmentType["ShLib"] = 5] = "ShLib";
SegmentType[SegmentType["ProgHeaderTable"] = 6] = "ProgHeaderTable";
SegmentType[SegmentType["GnuEhFrame"] = 1685382480] = "GnuEhFrame";
SegmentType[SegmentType["GnuStack"] = 1685382481] = "GnuStack";
SegmentType[SegmentType["GnuRelRo"] = 1685382482] = "GnuRelRo";
})(SegmentType || (SegmentType = {}));
/** The type of section (section header entry). //! uint32 */
export var SectionType;
(function (SectionType) {
/** Inactive section with undefined values (SHT_NULL) */
SectionType[SectionType["Null"] = 0] = "Null";
/** Information defined by the program, includes executable code and data (SHT_PROGBITS) */
SectionType[SectionType["ProgBits"] = 1] = "ProgBits";
/** Section data contains a symbol table (SHT_SYMTAB) */
SectionType[SectionType["SymTab"] = 2] = "SymTab";
/** Section data contains a string table (SHT_STRTAB) */
SectionType[SectionType["StrTab"] = 3] = "StrTab";
/** Section data contains relocation entries with explicit addends (SHT_RELA) */
SectionType[SectionType["Rela"] = 4] = "Rela";
/** Section data contains a symbol hash table. Must be present for dynamic linking (SHT_HASH) */
SectionType[SectionType["Hash"] = 5] = "Hash";
/** Section data contains information for dynamic linking (SHT_DYNAMIC) */
SectionType[SectionType["Dynamic"] = 6] = "Dynamic";
/** Section data contains information that marks the file in some way (SHT_NOTE) */
SectionType[SectionType["Note"] = 7] = "Note";
/** Section data occupies no space in the file but otherwise resembles SHT_PROGBITS (SHT_NOBITS) */
SectionType[SectionType["NoBits"] = 8] = "NoBits";
/** Section data contains relocation entries without explicit addends (SHT_REL) */
SectionType[SectionType["Rel"] = 9] = "Rel";
/** Section is reserved but has unspecified semantics (SHT_SHLIB) */
SectionType[SectionType["ShLib"] = 10] = "ShLib";
/** Section data contains a minimal set of dynamic linking symbols (SHT_DYNSYM) */
SectionType[SectionType["DynSym"] = 11] = "DynSym";
/** Section data contains an array of constructors (SHT_INIT_ARRAY) */
SectionType[SectionType["InitArray"] = 14] = "InitArray";
/** Section data contains an array of destructors (SHT_FINI_ARRAY) */
SectionType[SectionType["FiniArray"] = 15] = "FiniArray";
/** Section data contains an array of pre-constructors (SHT_PREINIT_ARRAY) */
SectionType[SectionType["PreInitArray"] = 16] = "PreInitArray";
/** Section group (SHT_GROUP) */
SectionType[SectionType["Group"] = 17] = "Group";
/** Extended symbol table section index (SHT_SYMTAB_SHNDX) */
SectionType[SectionType["ShNdx"] = 18] = "ShNdx";
/** Number of reserved SHT_* values (SHT_NUM) */
SectionType[SectionType["Num"] = 19] = "Num";
/** Object attributes (SHT_GNU_ATTRIBUTES) */
SectionType[SectionType["GnuAttributes"] = 1879048181] = "GnuAttributes";
/** GNU-style hash section (SHT_GNU_HASH) */
SectionType[SectionType["GnuHash"] = 1879048182] = "GnuHash";
/** Pre-link library list (SHT_GNU_LIBLIST) */
SectionType[SectionType["GnuLibList"] = 1879048183] = "GnuLibList";
/** Version definition section (SHT_GNU_verdef) */
SectionType[SectionType["GnuVerDef"] = 1879048189] = "GnuVerDef";
/** Version needs section (SHT_GNU_verdneed) */
SectionType[SectionType["GnuVerNeed"] = 1879048190] = "GnuVerNeed";
/** Version symbol table (SHT_GNU_versym) */
SectionType[SectionType["GnuVerSym"] = 1879048191] = "GnuVerSym";
/** RPL exports table (SHT_RPL_EXPORTS) */
SectionType[SectionType["RPLExports"] = 2147483649] = "RPLExports";
/** RPL imports table (SHT_RPL_IMPORTS) */
SectionType[SectionType["RPLImports"] = 2147483650] = "RPLImports";
/** RPL file CRC hashes (SHT_RPL_CRCS) */
SectionType[SectionType["RPLCrcs"] = 2147483651] = "RPLCrcs";
/** RPL file information (SHT_RPL_FILEINFO) */
SectionType[SectionType["RPLFileInfo"] = 2147483652] = "RPLFileInfo";
})(SectionType || (SectionType = {}));
/** Section header flags //! uint32 */
export var SectionFlags;
(function (SectionFlags) {
SectionFlags[SectionFlags["None"] = 0] = "None";
/** (SHF_WRITE) */
SectionFlags[SectionFlags["Write"] = 1] = "Write";
/** (SHF_ALLOC) */
SectionFlags[SectionFlags["Alloc"] = 2] = "Alloc";
/** (SHF_EXECINSTR) */
SectionFlags[SectionFlags["Executable"] = 4] = "Executable";
/** (SHF_MERGE) */
SectionFlags[SectionFlags["Merge"] = 16] = "Merge";
/** (SHF_STRINGS) */
SectionFlags[SectionFlags["Strings"] = 32] = "Strings";
/** (SHF_INFO_LINK) */
SectionFlags[SectionFlags["InfoLink"] = 64] = "InfoLink";
/** (SHF_LINK_ORDER) */
SectionFlags[SectionFlags["LinkOrder"] = 128] = "LinkOrder";
/** (SHF_OS_NONCONFORMING) */
SectionFlags[SectionFlags["Nonconforming"] = 256] = "Nonconforming";
/** (SHF_GROUP) */
SectionFlags[SectionFlags["Group"] = 512] = "Group";
/** (SHF_TLS) */
SectionFlags[SectionFlags["TLS"] = 1024] = "TLS";
/** (SHF_COMPRESSED) */
SectionFlags[SectionFlags["Compressed"] = 134217728] = "Compressed";
/** (SHF_AMD64_LARGE) */
SectionFlags[SectionFlags["AMD64Large"] = 268435456] = "AMD64Large";
/** (SHF_ORDERED) */
SectionFlags[SectionFlags["Ordered"] = 1073741824] = "Ordered";
/** (SHF_EXCLUDE) */
SectionFlags[SectionFlags["Exclude"] = 2147483648] = "Exclude";
})(SectionFlags || (SectionFlags = {}));
/** The scope of the symbol. //* nybble */
export var SymbolBinding;
(function (SymbolBinding) {
/** A local symbol is akin to a local variable. */
SymbolBinding[SymbolBinding["Local"] = 0] = "Local";
/** A global symbol is akin to a global variable or function. */
SymbolBinding[SymbolBinding["Global"] = 1] = "Global";
/** A weak symbol is a symbol that can be replaced by a non-weak symbol in another object file when linking. */
SymbolBinding[SymbolBinding["Weak"] = 2] = "Weak";
})(SymbolBinding || (SymbolBinding = {}));
/** The type of symbol. The most common symbol is a function or object,
* but other kinds of symbols exist for keeping track of various things. //* nybble */
export var SymbolType;
(function (SymbolType) {
SymbolType[SymbolType["None"] = 0] = "None";
SymbolType[SymbolType["Object"] = 1] = "Object";
SymbolType[SymbolType["Function"] = 2] = "Function";
SymbolType[SymbolType["Section"] = 3] = "Section";
SymbolType[SymbolType["File"] = 4] = "File";
SymbolType[SymbolType["Common"] = 5] = "Common";
SymbolType[SymbolType["ThreadLocalStorage"] = 6] = "ThreadLocalStorage";
SymbolType[SymbolType["RelocationExpression"] = 7] = "RelocationExpression";
SymbolType[SymbolType["SignedRelocationExpression"] = 8] = "SignedRelocationExpression";
})(SymbolType || (SymbolType = {}));
/** The visibility of a symbol. //* uint8 */
export var SymbolVisibility;
(function (SymbolVisibility) {
SymbolVisibility[SymbolVisibility["Default"] = 0] = "Default";
SymbolVisibility[SymbolVisibility["Internal"] = 1] = "Internal";
SymbolVisibility[SymbolVisibility["Hidden"] = 2] = "Hidden";
SymbolVisibility[SymbolVisibility["Protected"] = 3] = "Protected";
})(SymbolVisibility || (SymbolVisibility = {}));