Module ida_fixup

A loader should setup fixup information using set_fixup().

Global Variables

FIXUPF_CREATED

FIXUPF_CREATED = 8

FIXUPF_EXTDEF

FIXUPF_EXTDEF = 2

FIXUPF_LOADER_MASK

FIXUPF_LOADER_MASK = -268435456

FIXUPF_REL

FIXUPF_REL = 1

FIXUPF_UNUSED

FIXUPF_UNUSED = 4

FIXUP_CUSTOM

FIXUP_CUSTOM = 32768

FIXUP_HI16

FIXUP_HI16 = 7

FIXUP_HI8

FIXUP_HI8 = 6

FIXUP_LOW16

FIXUP_LOW16 = 9

FIXUP_LOW8

FIXUP_LOW8 = 8

FIXUP_OFF16

FIXUP_OFF16 = 1

FIXUP_OFF16S

FIXUP_OFF16S = 15

FIXUP_OFF32

FIXUP_OFF32 = 4

FIXUP_OFF32S

FIXUP_OFF32S = 16

FIXUP_OFF64

FIXUP_OFF64 = 12

FIXUP_OFF8

FIXUP_OFF8 = 13

FIXUP_OFF8S

FIXUP_OFF8S = 14

FIXUP_PTR16

FIXUP_PTR16 = 3

FIXUP_PTR32

FIXUP_PTR32 = 5

FIXUP_SEG16

FIXUP_SEG16 = 2

V695_FIXUP_VHIGH

V695_FIXUP_VHIGH = 10

V695_FIXUP_VLOW

V695_FIXUP_VLOW = 11

Functions

calc_fixup_size(type: fixup_type_t) ‑> int

calc_fixup_size(type) -> int Calculate size of fixup in bytes (the number of bytes the fixup patches) retval -1: means error

type: (C++: fixup_type_t)

contains_fixups(ea: ea_t, size: asize_t) ‑> bool

contains_fixups(ea, size) -> bool Does the specified address range contain any fixup information?

ea: (C++: ea_t)
size: (C++: asize_t)

del_fixup(source: ea_t) ‑> void

del_fixup(source) Delete fixup information.

source: (C++: ea_t)

exists_fixup(source: ea_t) ‑> bool

exists_fixup(source) -> bool Check that a fixup exists at the given address.

source: (C++: ea_t)

find_custom_fixup(name: char const *) ‑> fixup_type_t

find_custom_fixup(name) -> fixup_type_t Get id of a custom fixup handler.

name: (C++: const char *) name of the custom fixup handler
return: id with FIXUP_CUSTOM bit set or 0

gen_fix_fixups(_from: ea_t, to: ea_t, size: asize_t) ‑> void

gen_fix_fixups(_from, to, size) Relocate the bytes with fixup information once more (generic function). This function may be called from loader_t::move_segm() if it suits the goal. If loader_t::move_segm is not defined then this function will be called automatically when moving segments or rebasing the entire program. Special parameter values (from = BADADDR, size = 0, to = delta) are used when the function is called from rebase_program(delta).

from: (C++: ea_t)
to: (C++: ea_t)
size: (C++: asize_t)

get_first_fixup_ea() ‑> ea_t

get_first_fixup_ea() -> ea_t

get_fixup(fd: fixup_data_t, source: ea_t) ‑> bool

get_fixup(fd, source) -> bool Get fixup information.

fd: (C++: fixup_data_t *)
source: (C++: ea_t)

get_fixup_desc(source: ea_t, fd: fixup_data_t) ‑> fixup_data_t const &

get_fixup_desc(source, fd) -> str Get FIXUP description comment.

source: (C++: ea_t)
fd: (C++: const fixup_data_t &) fixup_data_t const &

get_fixup_handler(type: fixup_type_t) ‑> fixup_handler_t const *

get_fixup_handler(type) -> fixup_handler_t const * Get handler of standard or custom fixup.

type: (C++: fixup_type_t)

get_fixup_value(ea: ea_t, type: fixup_type_t) ‑> uval_t

get_fixup_value(ea, type) -> uval_t Get the operand value. This function get fixup bytes from data or an instruction at ea' and convert them to the operand value (maybe partially). It is opposite in meaning to the patch_fixup_value(). For example, FIXUP_HI8 read a byte at ea' and shifts it left by 8 bits, or AArch64's custom fixup BRANCH26 get low 26 bits of the insn at `ea' and shifts it left by 2 bits. This function is mainly used to get a relocation addend.

ea: (C++: ea_t) address to get fixup bytes from, the size of the fixup bytes depends
          on the fixup type.

@see: fixup_handler_t::size type: (C++: fixup_type_t) fixup type retval operand: value

get_fixups(out: fixups_t *, ea: ea_t, size: asize_t) ‑> bool

get_fixups(out, ea, size) -> bool

out: fixups_t *
ea: ea_t
size: asize_t

get_next_fixup_ea(ea: ea_t) ‑> ea_t

get_next_fixup_ea(ea) -> ea_t Find next address with fixup information

ea: (C++: ea_t) current address
return: the next address with fixup information, or BADADDR

get_prev_fixup_ea(ea: ea_t) ‑> ea_t

get_prev_fixup_ea(ea) -> ea_t Find previous address with fixup information

ea: (C++: ea_t) current address
return: the previous address with fixup information, or BADADDR

