mirror of https://github.com/Nonannet/pelfy.git
read data for SHT_NOBITS sections fixed
This commit is contained in:
parent
675146e744
commit
553355cc12
|
@ -73,6 +73,9 @@ class elf_symbol():
|
||||||
Symbol data
|
Symbol data
|
||||||
"""
|
"""
|
||||||
assert self.section, 'This symbol is not associated to a data section'
|
assert self.section, 'This symbol is not associated to a data section'
|
||||||
|
if self.section.type == 'SHT_NOBITS':
|
||||||
|
return b'\x00' * self['sh_size']
|
||||||
|
else:
|
||||||
offset = self.section['sh_offset'] + self['st_value']
|
offset = self.section['sh_offset'] + self['st_value']
|
||||||
return self.file.read_bytes(offset, self['st_size'])
|
return self.file.read_bytes(offset, self['st_size'])
|
||||||
|
|
||||||
|
@ -160,6 +163,9 @@ class elf_section():
|
||||||
Returns:
|
Returns:
|
||||||
Data of the section
|
Data of the section
|
||||||
"""
|
"""
|
||||||
|
if self.type == 'SHT_NOBITS':
|
||||||
|
return b'\x00' * self['sh_size']
|
||||||
|
else:
|
||||||
return self.file.read_bytes(self['sh_offset'], self['sh_size'])
|
return self.file.read_bytes(self['sh_offset'], self['sh_size'])
|
||||||
|
|
||||||
def get_symbols(self) -> 'symbol_list':
|
def get_symbols(self) -> 'symbol_list':
|
||||||
|
|
Loading…
Reference in New Issue