ida_fixup

Functions that deal with fixup information.

A loader should setup fixup information using set_fixup().

Attributes

SWIG_PYTHON_LEGACY_BOOL

FIXUP_OFF8

8-bit offset

FIXUP_OFF16

16-bit offset

FIXUP_SEG16

16-bit base-logical segment base (selector)

FIXUP_PTR16

32-bit long pointer (16-bit base:16-bit offset)

FIXUP_OFF32

32-bit offset

FIXUP_PTR32

48-bit pointer (16-bit base:32-bit offset)

FIXUP_HI8

high 8 bits of 16bit offset

FIXUP_HI16

high 16 bits of 32bit offset

FIXUP_LOW8

low 8 bits of 16bit offset

FIXUP_LOW16

low 16 bits of 32bit offset

V695_FIXUP_VHIGH

obsolete

V695_FIXUP_VLOW

obsolete

FIXUP_OFF64

64-bit offset

FIXUP_OFF8S

8-bit signed offset

FIXUP_OFF16S

16-bit signed offset

FIXUP_OFF32S

32-bit signed offset

FIXUP_CUSTOM

start of the custom types range

FIXUPF_REL

fixup is relative to the linear address base. Otherwise fixup is relative to the start of the segment with sel selector.

FIXUPF_EXTDEF

target is a location (otherwise - segment). Use this bit if the target is a symbol rather than an offset from the beginning of a segment.

FIXUPF_UNUSED

fixup is ignored by IDA

FIXUPF_CREATED

fixup was not present in the input file

FIXUPF_LOADER_MASK

additional flags. The bits from this mask are not stored in the database and can be used by the loader at its discretion.

Classes

fixup_data_t

fixup_info_t

Functions

is_fixup_custom(→ bool)

Is fixup processed by processor module?

get_fixup(→ bool)

Get fixup information.

exists_fixup(→ bool)

Check that a fixup exists at the given address.

set_fixup(→ None)

Set fixup information. You should fill fixup_data_t and call this function and the kernel will remember information in the database.

del_fixup(→ None)

Delete fixup information.

get_first_fixup_ea(→ ida_idaapi.ea_t)

get_next_fixup_ea(→ ida_idaapi.ea_t)

get_prev_fixup_ea(→ ida_idaapi.ea_t)

get_fixup_handler(→ fixup_handler_t const *)

Get handler of standard or custom fixup.

get_fixup_value(→ int)

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.

patch_fixup_value(→ 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.

get_fixup_desc(→ str)

Get FIXUP description comment.

calc_fixup_size(→ int)

Calculate size of fixup in bytes (the number of bytes the fixup patches)

find_custom_fixup(→ fixup_type_t)

get_fixups(→ bool)

contains_fixups(→ bool)

Does the specified address range contain any fixup information?

gen_fix_fixups(→ None)

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).

handle_fixups_in_macro(→ bool)

Handle two fixups in a macro. We often combine two instruction that load parts of a value into one macro instruction. For example:

Module Contents

ida_fixup.SWIG_PYTHON_LEGACY_BOOL
ida_fixup.FIXUP_OFF8

8-bit offset

ida_fixup.FIXUP_OFF16

16-bit offset

ida_fixup.FIXUP_SEG16

16-bit base-logical segment base (selector)

ida_fixup.FIXUP_PTR16

32-bit long pointer (16-bit base:16-bit offset)

ida_fixup.FIXUP_OFF32

32-bit offset

ida_fixup.FIXUP_PTR32

48-bit pointer (16-bit base:32-bit offset)

ida_fixup.FIXUP_HI8

high 8 bits of 16bit offset

ida_fixup.FIXUP_HI16

high 16 bits of 32bit offset

ida_fixup.FIXUP_LOW8

low 8 bits of 16bit offset

ida_fixup.FIXUP_LOW16

low 16 bits of 32bit offset

ida_fixup.V695_FIXUP_VHIGH

obsolete

ida_fixup.V695_FIXUP_VLOW

obsolete

ida_fixup.FIXUP_OFF64

64-bit offset

ida_fixup.FIXUP_OFF8S

8-bit signed offset

ida_fixup.FIXUP_OFF16S

16-bit signed offset

ida_fixup.FIXUP_OFF32S

32-bit signed offset

ida_fixup.FIXUP_CUSTOM

start of the custom types range

ida_fixup.is_fixup_custom(type: fixup_type_t) bool

Is fixup processed by processor module?

ida_fixup.FIXUPF_REL

fixup is relative to the linear address base. Otherwise fixup is relative to the start of the segment with sel selector.

ida_fixup.FIXUPF_EXTDEF

target is a location (otherwise - segment). Use this bit if the target is a symbol rather than an offset from the beginning of a segment.

ida_fixup.FIXUPF_UNUSED

fixup is ignored by IDA * disallows the kernel to convert operands * this fixup is not used during output

