Relocations#

CLE’s loader implements program relocation data on a plugin basis. If you would like to add more relocation implementations, do so by subclassing the Relocation class and overriding any relevant methods or properties. Put your subclasses in a module in the relocations subpackage of the appropraite backend package. The name of the subclass will be used to determine when to use it! Look at the existing versions for details.

class cle.backends.relocation.Relocation[source]#

Bases: object

A representation of a relocation in a binary file. Smart enough to relocate itself.

Variables:
  • owner – The binary this relocation was originaly found in, as a cle object

  • symbol – The Symbol object this relocation refers to

  • relative_addr – The address in owner this relocation would like to write to

  • resolvedby – If the symbol this relocation refers to is an import symbol and that import has been resolved, this attribute holds the symbol from a different binary that was used to resolve the import.

  • resolved – Whether the application of this relocation was successful

__init__(owner: Backend, symbol: Symbol | None, relative_addr: int)[source]#
Parameters:
AUTO_HANDLE_NONE = False#
resolve_symbol(solist: List[Any], thumb=False, extern_object=None, **kwargs)[source]#
Parameters:

solist (List[Any]) –

resolve(obj, **kwargs)[source]#
property rebased_addr#

The address in the global memory space this relocation would like to write to

property linked_addr#
property dest_addr#
property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

property owner_obj#
cle.backends.elf.relocation.load_relocations()[source]#
cle.backends.elf.relocation.get_relocation(arch, r_type)[source]#
class cle.backends.elf.relocation.elfreloc.ELFReloc[source]#

Bases: Relocation

