Skip to content

Commit

Permalink
Fix remaining warnings and enable RTD failures on warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Aug 11, 2023
1 parent 1411960 commit 1b12d2a
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ python:
path: .
extra_requirements:
- docs

sphinx:
fail_on_warning: true
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ There are several backends that can be used to load a single file:
- PE is a backend to load Microsoft's Portable Executable format,
effectively Windows binaries. It uses the (optional) `pefile` module.

- Mach-O is a backend to load, you guessed it, Mach-O binaries. It is
subject to several limitations, which you can read about in the
[readme in the macho directory](backends/macho/README.md)
- Mach-O is a backend to load, you guessed it, Mach-O binaries. Support is
limited for this backend.

- Blob is a backend to load unknown data. It requires that you specify
the architecture it would be run on, in the form of a class from
Expand Down
21 changes: 0 additions & 21 deletions cle/backends/macho/README.md

This file was deleted.

17 changes: 8 additions & 9 deletions cle/backends/macho/macho.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,19 @@ def get_by_name_and_ordinal(self, name: str, ordinal: int, include_stab=False) -

# pylint: enable =abstract-method


class MachO(Backend):
"""
Mach-O binaries for CLE
-----------------------
The Mach-O format is notably different from other formats, as such:
* Sections are always part of a segment, self.sections will thus be empty
* Symbols cannot be categorized like in ELF
* Symbol resolution must be handled by the binary
* Rebasing in dyld is implemented via adding a small slide to addresses inside the binary, instead of
changing the base address of the binary and the addresses being relative. CLE needs relative addresses,
so there are a lot of AT.from_lva().to_rva() calls in this backend.
The Mach-O format is notably different from other formats. Specifically:
* ...
- Sections are always part of a segment, so `self.sections` will be empty.
- Symbols cannot be categorized like in ELF.
- Symbol resolution must be handled by the binary.
- Rebasing in dyld is implemented by adding a small slide to addresses inside the binary, instead of
changing the base address of the binary. Consequently, the addresses are absolute rather than relative.
CLE requires relative addresses, leading to numerous `AT.from_lva().to_rva()` calls in this backend.
"""

is_default = True # Tell CLE to automatically consider using the MachO backend
Expand Down
Empty file added docs/_static/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions docs/api/backend.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Backend Interface
=================

.. automodule:: cle.backends.backend
.. automodule:: cle.backends.symbol
.. automodule:: cle.backends.regions
Expand Down
3 changes: 3 additions & 0 deletions docs/api/backends/binja.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Binary Ninja
============

.. automodule:: cle.backends.binja
3 changes: 3 additions & 0 deletions docs/api/backends/blob.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Blob
====

.. automodule:: cle.backends.blob
3 changes: 3 additions & 0 deletions docs/api/backends/cgc.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CGC
===

.. automodule:: cle.backends.cgc
.. automodule:: cle.backends.cgc.cgc
.. automodule:: cle.backends.cgc.backedcgc
1 change: 0 additions & 1 deletion docs/api/backends/elf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ELF Backend
===========

.. autoclass:: cle.backends.ELF
.. autoclass:: cle.backends.ELFSymbol

.. autoclass:: cle.backends.elf.ELFCore

Expand Down
3 changes: 3 additions & 0 deletions docs/api/backends/ihex.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
IHex
====

.. automodule:: cle.backends.ihex
2 changes: 0 additions & 2 deletions docs/api/backends/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Backends
.. toctree::
:maxdepth: 1

.. Most common backends
ELF <elf>
PE <pe>
Mach-O <macho>

.. Other backends in alphabetical order
Binary Ninja <binja>
Blob <blob>
CGC <cgc>
Expand Down
3 changes: 3 additions & 0 deletions docs/api/backends/java.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Java
====

.. automodule:: cle.backends.java.android_lifecycle
.. automodule:: cle.backends.java.apk
.. automodule:: cle.backends.java.jar
Expand Down
5 changes: 2 additions & 3 deletions docs/api/backends/macho.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Mach-O Backend
==============
Mach-O
======

.. autoclass:: cle.backends.macho.macho.MachO
.. autoclass:: cle.backends.macho.macho.SymbolList
Expand All @@ -8,5 +8,4 @@ Mach-O Backend
.. automodule:: cle.backends.macho.section
.. automodule:: cle.backends.macho.segment
.. automodule:: cle.backends.macho.binding
.. automodule:: cle.backends.macho.macho_load_commands
.. automodule:: cle.backends.macho.structs
3 changes: 3 additions & 0 deletions docs/api/backends/minidump.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Minidump
========

.. automodule:: cle.backends.minidump
4 changes: 2 additions & 2 deletions docs/api/backends/pe.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PE Backend
==========
PE
==

.. autoclass:: cle.backends.PE

Expand Down
3 changes: 3 additions & 0 deletions docs/api/backends/static_archive.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Static Archive
==============

.. automodule:: cle.backends.static_archive
3 changes: 3 additions & 0 deletions docs/api/backends/uefi_firmware.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
UEFI Firmware
=============

.. automodule:: cle.backends.uefi_firmware
.. automodule:: cle.backends.te
3 changes: 3 additions & 0 deletions docs/api/backends/xbe.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Xbox Executable
===============

.. automodule:: cle.backends.xbe
2 changes: 1 addition & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ API Documentation
=================

.. toctree::
:maxdepth: 1
:maxdepth: 0

Loader Interface <loader>
Backend Interface <backend>
Expand Down
1 change: 0 additions & 1 deletion docs/api/relocations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Look at the existing versions for details.
.. automodule:: cle.backends.elf.relocation.elfreloc
.. automodule:: cle.backends.elf.relocation.mips64
.. automodule:: cle.backends.elf.relocation.generic
.. automodule:: cle.backends.elf.relocation.armel
.. automodule:: cle.backends.elf.relocation.ppc
.. automodule:: cle.backends.elf.relocation.armhf
.. automodule:: cle.backends.elf.relocation.pcc64
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
# "sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"myst_parser",
]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The first shows basic usage of CLE, and the second shows the API reference.


.. toctree::
:maxdepth: 5
:maxdepth: 1
:caption: Contents:

Quickstart <quickstart>
Expand Down

0 comments on commit 1b12d2a

Please sign in to comment.