ida_fixup.FIXUPF_CREATED

fixup was not present in the input file

ida_fixup.FIXUPF_LOADER_MASK

additional flags. The bits from this mask are not stored in the database and can be used by the loader at its discretion.

class ida_fixup.fixup_data_t(*args)

Bases: object

thisown
sel: sel_t

selector of the target segment. BADSEL means an absolute (zero based) target.

off: ida_idaapi.ea_t

target offset

displacement: adiff_t

displacement (offset from the target)

get_type() fixup_type_t

Fixup type Types of fixups.

set_type(type_: fixup_type_t) None
set_type_and_flags(type_: fixup_type_t, flags_: int = 0) None
is_custom() bool

is_fixup_custom()

get_flags() int

Fixup flags Fixup flags.

is_extdef() bool
set_extdef() None
clr_extdef() None
is_unused() bool
set_unused() None
clr_unused() None
has_base() bool

Is fixup relative?

was_created() bool

Is fixup artificial?

get_base() ida_idaapi.ea_t

Get base of fixup.

set_base(new_base: ida_idaapi.ea_t) None

Set base of fixup. The target should be set before a call of this function.

set_sel(seg: segment_t const *) None
set_target_sel() None

Set selector of fixup to the target. The target should be set before a call of this function.

set(source: ida_idaapi.ea_t) None

set_fixup()

get(source: ida_idaapi.ea_t) bool

get_fixup()

get_handler() fixup_handler_t const *

get_fixup_handler()

get_desc(source: ida_idaapi.ea_t) str

get_fixup_desc()

calc_size() int

calc_fixup_size()

get_value(ea: ida_idaapi.ea_t) int

get_fixup_value()

patch_value(ea: ida_idaapi.ea_t) bool

patch_fixup_value()

ida_fixup.get_fixup(fd: fixup_data_t, source: ida_idaapi.ea_t) bool

Get fixup information.

ida_fixup.exists_fixup(source: ida_idaapi.ea_t) bool

Check that a fixup exists at the given address.

ida_fixup.set_fixup(source: ida_idaapi.ea_t, fd: fixup_data_t) None

Set fixup information. You should fill fixup_data_t and call this function and the kernel will remember information in the database.

Parameters:
  • source – the fixup source address, i.e. the address modified by the fixup

  • fd – fixup data

ida_fixup.del_fixup(source: ida_idaapi.ea_t) None

Delete fixup information.

ida_fixup.get_first_fixup_ea() ida_idaapi.ea_t
ida_fixup.get_next_fixup_ea(ea: ida_idaapi.ea_t) ida_idaapi.ea_t
ida_fixup.get_prev_fixup_ea(ea: ida_idaapi.ea_t) ida_idaapi.ea_t
ida_fixup.get_fixup_handler(type: fixup_type_t) fixup_handler_t const *

Get handler of standard or custom fixup.

ida_fixup.get_fixup_value(ea: ida_idaapi.ea_t, type: fixup_type_t) int

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.

Parameters:
  • ea – address to get fixup bytes from, the size of the fixup bytes depends on the fixup type.

  • type – fixup type

Returns:

operand: value

ida_fixup.patch_fixup_value(ea: ida_idaapi.ea_t, fd: fixup_data_t) 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.

Parameters:
  • ea – address where data are changed, the size of the changed data depends on the fixup type.

  • fd – fixup data

Returns:

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.

ida_fixup.get_fixup_desc(source: ida_idaapi.ea_t, fd: fixup_data_t) str

Get FIXUP description comment.

ida_fixup.calc_fixup_size(type: fixup_type_t) int

Calculate size of fixup in bytes (the number of bytes the fixup patches)

Returns:

-1: means error

ida_fixup.find_custom_fixup(name: str) fixup_type_t
class ida_fixup.fixup_info_t

Bases: object

thisown
ea: ida_idaapi.ea_t
fd: fixup_data_t
ida_fixup.get_fixups(out: fixups_t *, ea: ida_idaapi.ea_t, size: asize_t) bool
ida_fixup.contains_fixups(ea: ida_idaapi.ea_t, size: asize_t) bool

Does the specified address range contain any fixup information?

ida_fixup.gen_fix_fixups(_from: ida_idaapi.ea_t, to: ida_idaapi.ea_t, size: asize_t) None

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).

ida_fixup.handle_fixups_in_macro(ri: refinfo_t, ea: ida_idaapi.ea_t, other: fixup_type_t, macro_reft_and_flags: int) bool
Handle two fixups in a macro. We often combine two instruction that load parts of a value into one macro instruction. For example:
ADRP X0, #var@PAGE

ADD X0, X0, #var@PAGEOFF –> ADRL X0, var

lui $v0, %hi(var)

addiu $v0, $v0, %lo(var) –> la $v0, var

Returns:

success (‘false’ means that RI was not changed)