class ElfParser
Public Instance Methods
parse_arch(e_machine)
click to toggle source
# File lib/elf.rb, line 181 def parse_arch(e_machine) machine = { 0x02 => "SPARC", 0x03 => "x86", 0x08 => "MIPS", 0x14 => "PowerPC", 0x28 => "ARM", 0x2a => "SuperH", 0x32 => "IA64", 0x3e => "x86-64", 0xb7 => "AArch64", } machine[e_machine] end
parse_bits(ei_class)
click to toggle source
# File lib/elf.rb, line 177 def parse_bits(ei_class) ei_class == 1 ? 32 : 64 end
parse_sh_flags(sh_flags)
click to toggle source
# File lib/elf.rb, line 245 def parse_sh_flags(sh_flags) flags = { (1 << 0) => "WRITE", # /* Writable */ (1 << 1) => "ALLOC", # /* Occupies memory during execution */ (1 << 2) => "EXECINSTR", # /* Executable */ (1 << 4) => "MERGE", # /* Might be merged */ (1 << 5) => "STRINGS", # /* Contains nul-terminated strings */ (1 << 6) => "INFO_LINK", # /* `sh_info' contains SHT index */ (1 << 7) => "LINK_ORDER", # /* Preserve order after combining */ (1 << 8) => "OS_NONCONFORMING", # /* Non-standard OS specific handling required */ (1 << 9) => "GROUP", # /* Section is member of a group. */ (1 << 10) => "TLS", # /* Section hold thread-local data. */ 0x0ff00000 => "MASKOS", # /* OS-specific. */ 0xf0000000 => "MASKPROC", # /* Processor-specific */ (1 << 30) => "ORDERED", # /* Special ordering requirement (Solaris). */ (1 << 31) => "EXCLUDE", # /* Section is excluded unless referenced or allocated (Solaris).*/ } result = [] flags.each do |k, v| if (sh_flags & k) > 0 result.push v end end result.join "|" end
parse_sh_type(sh_type)
click to toggle source
# File lib/elf.rb, line 206 def parse_sh_type(sh_type) type = { 0 => "NULL", # /* Section header table entry unused */ 1 => "PROGBITS", # /* Program data */ 2 => "SYMTAB", # /* Symbol table */ 3 => "STRTAB", # /* String table */ 4 => "RELA", # /* Relocation entries with addends */ 5 => "HASH", # /* Symbol hash table */ 6 => "DYNAMIC", # /* Dynamic linking information */ 7 => "NOTE", # /* Notes */ 8 => "NOBITS", # /* Program space with no data (bss) */ 9 => "REL", # /* Relocation entries, no addends */ 10 => "SHLIB", # /* Reserved */ 11 => "DYNSYM", # /* Dynamic linker symbol table */ 14 => "INIT_ARRAY", # /* Array of constructors */ 15 => "FINI_ARRAY", # /* Array of destructors */ 16 => "PREINIT_ARRAY", # /* Array of pre-constructors */ 17 => "GROUP", # /* Section group */ 18 => "SYMTAB_SHNDX", # /* Extended section indeces */ 19 => "NUM", # /* Number of defined types. */ 0x60000000 => "LOOS", # /* Start OS-specific. */ 0x6ffffff5 => "GNU_ATTRIBUTES", # /* Object attributes. */ 0x6ffffff6 => "GNU_HASH", # /* GNU-style hash table. */ 0x6ffffff7 => "GNU_LIBLIST", # /* Prelink library list */ 0x6ffffff8 => "CHECKSUM", # /* Checksum for DSO content. */ 0x6ffffffa => "SUNW_move", # 0x6ffffffb => "SUNW_COMDAT", # 0x6ffffffc => "SUNW_syminfo", # 0x6ffffffd => "GNU_verdef", # /* Version definition section. */ 0x6ffffffe => "GNU_verneed", # /* Version needs section. */ 0x6fffffff => "GNU_versym", # /* Version symbol table. */ 0x70000000 => "LOPROC", # /* Start of processor-specific */ 0x7fffffff => "HIPROC", # /* End of processor-specific */ 0x80000000 => "LOUSER", # /* Start of application-specific */ 0x8fffffff => "HIUSER", # /* End of application-specific */ } type[sh_type] end
parse_type(e_type)
click to toggle source
# File lib/elf.rb, line 196 def parse_type(e_type) type ={ 1 => "relocatable", 2 => "executable", 3 => "shared", 4 => "core", } type[e_type] end