Skip to content

Commit

Permalink
relocation: Mark methods as staticmethod
Browse files Browse the repository at this point in the history
A method expects `self` as the first argument; they are all functions.

Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
  • Loading branch information
pmhahn committed Feb 24, 2025
1 parent 1eb806b commit c7f2261
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions elftools/elf/relocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,27 +340,35 @@ def _do_apply_relocation(self, stream, reloc, symtab):
_RELOCATION_RECIPE_TYPE = namedtuple('_RELOCATION_RECIPE_TYPE',
'bytesize has_addend calc_func')

@staticmethod
def _reloc_calc_identity(value, sym_value, offset, addend=0):
return value

@staticmethod
def _reloc_calc_sym_plus_value(value, sym_value, offset, addend=0):
return sym_value + value + addend

@staticmethod
def _reloc_calc_sym_plus_value_pcrel(value, sym_value, offset, addend=0):
return sym_value + value - offset

@staticmethod
def _reloc_calc_sym_plus_addend(value, sym_value, offset, addend=0):
return sym_value + addend

@staticmethod
def _reloc_calc_sym_plus_addend_pcrel(value, sym_value, offset, addend=0):
return sym_value + addend - offset

@staticmethod
def _reloc_calc_value_minus_sym_addend(value, sym_value, offset, addend=0):
return value - sym_value - addend

@staticmethod
def _arm_reloc_calc_sym_plus_value_pcrel(value, sym_value, offset, addend=0):
return sym_value // 4 + value - offset // 4

@staticmethod
def _bpf_64_32_reloc_calc_sym_plus_addend(value, sym_value, offset, addend=0):
return (sym_value + addend) // 8 - 1

Expand Down

0 comments on commit c7f2261

Please sign in to comment.