UNPKG

elflib

Version:
148 lines (147 loc) 7.96 kB
import { uint8, uint16, uint32, uint64, sint32, sint64 } from './primitive.js'; import * as Enums from './enums.js'; export declare namespace Structs { class Header { /** The magic number of the ELF file, always '\x7FELF'. */ readonly magic: "ELF"; /** The architecture of the ELF file, either 32 or 64 bits. */ protected _class: Enums.Class; /** The endianness of the data in the ELF file. */ protected _endian: Enums.Endian; /** The version of the ELF file. There is currently only one version. */ protected _version: Enums.Version; /** The ABI (Application Binary Interface) of this ELF file. This is typically not used and set to SystemV. */ protected _abi: Enums.ABI; /** The ABI version. This is ABI specific data but is generally not used. */ protected _abiVersion: uint8; /** 7 null bytes of padding. */ readonly padding: "\0\0\0\0\0\0\0"; /** The type of ELF file this is (e.g. executable, object file, shared library). */ protected _type: Enums.Type; /** The ISA (Instruction Set Architecture) for this ELF file. This corresponds to the type of processor this ELF file is for * and does not necessarily include the entire specification of the ISA. isaVersion and flags may contain more information. */ protected _isa: Enums.ISA; /** The version of ISA used. The interpretation of version is ISA specific. */ protected _isaVersion: uint32; /** The virtual address of the entry point. */ protected _entryPoint: uint32 | uint64; /** Offset in the ELF file of the first program header entry. */ protected _programHeadersOffset: uint32; /** Offset in the ELF file of the first section header entry. */ protected _sectionHeadersOffset: uint32; /** Flags for the ISA used. The interpretation is ISA specific. */ protected _flags: uint32; /** The size of this ELF header in bytes. */ readonly headerSize: uint16; /** The size of 1 program header entry. */ protected _programHeadersEntrySize: uint16; /** The total number of program header entries in the file. */ protected _programHeadersEntryCount: uint16; /** The size of 1 section header entry. */ protected _sectionHeadersEntrySize: uint16; /** The total number of program section entries in the file. */ protected _sectionHeadersEntryCount: uint16; /** The section index for the section headers string table (if any). */ protected _shstrIndex: uint16; } class Section { /** Offset from the start of the {@link Header.shstrIndex section headers string table} * to the address of this section's name in said table, if any. */ protected _nameOffset: uint32; /** The type of this section. */ protected _type: Enums.SectionType; /** The flags for this section. */ protected _flags: uint32; /** The virtual address of this section. */ protected _addr: uint32 | uint64; /** The absolute offset of the section in the file. */ protected _offset: uint32; /** The size of this section, in bytes. */ protected _size: uint32; /** A section linked to this section. For example for a symbol section the * linked section is a string table section providing names for symbols. */ protected _link: uint32; /** Section type specific info for this section. */ protected _info: uint32; /** The alignment requirement of this section. */ protected _addrAlign: uint32; /** The size of each "entity" in this section, if applicable. * For example, if this is a symbol table section, this is the size of a symbol entry. */ protected _entSize: uint32; } class Symbol { /** Offset from the start of the {@link Section.link linked string table section} of * this symbol's section, to the address of this symbol's name in said table, if any. */ protected _nameOffset: uint32; /** The value of this symbol. The interpretation of the value is dependent on a few things but is generally an offset or address. */ protected _value: uint32 | uint64; /** The size of this symbol, if applicable. */ protected _size: uint32; /** Symbol type specific information. */ protected _info: uint8; /** Other symbol information. */ protected _other: uint8; /** Section index for this symbol. * @summary This is the index of the section for this symbol. There * are also special values such as 0xFFF1 for an absolute index symbol * in a relocatable ELF file (object file). */ protected _shndx: uint16; } class Relocation { /** The location at which to apply the relocation action. * @summary This member gives the location at which to apply the relocation action. For * a relocatable file, the value is the byte offset from the beginning of the * section to the storage unit affected by the relocation. For an executable file * or a shared object, the value is the virtual address of the storage unit affected by the relocation. */ protected _addr: uint32 | uint64; /** The symbol table index with respect to which the * relocation must be made, and the type of relocation to apply. * @summary This member gives both the symbol table index with respect to which the * relocation must be made, and the type of relocation to apply. For example, * a call instruction's relocation entry would hold the symbol table index of * the function being called. If the index is STN_UNDEF, the undefined symbol * index, the relocation uses 0 as the symbol value. Relocation types are * processor-specific; descriptions of their behavior appear in the processor * supplement. When the text in the processor supplement refers to a * relocation entry's relocation type or symbol table index, it means the result * of applying ELF32_R_TYPE or ELF32_R_SYM, respectively, to the entry's r_info member. */ protected _info: uint32 | uint64; /** A constant addend used to compute the value to be stored into the relocatable field. */ protected _addend?: sint32 | sint64; } /** RPL-exclusive file information section data structure. */ class RPLFileInfo { /** Magic number of the RPL_FILEINFO section, always 0xCAFE */ readonly magic: 51966; protected _version: uint16; protected _textSize: uint32; protected _textAlign: uint32; protected _dataSize: uint32; protected _dataAlign: uint32; protected _loadSize: uint32; protected _loadAlign: uint32; protected _tempSize: uint32; protected _trampAdjust: uint32; protected _sdaBase: uint32; protected _sda2Base: uint32; protected _stackSize: uint32; /** The offset from the start of the section to the start of the strings array */ protected _stringsOffset: uint32; protected _flags: uint32; protected _heapSize: uint32; protected _tagOffset: uint32; protected _minVersion: uint32; protected _compressionLevel: sint32; protected _trampAddition: uint32; protected _fileInfoPad: uint32; protected _cafeSdkVersion: uint32; protected _cafeSdkRevision: uint32; protected _tlsModuleIndex: uint16; protected _tlsAlignShift: uint16; protected _runtimeFileInfoSize: uint32; /** Array of null-terminated strings until the end of the file */ protected _strings: { [addr: number]: string; }; } }