Skip to content

Support threaded binding opcodes #26

@PaulDance

Description

@PaulDance

As one can see in loader.h, some additional binding opcodes are defined:

#define BIND_OPCODE_THREADED                                    0xD0
#define BIND_SUBOPCODE_THREADED_SET_BIND_ORDINAL_TABLE_SIZE_ULEB 0x00
#define BIND_SUBOPCODE_THREADED_APPLY                            0x01

However, these are not found in this project's consts.rs:

rust-macho/src/consts.rs

Lines 844 to 855 in 4bf5fb1

pub const BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: u8 = 0x20;
pub const BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: u8 = 0x30;
pub const BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: u8 = 0x40;
pub const BIND_OPCODE_SET_TYPE_IMM: u8 = 0x50;
pub const BIND_OPCODE_SET_ADDEND_SLEB: u8 = 0x60;
pub const BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: u8 = 0x70;
pub const BIND_OPCODE_ADD_ADDR_ULEB: u8 = 0x80;
pub const BIND_OPCODE_DO_BIND: u8 = 0x90;
pub const BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: u8 = 0xA0;
pub const BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: u8 = 0xB0;
pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = 0xC0;

and are therefore not handled in opcode.rs, which means that if a file contains some opcode of 0xd0 or 0xf0, then the parsing will fail on:

rust-macho/src/opcode.rs

Lines 148 to 152 in 4bf5fb1

(opcode, immediate) => {
warn!("unknown bind opcode: {:x}, immediate = {}", opcode, immediate);
None
}

while it should not. There should instead be some support for these cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions