Output readability improved

This commit is contained in:
Nicolas 2025-02-28 15:42:38 +01:00
parent 553355cc12
commit d4c68c8e42
2 changed files with 20 additions and 11 deletions

View File

@ -112,7 +112,7 @@ class elf_symbol():
f'name {self.name}\n' +\ f'name {self.name}\n' +\
f'stb {self.stb} ({self.stb_description})\n' +\ f'stb {self.stb} ({self.stb_description})\n' +\
f'info {self.info} ({self.description})\n' +\ f'info {self.info} ({self.description})\n' +\
'\n'.join(f'{k:18} {v:4}' for k, v in self.fields.items()) + '\n' '\n'.join(f"{k:18} {v:4} {fdat.symbol_fields[k]}" for k, v in self.fields.items()) + '\n'
class elf_section(): class elf_section():
@ -338,9 +338,9 @@ class symbol_list(elf_list[elf_symbol]):
"""A class for representing a list of ELF symbols """A class for representing a list of ELF symbols
""" """
def _compact_table(self) -> tuple[list[str], list[list[int | str]], list[str]]: def _compact_table(self) -> tuple[list[str], list[list[int | str]], list[str]]:
columns = ['index', 'name', 'info', 'size', 'stb', 'description'] columns = ['index', 'name', 'info', 'size', 'stb', 'section', 'description']
data: list[list[str | int]] = [[item.index, item.name, item.info, item.fields['st_size'], data: list[list[str | int]] = [[item.index, item.name, item.info, item.fields['st_size'],
item.stb, item.description] for item in self] item.stb, item.section.name if item.section else '', item.description] for item in self]
return columns, data, ['index', 'size'] return columns, data, ['index', 'size']

View File

@ -316,16 +316,25 @@ section_header_types_ex = {0x60000000: 'OS-specific',
0x70000000: 'Processor-specific', 0x70000000: 'Processor-specific',
0x80000000: 'Application-specific'} 0x80000000: 'Application-specific'}
symbol_fields = {
"st_name": "Index into the string table for the symbol's name",
"st_info": "Encodes the symbol's type and its binding attribute",
"st_other": "Defines symbol visibility within and outside the object file",
"st_shndx": "Specifies which section this symbol is associated with",
"st_value": "Holds the symbol's address or offset, depending on context",
"st_size": "Specifies the size of the symbol (e.g., function length or variable size)"
}
st_info_values = { st_info_values = {
0: ("STT_NOTYPE", "Symbol type is unspecified"), 0: ("STT_NOTYPE", "Type is unspecified"),
1: ("STT_OBJECT", "Symbol is a data object"), 1: ("STT_OBJECT", "Data object"),
2: ("STT_FUNC", "Symbol is a code object"), 2: ("STT_FUNC", "Code object"),
3: ("STT_SECTION", "Symbol associated with a section"), 3: ("STT_SECTION", "Section associated"),
4: ("STT_FILE", "Symbol's name is file name"), 4: ("STT_FILE", "File name"),
5: ("STT_COMMON", "Symbol is a common data object"), 5: ("STT_COMMON", "Common data object"),
6: ("STT_TLS", "Symbol is thread-local data object"), 6: ("STT_TLS", "Thread-local data object"),
7: ("STT_NUM", "Number of defined types"), 7: ("STT_NUM", "Number of defined types"),
10: ("STT_GNU_IFUNC", "Symbol is indirect code object") 10: ("STT_GNU_IFUNC", "Indirect code object")
} }
stb_values = { stb_values = {