From 594dc724b3dbdfef1b03ba5601b6e0516b249d4c Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sat, 25 May 2013 06:10:23 -0700 Subject: [PATCH] More renaming & cleaning up --- elftools/elf/elffile.py | 2 +- elftools/elf/enums.py | 4 ++-- elftools/elf/sections.py | 18 +++++++++--------- elftools/elf/structs.py | 34 +++++++++++++++++----------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/elftools/elf/elffile.py b/elftools/elf/elffile.py index 7e18c92..a8e605f 100644 --- a/elftools/elf/elffile.py +++ b/elftools/elf/elffile.py @@ -265,7 +265,7 @@ class ELFFile(object): stringtable=strtab_section) def _make_sunwsyminfo_table_section(self, section_header, name): - """ Create a SymbolTableSection + """ Create a SUNWSyminfoTableSection """ linked_strtab_index = section_header['sh_link'] strtab_section = self.get_section(linked_strtab_index) diff --git a/elftools/elf/enums.py b/elftools/elf/enums.py index 2c30282..121c287 100644 --- a/elftools/elf/enums.py +++ b/elftools/elf/enums.py @@ -447,8 +447,8 @@ ENUM_RELOC_TYPE_x64 = dict( _default_=Pass, ) -# Syminfo Bound To special values -ENUM_SYMINFO_BOUNDTO = dict( +# Sunw Syminfo Bound To special values +ENUM_SUNW_SYMINFO_BOUNDTO = dict( SYMINFO_BT_SELF=0xffff, SYMINFO_BT_PARENT=0xfffe, SYMINFO_BT_NONE=0xfffd, diff --git a/elftools/elf/sections.py b/elftools/elf/sections.py index 1446ccf..ce62450 100644 --- a/elftools/elf/sections.py +++ b/elftools/elf/sections.py @@ -13,7 +13,7 @@ from ..common.utils import struct_parse, elf_assert, parse_cstring_from_stream class Section(object): """ Base class for ELF sections. Also used for all sections types that have no special functionality. - + Allows dictionary-like access to the section header. For example: > sec = Section(...) > sec['sh_type'] # section type @@ -22,7 +22,7 @@ class Section(object): self.header = header self.name = name self.stream = stream - + def data(self): """ The section data from the file. """ @@ -33,7 +33,7 @@ class Section(object): """ Is this a null section? """ return False - + def __getitem__(self, name): """ Implement dict-like access to header entries """ @@ -51,14 +51,14 @@ class NullSection(Section): def is_null(self): return True - + class StringTableSection(Section): """ ELF string table section. """ def __init__(self, header, name, stream): super(StringTableSection, self).__init__(header, name, stream) - + def get_string(self, offset): """ Get the string stored at the given offset in this string table. """ @@ -85,7 +85,7 @@ class SymbolTableSection(Section): """ Number of symbols in the table """ return self['sh_size'] // self['sh_entsize'] - + def get_symbol(self, n): """ Get the symbol at index #n from the table (Symbol object) """ @@ -139,14 +139,14 @@ class SUNWSyminfoTableSection(Section): return self['sh_size'] // self['sh_entsize'] - 1 def get_symbol(self, n): - """ Get the symbol at index #n from the table (Symbol object) + """ Get the symbol at index #n from the table (Symbol object). It begins at 1 and not 0 since the first entry is used to - store the current version of the syminfo table + store the current version of the syminfo table. """ # Grab the symbol's entry from the stream entry_offset = self['sh_offset'] + n * self['sh_entsize'] entry = struct_parse( - self.elfstructs.Elf_Syminfo, + self.elfstructs.Elf_Sunw_Syminfo, self.stream, stream_pos=entry_offset) # Find the symbol name in the associated symbol table diff --git a/elftools/elf/structs.py b/elftools/elf/structs.py index 93edd13..72d07fa 100644 --- a/elftools/elf/structs.py +++ b/elftools/elf/structs.py @@ -19,20 +19,20 @@ from .enums import * class ELFStructs(object): """ Accessible attributes: - + Elf_{byte|half|word|word64|addr|offset|sword|xword|xsword}: - Data chunks, as specified by the ELF standard, adjusted for + Data chunks, as specified by the ELF standard, adjusted for correct endianness and word-size. Elf_Ehdr: ELF file header - + Elf_Phdr: Program header - + Elf_Shdr: Section header - + Elf_Sym: Symbol table entry @@ -42,9 +42,9 @@ class ELFStructs(object): def __init__(self, little_endian=True, elfclass=32): assert elfclass == 32 or elfclass == 64 self.little_endian = little_endian - self.elfclass = elfclass + self.elfclass = elfclass self._create_structs() - + def _create_structs(self): if self.little_endian: self.Elf_byte = ULInt8 @@ -66,15 +66,15 @@ class ELFStructs(object): self.Elf_sword = SBInt32 self.Elf_xword = UBInt32 if self.elfclass == 32 else UBInt64 self.Elf_sxword = SBInt32 if self.elfclass == 32 else SBInt64 - + self._create_ehdr() self._create_phdr() self._create_shdr() self._create_sym() self._create_rel() self._create_dyn() - self._create_syminfo() - + self._create_sunw_syminfo() + def _create_ehdr(self): self.Elf_Ehdr = Struct('Elf_Ehdr', Struct('e_ident', @@ -100,7 +100,7 @@ class ELFStructs(object): self.Elf_half('e_shnum'), self.Elf_half('e_shstrndx'), ) - + def _create_phdr(self): if self.elfclass == 32: self.Elf_Phdr = Struct('Elf_Phdr', @@ -123,8 +123,8 @@ class ELFStructs(object): self.Elf_xword('p_filesz'), self.Elf_xword('p_memsz'), self.Elf_xword('p_align'), - ) - + ) + def _create_shdr(self): self.Elf_Shdr = Struct('Elf_Shdr', self.Elf_word('sh_name'), @@ -138,7 +138,7 @@ class ELFStructs(object): self.Elf_xword('sh_addralign'), self.Elf_xword('sh_entsize'), ) - + def _create_rel(self): # r_info is also taken apart into r_info_sym and r_info_type. # This is done in Value to avoid endianity issues while parsing. @@ -204,8 +204,8 @@ class ELFStructs(object): self.Elf_xword('st_size'), ) - def _create_syminfo(self): - self.Elf_Syminfo = Struct('Elf_Syminfo', - Enum(self.Elf_half('si_boundto'), **ENUM_SYMINFO_BOUNDTO), + def _create_sunw_syminfo(self): + self.Elf_Sunw_Syminfo = Struct('Elf_Sunw_Syminfo', + Enum(self.Elf_half('si_boundto'), **ENUM_SUNW_SYMINFO_BOUNDTO), self.Elf_half('si_flags'), ) -- 2.30.2