Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support threaded binding opcodes #26

Open
PaulDance opened this issue Nov 2, 2023 · 0 comments
Open

Support threaded binding opcodes #26

PaulDance opened this issue Nov 2, 2023 · 0 comments

Comments

@PaulDance
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant