-
Notifications
You must be signed in to change notification settings - Fork 234
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
Uninstalling a load command doesn't update dynamic loader binding ordinals #2
Comments
Thanks for reporting this. I designed the uninstall command really to remove a command that was originally added with the tool so I didn't expect it to have to modify any dynamic loader info. However, I've looked at this a bit and it seems the opcodes are stored in the From the ABI:
|
Hi Alex, I ran into the same issue, but managed to get it working (better) by From what I found;
After doing some hand editing of the hex values, the binary made it further On Fri, Aug 29, 2014 at 10:43 AM, Alex Zielenski [email protected]
|
Alright, thanks for the info. With automation it should be trivial to be able to edit all of the higher opcodes. My only concern is about removing the opcodes relating to the uninstalled binary. Is this necessary? |
I found that I didn't need to remove opcodes pointing to the removed dylib, We could try removing them and see if it breaks. Some of the DATA segments The problem I'm trying to solve is removing unused dylibs that have been On Fri, Aug 29, 2014 at 11:15 AM, Alex Zielenski [email protected]
|
I think we have to remove them incase another dylib is added, then the opcode would reference that dylib and cause this issue all over again. |
Here is a snippet of code I wrote to parse the opcodes and log some offsets (using Chess.app) case LC_DYLD_INFO:
case LC_DYLD_INFO_ONLY: {
NSLog(@"%lu", (unsigned long)binary.currentOffset);
struct dyld_info_command info;
[binary getBytes:&info range:NSMakeRange(binary.currentOffset, size)];
NSLog(@"%u", info.bind_off);
NSLog(@"%u", info.weak_bind_off);
NSLog(@"%u", info.lazy_bind_off);
uint8_t *p = malloc(info.bind_size);
[binary getBytes:p range:NSMakeRange(info.bind_off, info.bind_size)];
uint8_t immediate = *p & BIND_IMMEDIATE_MASK;
uint8_t opcode = *p & BIND_OPCODE_MASK;
NSLog(@"%d, %d", opcode, immediate);
NSLog(@"%d", BIND_OPCODE_SET_DYLIB_ORDINAL_IMM);
NSLog(@"%d", BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB);
NSLog(@"%d", BIND_OPCODE_SET_DYLIB_SPECIAL_IMM);
binary.currentOffset += size;
break;
} And the output:
So it successfully gets the offsets of the bindings and as you can see the opcode in this example uses |
Hi Alex, That looks promising. Here's a real world use case for you. It's our game https://www.dropbox.com/s/5w2utv8g2shggpd/UberStrike.app.zip?dl=0 I initially just replaced the LC with another dummy, but if we can actually Best regards, On Sun, Aug 31, 2014 at 2:54 AM, Alex Zielenski [email protected]
|
I know it's been a while but I committed a first iteration of an implementation of this. I haven't tested it and I don't think it'll work on the first try, but the code is there... |
@shaunls what app is shown in your screenshot? |
@kastiglione That's MachOView https://sourceforge.net/projects/machoview/ |
When removing a load command entry, the dylib ordinal should be reduced by one for all bindings with a higher ordinal than the removed LC.
Failing to do this, the application will crash on startup as the opcodes in the dynamic loader bindings point to the incorrect dylib.
The text was updated successfully, but these errors were encountered: