Compare commits

...

4 Commits

Author SHA1 Message Date
Nicolas Kruse c6682effc7
Update __init__.py to fix typing of self._data to bytes 2025-07-23 23:01:41 +02:00
Nicolas Kruse 77f8b5ed44 ci/cd updated 2025-07-23 22:43:40 +02:00
Nicolas Kruse 75bde1ed99 symbol_list function made public 2025-07-23 22:43:21 +02:00
Nicolas Kruse 8da6ab4cd2 notebook removed 2025-07-23 22:42:04 +02:00
6 changed files with 36 additions and 1096 deletions

View File

@ -8,6 +8,7 @@ on:
jobs:
build:
name: Linting, typechecking and testing code
runs-on: ubuntu-latest
strategy:

View File

@ -9,7 +9,7 @@ permissions:
contents: write
jobs:
build-and-deploy:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -30,8 +30,22 @@ jobs:
rm ./source/*.rst
make html
touch ./build/html/.nojekyll
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
branch: gh-pages
folder: docs/build/html
path: docs/build/html
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@ -9,6 +9,9 @@ jobs:
publish:
name: Build and publish
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/${{ github.event.repository.name }}/
steps:
- uses: actions/checkout@v3

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.vscode
# Jupyter Notebook
.ipynb_checkpoints

View File

@ -164,7 +164,7 @@ class elf_section():
def symbols(self) -> 'symbol_list':
"""All ELF symbols associated with this section
"""
return symbol_list(self.file._list_symbols(self.index))
return symbol_list(self.file.list_symbols(self.index))
@property
def data_hex(self) -> str:
@ -371,7 +371,7 @@ class elf_file:
data: binary ELF data
"""
assert isinstance(data, (bytes, bytearray)), 'Binary ELF data must be provided as bytes or bytearray.'
self._data = data
self._data = bytes(data)
# Defaults required for function _read_int_from_elf_field
self.bit_width = 32
@ -403,7 +403,7 @@ class elf_file:
ret_sections = [sh for sh in self.sections if sh.name == '.strtab']
self.string_table_section = ret_sections[0] if ret_sections else None
self.symbols = symbol_list(self._list_symbols())
self.symbols = symbol_list(self.list_symbols())
self.functions = symbol_list(s for s in self.symbols if s.info == 'STT_FUNC')
self.objects = symbol_list(s for s in self.symbols if s.info == 'STT_OBJECT')
@ -415,7 +415,15 @@ class elf_file:
offs = self.fields['e_shoff'] + i * self.fields['e_shentsize']
yield {fn: self._read_from_sh_field(offs, fn) for fn in fdat.section_header.keys()}
def _list_symbols(self, section_index: Optional[int] = None) -> Generator[elf_symbol, None, None]:
def list_symbols(self, section_index: Optional[int] = None) -> Generator[elf_symbol, None, None]:
"""List ELF symbols.
Args:
section_index: If provided, only symbols from the specified section are returned.
Returns:
List of ELF symbols
"""
if self.symbol_table_section:
offs = self.symbol_table_section['sh_offset']

File diff suppressed because it is too large Load Diff