handle_fixups_in_macro(ri: refinfo_t, ea: ea_t, other: fixup_type_t, macro_reft_and_flags: uint32) ‑> bool

handle_fixups_in_macro(ri, ea, other, macro_reft_and_flags) -> bool Handle two fixups in a macro. We often combine two instruction that load parts of a value into one macro instruction. For example: ARM: ADRP X0, #var@PAGE ADD X0, X0, #var@PAGEOFF --> ADRL X0, var MIPS: lui $v0, %hi(var) addiu $v0, $v0, %lo(var) --> la $v0, var When applying the fixups that fall inside such a macro, we should convert them to one refinfo. This function does exactly that. It should be called from the apply() callback of a custom fixup.

ri: (C++: refinfo_t *)
ea: (C++: ea_t)
other: (C++: fixup_type_t)
macro_reft_and_flags: (C++: uint32)
return: success ('false' means that RI was not changed)

is_fixup_custom(type: fixup_type_t) ‑> bool

is_fixup_custom(type) -> bool Is fixup processed by processor module?

type: (C++: fixup_type_t)

patch_fixup_value(ea: ea_t, fd: fixup_data_t) ‑> bool

patch_fixup_value(ea, fd) -> bool Patch the fixup bytes. This function updates data or an instruction at ea' to the fixup bytes. For example, FIXUP_HI8 updates a byte at ea' to the high byte of fd->off', or AArch64's custom fixup BRANCH26 updates low 26 bits of the insn at ea' to the value of `fd->off' shifted right by 2.

ea: (C++: ea_t) address where data are changed, the size of the changed data depends
          on the fixup type.

@see: fixup_handler_t::size fd: (C++: const fixup_data_t &) fixup data retval false: the fixup bytes do not fit (e.g. `fd->off' is greater than 0xFFFFFFC for BRANCH26). The database is changed even in this case.

set_fixup(source: ea_t, fd: fixup_data_t) ‑> void

set_fixup(source, fd) Set fixup information. You should fill fixup_data_t and call this function and the kernel will remember information in the database.

source: (C++: ea_t) the fixup source address, i.e. the address modified by the fixup
fd: (C++: const fixup_data_t &) fixup data

Classes

fixup_data_t(*args)

: Proxy of C++ fixup_data_t class.

__init__(self) -> fixup_data_t
__init__(self, type_, flags_=0) -> fixup_data_t

 type_: fixup_type_t
 flags_: uint32

Instance variables

  • displacement: adiff_t displacement


  • off: ea_t off


  • sel: sel_t sel


Methods

  • calc_size(self) ‑> int calc_size(self) -> int calc_fixup_size()


  • clr_extdef(self) ‑> void clr_extdef(self)


  • clr_unused(self) ‑> void clr_unused(self)


  • get(self, source: ea_t) ‑> bool get(self, source) -> bool get_fixup()

    source: (C++: ea_t)


  • get_base(self) ‑> ea_t get_base(self) -> ea_t Get base of fixup. note: The target is calculated as get_base() + off. @see: FIXUPF_REL


  • get_desc(self, source: ea_t) ‑> char const * get_desc(self, source) -> char const * get_fixup_desc()

    source: (C++: ea_t)


  • get_flags(self) ‑> uint32 get_flags(self) -> uint32 Fixup flags Fixup flags.


  • get_handler(self) ‑> fixup_handler_t const * get_handler(self) -> fixup_handler_t const * get_fixup_handler()


  • get_type(self) ‑> fixup_type_t get_type(self) -> fixup_type_t Fixup type Types of fixups.


  • get_value(self, ea: ea_t) ‑> uval_t get_value(self, ea) -> uval_t get_fixup_value()

    ea: (C++: ea_t)


  • has_base(self) ‑> bool has_base(self) -> bool Is fixup relative?


  • is_custom(self) ‑> bool is_custom(self) -> bool is_fixup_custom()


  • is_extdef(self) ‑> bool is_extdef(self) -> bool


  • is_unused(self) ‑> bool is_unused(self) -> bool


  • patch_value(self, ea: ea_t) ‑> bool patch_value(self, ea) -> bool patch_fixup_value()

    ea: (C++: ea_t)


  • set(self, source: ea_t) ‑> void set(self, source) set_fixup()

    source: (C++: ea_t)


  • set_base(self, new_base: ea_t) ‑> void set_base(self, new_base) Set base of fixup. The target should be set before a call of this function.

    new_base: (C++: ea_t)


  • set_extdef(self) ‑> void set_extdef(self)


  • set_sel(self, seg: segment_t const *) ‑> void set_sel(self, seg)

    seg: segment_t const *


  • set_target_sel(self) ‑> void set_target_sel(self) Set selector of fixup to the target. The target should be set before a call of this function.


  • set_type(self, type_: fixup_type_t) ‑> void set_type(self, type_)

    type_: fixup_type_t


  • set_type_and_flags(self, type_: fixup_type_t, flags_: uint32 = 0) ‑> void set_type_and_flags(self, type_, flags_=0)

    type_: fixup_type_t flags_: uint32


  • set_unused(self) ‑> void set_unused(self)


  • was_created(self) ‑> bool was_created(self) -> bool Is fixup artificial?


fixup_info_t()

: Proxy of C++ fixup_info_t class.

__init__(self) -> fixup_info_t

Instance variables

  • ea: ea_t ea


  • fd: fixup_data_t fd


Last updated