-
-
Notifications
You must be signed in to change notification settings - Fork 36
(Correct) RPath support. #35
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
Conversation
I happen to know the reason (and why it's only affecting 64-bit architectures), but I'm not sure if you would prefer to find out yourself, just a small hint, or the full explanation. Let me know! I guess I'm not disclosing too much if I'm seeing a major refactoring of |
I haven't quite figured it out yet (although I know it's related to my padding/cmdsize logic). Don't tell me quite yet 😄 |
If you're able to say this much, you're obviously very close to understanding the root cause. |
I'm surprised I hadn't caught this behavior until now - that's a sizeable bug 😅 |
f341ea1
to
5b1c019
Compare
lib/macho/macho_file.rb
Outdated
end | ||
|
||
# Changes the runtime path `old_path` to `new_path` | ||
# Changes the relative path `old_path` to `new_path` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “R” definitely doesn't stand for “relative”. dyld(1)
talks about a “run path list” that is populated from the various LC_RPATH
load commands, thus I'd make this “run path” or leave it as “runtime path”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected 👍
You found it! 👍 It had to do with the requirement that every load command as a whole needs to have a size that is a multiple of either 4 or 8 bytes, depending on the architecture, and not just the I think this is fine as a temporary workaround, but looking more closely at the code after you found this issue made me realize that the
I believe most of these issues can be avoided if this code is radically simplified. And I think the easiest way to achieve this is to expand on your idea in #36, such that setting a path in an existing load command would effectively boil down to:
|
Yep, all of these cases are missed by
This approach sounds very reasonable to me, and would be a significant step towards making In the mean time, I'll merge this (temporary) fix once you're satisfied with it. |
Feel free to merge, ideally with a (And don't get me wrong, it's easy to point out flaws when you haven't written the code yourself and at least you were bold enough to write that code while all my Mach-O related code to date was read-only in fear of not understanding enough and thus breaking stuff. 😀 Absolutely appreciate your work!) |
Will do!
Thanks, I appreciate it. Don't worry about being critical about my code, that's the only way it'll get better 😄 |
Fixes a long-standing bug in null-pad calculation that caused rpaths modifications to be misaligned (but only on 64-bit systems). Additionally, add FatFile#rpaths and FatFile#change_rpath.
Looks good to me!
Awesome! |
At the moment,
rpath
modification fails on x86_64 binaries.I'll be looking into why that is, and this PR will serve as the location for that research (and eventual fix).