__init__(owner, symbol, relative_addr, addend=None)[source]#
property addend#
resolvedby: Optional[Symbol]#
resolved: bool#
property value#
class cle.backends.elf.relocation.mips64.R_MIPS_64[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips64.R_MIPS_REL32[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips64.R_MIPS_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips64.R_MIPS_TLS_DTPMOD64[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips64.R_MIPS_TLS_DTPREL64[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips64.R_MIPS_TLS_TPREL64[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericTLSDoffsetReloc[source]#

Bases: ELFReloc

property value#
resolve_symbol(solist, **kwargs)[source]#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericTLSOffsetReloc[source]#

Bases: ELFReloc

AUTO_HANDLE_NONE = True#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericTLSDescriptorReloc[source]#

Bases: ELFReloc

RESOLVER_ADDR = NotImplemented#
AUTO_HANDLE_NONE = True#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericTLSModIdReloc[source]#

Bases: ELFReloc

AUTO_HANDLE_NONE = True#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericIRelativeReloc[source]#

Bases: ELFReloc

AUTO_HANDLE_NONE = True#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericAbsoluteAddendReloc[source]#

Bases: ELFReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericPCRelativeAddendReloc[source]#

Bases: ELFReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericJumpslotReloc[source]#

Bases: ELFReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericRelativeReloc[source]#

Bases: ELFReloc

AUTO_HANDLE_NONE = True#
property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericAbsoluteReloc[source]#

Bases: ELFReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.GenericCopyReloc[source]#

Bases: ELFReloc

resolve_symbol(solist, **kwargs)[source]#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.MipsGlobalReloc[source]#

Bases: GenericAbsoluteReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.MipsLocalReloc[source]#

Bases: ELFReloc

AUTO_HANDLE_NONE = True#
resolve_symbol(solist, **kwargs)[source]#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.generic.RelocTruncate32Mixin[source]#

Bases: object

A mix-in class for relocations that cover a 32-bit field regardless of the architecture’s address word length.

check_zero_extend = False#
check_sign_extend = False#
relocate()[source]#
class cle.backends.elf.relocation.generic.RelocGOTMixin[source]#

Bases: object

A mix-in class which will cause the symbol to be resolved to a pointer to the symbol instead of the symbol

resolve(symbol, extern_object=None, **kwargs)[source]#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR32[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR24[source]#

Bases: ELFReloc

Relocation Type: 0x2 Calculation: (S + A) >> 2 Field: low24*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR16[source]#

Bases: ELFReloc

Relocation Type: 0x3 Calculation: S+A Field: half16*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR16_LO[source]#

Bases: ELFReloc

Relocation Type: 0x4 Calculation: #lo(S + A) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR16_HI[source]#

Bases: ELFReloc

Relocation Type: 0x5 Calculation: #hi(S + A) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR16_HA[source]#

Bases: ELFReloc

Relocation Type: 0x6 Calculation: #ha(S + A) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR14[source]#

Bases: ELFReloc

Relocation Type: 0x7 Calculation: (S + A) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR14_BRTAKEN[source]#

Bases: ELFReloc

Relocation Type: 0x8 Calculation: (S + A) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR14_BRNTAKEN[source]#

Bases: ELFReloc

Relocation Type: 0x9 Calculation: (S + A) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_REL24[source]#

Bases: ELFReloc

Relocation Type: 0xa Calculation: (S + A - P) >> 2 Field: low24* R_PPC_REL24 is a special type of relocation. The instruction must be modified for this type. This relocation type resolves branch-and-link instructions. Prior to relocation, all instances of the branch-and-link instruction will consist of the following bytecode: 48 00 00 01. The problem with this is that all instances will result in calls to the current address - thus an infinite loop. After calculating the relocation result in R_PPC_REL24, you will have an address offset to the call. The result must be resolved to the correct instruction encoding.

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_REL14[source]#

Bases: ELFReloc

Relocation Type: 0xb Calculation: (S + A - P) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_REL14_BRTAKEN[source]#

Bases: ELFReloc

Relocation Type: 0xc Calculation: (S + A - P) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_REL14_BRNTAKEN[source]#

Bases: ELFReloc

Relocation Type: 0xd Calculation: (S + A - P) >> 2 Field: low14*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_JMP_SLOT[source]#

Bases: GenericJumpslotReloc

relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_UADDR32[source]#

Bases: ELFReloc

Relocation Type: 0x18 Calculation: S + A Field: word32

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_UADDR16[source]#

Bases: ELFReloc

Relocation Type: 0x19 Calculation: S + A Field: half16*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_REL32[source]#

Bases: ELFReloc

Relocation Type: 0x1a Calculation: S + A - P Field: word32

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_SECTOFF[source]#

Bases: ELFReloc

Relocation Type: 0x21 Calculation: R + A Field: half16*

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_SECTOFF_LO[source]#

Bases: ELFReloc

Relocation Type: 0x22 Calculation: #lo(R + A) Field: half16

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_SECTOFF_HI[source]#

Bases: ELFReloc

Relocation Type: 0x23 Calculation: #hi(R + A) Field: half16

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_SECTOFF_HA[source]#

Bases: ELFReloc

Relocation Type: 0x24 Calculation: #ha(R + A) Field: half16

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_ADDR30[source]#

Bases: ELFReloc

Relocation Type: 0x25 Calculation: (S + A - P) >> 2 Field: word30

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_DTPMOD32[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_DTPREL32[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.ppc.R_PPC_TPREL32[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_CALL symbols via instruction modification. It additionally handles R_ARM_PC24 and R_ARM_JUMP24. The former is deprecated and is now just the same as R_ARM_CALL.

R_ARM_JUMP24 doesn’t need the Thumb check. Technically, if the Thumb check succeeds on R_ARM_JUMP24, it’s a bad call that shouldn’t have been generated by the linker, so we may as well as just treat it like R_ARM_CALL.

  • Class: Static

  • Type: ARM (R_ARM_CALL, R_ARM_JUMP24); Deprecated (R_ARM_PC24)

  • Code: 1 (R_ARM_PC24), 28 (R_ARM_CALL), 29 (R_ARM_JUMP24)

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_PREL31[source]#

Bases: ELFReloc

Relocate R_ARM_PREL31 symbols via instruction modification. The difference between this and R_ARM_CALL/R_ARM_PC24/R_ARM_JUMP24 is that it’s a data relocation

  • Class: Static

  • Type: Data

  • Code: 42

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_REL32[source]#

Bases: ELFReloc

Relocate R_ARM_REL32 symbols. This is essentially the same as GenericPCRelativeAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_ABS32[source]#

Bases: ELFReloc

Relocate R_ARM_ABS32 symbols. This is essentially the same as GenericAbsoluteAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_MOVW_ABS_NC[source]#

Bases: ELFReloc

Relocate R_ARM_MOVW_ABS_NC symbols.

  • Class: Static

  • Type: Instruction

  • Code: 43

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_MOVT_ABS[source]#

Bases: ELFReloc

Relocate R_ARM_MOVT_ABS symbols.

  • Class: Static

  • Type: Instruction

  • Code: 44

  • Operation: S + A - S is the address of the symbol - A is the addend

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_THM_CALL symbols via instruction modification.

  • Class: Static

  • Type: ARM (R_ARM_THM_CALL)

  • Code: 10

  • Operation: ((S + A) | T) - P

    • S is the address of the symbol

    • A is the addend

    • P is the target location (place being relocated)

    • T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction (This bit is entirely irrelevant because the 1-bit of the address gets shifted off in the encoding)

  • Encoding: See http://hermes.wings.cs.wisc.edu/files/Thumb-2SupplementReferenceManual.pdf

__init__(*args, **kwargs)[source]#
resolve_symbol(solist, **kwargs)[source]#
property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_GOT_PREL[source]#

Bases: GenericPCRelativeAddendReloc, RelocTruncate32Mixin, RelocGOTMixin

GOT(S) + A - P Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_JUMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_ABS32_NOI[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_REL32_NOI[source]#

Bases: GenericPCRelativeAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_TLS_DTPMOD32[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_TLS_DTPOFF32[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_TLS_TPOFF32[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_JUMP24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_PC24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_JUMP24[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_JUMP19[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_JUMP6[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_MOVW_ABS_NC[source]#

Bases: ELFReloc

((S + A) | T) & 0xffff Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.armhf.R_ARM_THM_MOVT_ABS[source]#

Bases: ELFReloc

(S + A) & 0xffff0000 Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_JMP_SLOT[source]#

Bases: ELFReloc

relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_IRELATIVE[source]#

Bases: GenericIRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_ADDR64[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_DTPMOD64[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_DTPREL64[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_TPREL64[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_REL24[source]#

Bases: ELFReloc

Relocation Type: 10 Calculation: (S + A - P) >> 2 Field: low24*

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_TOC16_LO[source]#

Bases: ELFReloc

Relocation Type: 48 Calculation: #lo(S + A - .TOC.) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_TOC16_HI[source]#

Bases: ELFReloc

Relocation Type: 49 Calculation: #hi(S + A - .TOC.) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_TOC16_HA[source]#

Bases: ELFReloc

Relocation Type: 50 Calculation: #ha(S + A - .TOC.) Field: half16

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.pcc64.R_PPC64_TOC[source]#

Bases: ELFReloc

Relocation Type: 51 Calculation: .TOC. Field: doubleword64

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_32[source]#

Bases: GenericAbsoluteAddendReloc

Value: 1 Field: word32 Calculation: S + A

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_PC32[source]#

Bases: GenericPCRelativeAddendReloc

Value: 2 Field: word32 Calculation: S + A - P

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_COPY[source]#

Bases: GenericCopyReloc

Value: 5 Field: Calculation:

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

Value: 6 Field: word32 Calculation: S

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_JMP_SLOT[source]#

Bases: GenericJumpslotReloc

Value: 7 Field: word32 Calculation: S

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_RELATIVE[source]#

Bases: GenericRelativeReloc

Value: 8 Field: word32 Calculation: B + A

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_IRELATIVE[source]#

Bases: GenericIRelativeReloc

Value: 42 Field: word32 Calculation: indirect (B + A)

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_TLS_DTPMOD32[source]#

Bases: GenericTLSModIdReloc

Value: 35 Field: word32 Calculation:

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_TLS_TPOFF[source]#

Bases: GenericTLSOffsetReloc

Value: 14 Field: word32 Calculation:

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_TLS_DTPOFF32[source]#

Bases: GenericTLSDoffsetReloc

Value: 36 Field: word32 Calculation:

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_PLT32[source]#

Bases: GenericPCRelativeAddendReloc

Value: 4 Field: word32 Calculation: L + A - P

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.i386.R_386_GOTPC[source]#

Bases: GenericPCRelativeAddendReloc, RelocGOTMixin

Value: 10 Field: word32 Calculation: GOT + A - P

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_64[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_IRELATIVE[source]#

Bases: GenericIRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_JUMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_DTPMOD64[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_DTPOFF64[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_TPOFF64[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.amd64.R_X86_64_PC32[source]#

Bases: RelocTruncate32Mixin, GenericPCRelativeAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_32[source]#

Bases: RelocTruncate32Mixin, GenericAbsoluteAddendReloc

check_zero_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_32S[source]#

Bases: RelocTruncate32Mixin, GenericAbsoluteAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_PLT32[source]#

Bases: RelocTruncate32Mixin, GenericPCRelativeAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_GOTPCREL[source]#

Bases: RelocGOTMixin, RelocTruncate32Mixin, GenericPCRelativeAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_GOTPCRELX[source]#

Bases: RelocGOTMixin, RelocTruncate32Mixin, GenericPCRelativeAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.amd64.R_X86_64_REX_GOTPCRELX[source]#

Bases: RelocGOTMixin, RelocTruncate32Mixin, GenericPCRelativeAddendReloc

check_sign_extend = True#
class cle.backends.elf.relocation.mips.R_MIPS_32[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_REL32[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_JUMP_SLOT[source]#

Bases: GenericAbsoluteReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_GLOB_DAT[source]#

Bases: GenericAbsoluteReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_TLS_DTPMOD32[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_TLS_TPREL32[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_TLS_DTPREL32[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_HI16[source]#

Bases: GenericAbsoluteReloc

relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.mips.R_MIPS_LO16[source]#

Bases: GenericAbsoluteReloc

relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_CALL symbols via instruction modification. It additionally handles R_ARM_PC24 and R_ARM_JUMP24. The former is deprecated and is now just the same as R_ARM_CALL.

R_ARM_JUMP24 doesn’t need the Thumb check. Technically, if the Thumb check succeeds on R_ARM_JUMP24, it’s a bad call that shouldn’t have been generated by the linker, so we may as well as just treat it like R_ARM_CALL.

  • Class: Static

  • Type: ARM (R_ARM_CALL, R_ARM_JUMP24); Deprecated (R_ARM_PC24)

  • Code: 1 (R_ARM_PC24), 28 (R_ARM_CALL), 29 (R_ARM_JUMP24)

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_PREL31[source]#

Bases: ELFReloc

Relocate R_ARM_PREL31 symbols via instruction modification. The difference between this and R_ARM_CALL/R_ARM_PC24/R_ARM_JUMP24 is that it’s a data relocation

  • Class: Static

  • Type: Data

  • Code: 42

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_REL32[source]#

Bases: ELFReloc

Relocate R_ARM_REL32 symbols. This is essentially the same as GenericPCRelativeAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_ABS32[source]#

Bases: ELFReloc

Relocate R_ARM_ABS32 symbols. This is essentially the same as GenericAbsoluteAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_MOVW_ABS_NC[source]#

Bases: ELFReloc

Relocate R_ARM_MOVW_ABS_NC symbols.

  • Class: Static

  • Type: Instruction

  • Code: 43

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_MOVT_ABS[source]#

Bases: ELFReloc

Relocate R_ARM_MOVT_ABS symbols.

  • Class: Static

  • Type: Instruction

  • Code: 44

  • Operation: S + A - S is the address of the symbol - A is the addend

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_THM_CALL symbols via instruction modification.

  • Class: Static

  • Type: ARM (R_ARM_THM_CALL)

  • Code: 10

  • Operation: ((S + A) | T) - P

    • S is the address of the symbol

    • A is the addend

    • P is the target location (place being relocated)

    • T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction (This bit is entirely irrelevant because the 1-bit of the address gets shifted off in the encoding)

  • Encoding: See http://hermes.wings.cs.wisc.edu/files/Thumb-2SupplementReferenceManual.pdf

__init__(*args, **kwargs)[source]#
resolve_symbol(solist, **kwargs)[source]#
property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_JUMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_ABS32_NOI[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_REL32_NOI[source]#

Bases: GenericPCRelativeAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_TLS_DTPMOD32[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_TLS_DTPOFF32[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_TLS_TPOFF32[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_JUMP24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_PC24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_JUMP24[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_JUMP19[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_JUMP6[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_MOVW_ABS_NC[source]#

Bases: ELFReloc

((S + A) | T) & 0xffff Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_THM_MOVT_ABS[source]#

Bases: ELFReloc

(S + A) & 0xffff0000 Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm.R_ARM_GOT_PREL[source]#

Bases: GenericPCRelativeAddendReloc, RelocTruncate32Mixin, RelocGOTMixin

GOT(S) + A - P Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_CALL symbols via instruction modification. It additionally handles R_ARM_PC24 and R_ARM_JUMP24. The former is deprecated and is now just the same as R_ARM_CALL.

R_ARM_JUMP24 doesn’t need the Thumb check. Technically, if the Thumb check succeeds on R_ARM_JUMP24, it’s a bad call that shouldn’t have been generated by the linker, so we may as well as just treat it like R_ARM_CALL.

  • Class: Static

  • Type: ARM (R_ARM_CALL, R_ARM_JUMP24); Deprecated (R_ARM_PC24)

  • Code: 1 (R_ARM_PC24), 28 (R_ARM_CALL), 29 (R_ARM_JUMP24)

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_PREL31[source]#

Bases: ELFReloc

Relocate R_ARM_PREL31 symbols via instruction modification. The difference between this and R_ARM_CALL/R_ARM_PC24/R_ARM_JUMP24 is that it’s a data relocation

  • Class: Static

  • Type: Data

  • Code: 42

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_REL32[source]#

Bases: ELFReloc

Relocate R_ARM_REL32 symbols. This is essentially the same as GenericPCRelativeAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: ((S + A) | T) - P - S is the address of the symbol - A is the addend - P is the target location (place being relocated) - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_ABS32[source]#

Bases: ELFReloc

Relocate R_ARM_ABS32 symbols. This is essentially the same as GenericAbsoluteAddendReloc with the addition of a check for whether or not the target is Thumb.

  • Class: Static

  • Type: Data

  • Code: 3

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_MOVW_ABS_NC[source]#

Bases: ELFReloc

Relocate R_ARM_MOVW_ABS_NC symbols.

  • Class: Static

  • Type: Instruction

  • Code: 43

  • Operation: (S + A) | T - S is the address of the symbol - A is the addend - T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_MOVT_ABS[source]#

Bases: ELFReloc

Relocate R_ARM_MOVT_ABS symbols.

  • Class: Static

  • Type: Instruction

  • Code: 44

  • Operation: S + A - S is the address of the symbol - A is the addend

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_CALL[source]#

Bases: ELFReloc

Relocate R_ARM_THM_CALL symbols via instruction modification.

  • Class: Static

  • Type: ARM (R_ARM_THM_CALL)

  • Code: 10

  • Operation: ((S + A) | T) - P

    • S is the address of the symbol

    • A is the addend

    • P is the target location (place being relocated)

    • T is 1 if the symbol is of type STT_FUNC and addresses a Thumb instruction (This bit is entirely irrelevant because the 1-bit of the address gets shifted off in the encoding)

  • Encoding: See http://hermes.wings.cs.wisc.edu/files/Thumb-2SupplementReferenceManual.pdf

__init__(*args, **kwargs)[source]#
resolve_symbol(solist, **kwargs)[source]#
property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_JUMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_ABS32_NOI[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_REL32_NOI[source]#

Bases: GenericPCRelativeAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_TLS_DTPOFF32[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_TLS_TPOFF32[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_JUMP24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_PC24[source]#

Bases: R_ARM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_JUMP24[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_JUMP19[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_JUMP6[source]#

Bases: R_ARM_THM_CALL

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_MOVW_ABS_NC[source]#

Bases: ELFReloc

((S + A) | T) & 0xffff Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm_cortex_m.R_ARM_THM_MOVT_ABS[source]#

Bases: ELFReloc

(S + A) & 0xffff0000 Ref: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_ABS64[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_JUMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_IRELATIVE[source]#

Bases: GenericIRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_TLS_DTPREL[source]#

Bases: GenericTLSDoffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_TLS_DTPMOD[source]#

Bases: GenericTLSModIdReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_TLS_TPREL[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_TLSDESC[source]#

Bases: GenericTLSDescriptorReloc

RESOLVER_ADDR = 18446744073709551104#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_CALL26[source]#

Bases: ELFReloc

Relocation Type: 283 Calculation: (S + A - P)

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_ADR_PREL_PG_HI21[source]#

Bases: ELFReloc

Relocation Type: 275 Calculation: Page(S + A) - Page(P)

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.arm64.R_AARCH64_ADD_ABS_LO12_NC[source]#

Bases: ELFReloc

Relocation Type: 275 Calculation: (S + A)

property value#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_GLOB_DAT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_JMP_SLOT[source]#

Bases: GenericJumpslotReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_RELATIVE[source]#

Bases: GenericRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_64[source]#

Bases: GenericAbsoluteAddendReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_TLS_TPOFF[source]#

Bases: GenericTLSOffsetReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_IRELATIVE[source]#

Bases: GenericIRelativeReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.elf.relocation.s390x.R_390_COPY[source]#

Bases: GenericCopyReloc

resolvedby: Optional[Symbol]#
resolved: bool#
cle.backends.pe.relocation.load_relocations()[source]#
cle.backends.pe.relocation.get_relocation(arch, r_type)[source]#
class cle.backends.pe.relocation.pereloc.PEReloc[source]#

Bases: Relocation

AUTO_HANDLE_NONE = True#
__init__(owner, symbol, addr, resolvewith=None)[source]#
resolve_symbol(solist, bypass_compatibility=False, extern_object=None, **kwargs)[source]#
relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

property value#
property is_base_reloc#

These relocations are ignored by the linker if the executable is loaded at its preferred base address. There is no associated symbol with base relocations.

property is_import#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.DllImport[source]#

Bases: PEReloc

There’s nothing special to be done for DLL imports but this class provides a unique name to the relocation type.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_ABSOLUTE[source]#

Bases: PEReloc

relocate()[source]#

Applies this relocation. Will make changes to the memory object of the object it came from.

This implementation is a generic version that can be overridden in subclasses.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: PEReloc

__init__(owner, addr, next_rva)[source]#
property value#

In all the other cases, we can ignore the relocation difference part of the calculation because we simply use to_mva() to get our rebased address. In this case, however, we have to adjust the un-rebased address first.

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: PEReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_DIR64[source]#

Bases: PEReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_HIGH[source]#

Bases: PEReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.generic.IMAGE_REL_BASED_LOW[source]#

Bases: PEReloc

property value#
resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.i386.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: IMAGE_REL_BASED_HIGHADJ

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.i386.IMAGE_REL_BASED_DIR64[source]#

Bases: IMAGE_REL_BASED_DIR64

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.i386.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: IMAGE_REL_BASED_HIGHLOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.i386.IMAGE_REL_BASED_HIGH[source]#

Bases: IMAGE_REL_BASED_HIGH

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.i386.IMAGE_REL_BASED_LOW[source]#

Bases: IMAGE_REL_BASED_LOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.amd64.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: IMAGE_REL_BASED_HIGHADJ

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.amd64.IMAGE_REL_BASED_DIR64[source]#

Bases: IMAGE_REL_BASED_DIR64

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.amd64.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: IMAGE_REL_BASED_HIGHLOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.amd64.IMAGE_REL_BASED_HIGH[source]#

Bases: IMAGE_REL_BASED_HIGH

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.amd64.IMAGE_REL_BASED_LOW[source]#

Bases: IMAGE_REL_BASED_LOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: IMAGE_REL_BASED_HIGHADJ

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_DIR64[source]#

Bases: IMAGE_REL_BASED_DIR64

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: IMAGE_REL_BASED_HIGHLOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_HIGH[source]#

Bases: IMAGE_REL_BASED_HIGH

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_LOW[source]#

Bases: IMAGE_REL_BASED_LOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_MIPS_JMPADDR[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.mips.IMAGE_REL_BASED_MIPS_JMPADDR16[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: IMAGE_REL_BASED_HIGHADJ

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_DIR64[source]#

Bases: IMAGE_REL_BASED_DIR64

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: IMAGE_REL_BASED_HIGHLOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_HIGH[source]#

Bases: IMAGE_REL_BASED_HIGH

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_LOW[source]#

Bases: IMAGE_REL_BASED_LOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_ARM_MOV32[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.arm.IMAGE_REL_BASED_THUMB_MOV32[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_HIGHADJ[source]#

Bases: IMAGE_REL_BASED_HIGHADJ

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_DIR64[source]#

Bases: IMAGE_REL_BASED_DIR64

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_HIGHLOW[source]#

Bases: IMAGE_REL_BASED_HIGHLOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_HIGH[source]#

Bases: IMAGE_REL_BASED_HIGH

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_LOW[source]#

Bases: IMAGE_REL_BASED_LOW

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_RISCV_HIGH20[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_RISCV_LOW12I[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#
class cle.backends.pe.relocation.riscv.IMAGE_REL_BASED_RISCV_LOW12S[source]#

Bases: PEReloc

resolvedby: Optional[Symbol]#
resolved: bool#