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

Add BIND_OPCODE_THREADED and related subcodes support #524

Closed
Grivus opened this issue Jan 15, 2021 · 1 comment
Closed

Add BIND_OPCODE_THREADED and related subcodes support #524

Grivus opened this issue Jan 15, 2021 · 1 comment
Assignees

Comments

@Grivus
Copy link

Grivus commented Jan 15, 2021

Describe the bug
Currently, LIEF does not support the new opcodes introduced in macOS 10.16 Big Sur:

#define BIND_OPCODE_THREADED 0xD0
#define BIND_SUBOPCODE_THREADED_SET_BIND_ORDINAL_TABLE_SIZE_ULEB 0x00
#define BIND_SUBOPCODE_THREADED_APPLY 0x01
from SDK/usr/include/mach-o/loader.h
(also see https://opensource.apple.com/source/dyld/dyld-635.2/src/dyldInitialization.cpp.auto.html)

That stops the user from partially parsing and totally modifying any mach-o binary from Big Sur with such error:
"Unsupported opcode: 0xd0"

To Reproduce
Steps to reproduce the behavior:
I suggest to run macho_reader console application from LIEF and point it to the /bin/ls
There will be several "Unsupported opcode: 0xd0" output strings in the end.
It is also reproduced with macho_builder.

Expected behavior
I'm expecting that the binary would be successfully parsed without any "Unsupported opcode" messages.

Environment (please complete the following information):

  • System and Version : macOS 10.16 Big Sur (the bug could be reproduced on any Big Sur release version)
  • Target format: Mach-O
  • LIEF commit version: latest master

Additional context
There are one new opcode and 2 subcodes for it introduced first in iOS SDK and later with Big Sur too.
Some opensource projects are already have partially or full support of such opcodes:
https://github.com/DeVaukz/MachO-Kit
(I were able to correctly parse the /bin/ls from Big Sur with https://github.com/DeVaukz/MachO-Explorer linked against the MachO_Kit, there are some logic for such opcodes and subcodes)

also radare2 has some support: radareorg/radare2@0b91114

some info is here too (search the "0xd"): http://www.newosxbook.com/articles/DYLD.html

@romainthomas
Copy link
Member

After a quick check, I'll support this new opcodes after the release of v0.11.0 (and then release a patched version accordingly)

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

No branches or pull requests

2 participants