-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
MachO segments can have zero filesize, matching offset to other segments #1130
Comments
I think it's a duplicate of #1087. Could you test with a nightly build? |
I suspect that the fix is not enough, because there are other locations where offset_seg_ is updated, e.g.:
|
But I hit some issues further even with this and suspect that there is some other location where problems arise. |
Results: |
I think you already had a nightly version and your $ pip install --ignore-installed --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==0.16.0.dev0 On my end, the binary seems correctly shifted: 2c2
< a.out: file format mach-o arm64
---
> new.out: file format mach-o arm64
6,8c6,8
< 0 __text 00000008 0000000100003fa0 TEXT
< 1 __unwind_info 00000058 0000000100003fa8 DATA
< 2 __common 00000190 0000000100004000 BSS
---
> 0 __text 00000008 0000000100004388 TEXT
> 1 __unwind_info 00000058 0000000100004390 DATA
> 2 __common 00000190 00000001000043e8 BSS |
I think the objdump printout is not sufficient for seeing the problem; it becomes sufficient if delta is larger though:
|
You are right. Checking for a fix! |
No need to update add_cached_segment and this?:
Both would cause trouble when file_offset=0 |
You are right! Thank you! |
Actually my fix is not correct. |
Describe the bug
Offset of segment is used as unique identifier, for example in: offset_seg_ map.
This is incorrect as they can match in cases when offset filesize is 0.
To Reproduce
Steps to reproduce the behavior:
a.cpp:
__common is in __DATA, __unwind_info is in __TEXT. __DATA has nothing inside, as it is all zeroes/uninitialized.
Issue: if we try to shift the binary, TEXT segment is not found.
Expected behavior
should not use offset as identifier; should be able to shift __text section of such a binary.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
NOTICE
If the issue does not contain enough information to be reproduced,
it will be flagged as incomplete
and closed.
/NOTICE
The text was updated successfully, but these errors were encountered: