Compare commits

..

No commits in common. "c6682effc7b04f233c8021d67649fed3fb68ae82" and "cfbc53afc6c0ae25e56585f0c1bcaf9cbcf47fc4" have entirely different histories.

6 changed files with 1096 additions and 36 deletions

View File

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

View File

@ -9,7 +9,7 @@ permissions:
contents: write contents: write
jobs: jobs:
build: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -30,22 +30,8 @@ jobs:
rm ./source/*.rst rm ./source/*.rst
make html make html
touch ./build/html/.nojekyll touch ./build/html/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
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 - name: Deploy to GitHub Pages
id: deployment uses: JamesIves/github-pages-deploy-action@v4
uses: actions/deploy-pages@v4 with:
branch: gh-pages
folder: docs/build/html

View File

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

1
.gitignore vendored
View File

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

View File

@ -164,7 +164,7 @@ class elf_section():
def symbols(self) -> 'symbol_list': def symbols(self) -> 'symbol_list':
"""All ELF symbols associated with this section """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 @property
def data_hex(self) -> str: def data_hex(self) -> str:
@ -371,7 +371,7 @@ class elf_file:
data: binary ELF data data: binary ELF data
""" """
assert isinstance(data, (bytes, bytearray)), 'Binary ELF data must be provided as bytes or bytearray.' assert isinstance(data, (bytes, bytearray)), 'Binary ELF data must be provided as bytes or bytearray.'
self._data = bytes(data) self._data = data
# Defaults required for function _read_int_from_elf_field # Defaults required for function _read_int_from_elf_field
self.bit_width = 32 self.bit_width = 32
@ -403,7 +403,7 @@ class elf_file:
ret_sections = [sh for sh in self.sections if sh.name == '.strtab'] 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.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.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') self.objects = symbol_list(s for s in self.symbols if s.info == 'STT_OBJECT')
@ -415,15 +415,7 @@ class elf_file:
offs = self.fields['e_shoff'] + i * self.fields['e_shentsize'] 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()} 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: if self.symbol_table_section:
offs = self.symbol_table_section['sh_offset'] offs = self.symbol_table_section['sh_offset']

1087
tests/notebook.ipynb Normal file

File diff suppressed because it is too large Load Diff