示例#1
0
    def load_symbols_names(self):
        """ Loads symbols names from symtab if possible """

        # let's proceed through all sections to find symtab or dynsym sections
        for sec in self.sections:
            if sec.header.sh_type != shdr_type['SHT_SYMTAB']:
                if sec.header.sh_type != shdr_type['SHT_DYNSYM']:
                    continue

            # if so: sh_link should point on an existing section
            # which should own strtab type of
            if sec.header.sh_link >= len(self.sections):
                continue

            s_strtab = self.sections[sec.header.sh_link]
            if s_strtab.header.sh_type != shdr_type['SHT_STRTAB']:
                continue

            # for each symbol entry then: a name should be found in strtab
            # or then for symbol entry describing section it should be 
            # set to related section's name.
            for s_entry in sec.symtab:
                s_entry.name = getNameFromStrTab(s_entry.st_name,
                                                 s_strtab.strtab)
                if s_entry.name == 'null':
                    if s_entry.st_type == symtab_type['STT_SECTION']:
                        s_entry.name = self.sections[s_entry.st_shndx].name
示例#2
0
    def load_symbols_names(self):
        """ Loads symbols names from symtab if possible """

        # let's proceed through all sections to find symtab or dynsym sections
        for sec in self.sections:
            if sec.header.sh_type != shdr_type['SHT_SYMTAB']:
                if sec.header.sh_type != shdr_type['SHT_DYNSYM']:
                    continue

            # if so: sh_link should point on an existing section
            # which should own strtab type of
            if sec.header.sh_link >= len(self.sections):
                continue

            s_strtab = self.sections[sec.header.sh_link]
            if s_strtab.header.sh_type != shdr_type['SHT_STRTAB']:
                continue

            # for each symbol entry then: a name should be found in strtab
            # or then for symbol entry describing section it should be
            # set to related section's name.
            for s_entry in sec.symtab:
                s_entry.name = getNameFromStrTab(s_entry.st_name,
                                                 s_strtab.strtab)
                if s_entry.name == 'null':
                    if s_entry.st_type == symtab_type['STT_SECTION']:
                        s_entry.name = self.sections[s_entry.st_shndx].name
示例#3
0
    def load_sections_names(self):
        """ Loads sections names from shstrtab if possible """

        # index should exists in section table
        if self.header.e_shstrndx >= len(self.sections):
            return

        if self.header.e_shstrndx <= 0:
            return

        # Then related section should be strtab type of
        shstrtab = self.sections[self.header.e_shstrndx]
        if shstrtab.header.sh_type != shdr_type['SHT_STRTAB']:
            return

        # Then trying to set a name if possible
        for sec in self.sections:
            sec.name = getNameFromStrTab(sec.header.sh_name, shstrtab.strtab)
示例#4
0
    def load_sections_names(self):
        """ Loads sections names from shstrtab if possible """

        # index should exists in section table
        if self.header.e_shstrndx >= len(self.sections):
            return

        if self.header.e_shstrndx <= 0:
            return

        # Then related section should be strtab type of
        shstrtab = self.sections[self.header.e_shstrndx]
        if shstrtab.header.sh_type != shdr_type['SHT_STRTAB']:
            return

        # Then trying to set a name if possible
        for sec in self.sections:
            sec.name = getNameFromStrTab(sec.header.sh_name, shstrtab.strtab)