-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[llvm-objcopy] MachO: Fix section finding policy for object files #127604
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
Merged
alexander-shaposhnikov
merged 6 commits into
llvm:main
from
Nechda:macho-objcopy-find-section
Feb 23, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71619b8
llvm-objcopy MachO: scan each section when --update-section option is…
Nechda 118cbfd
Add test
Nechda 2712aed
Add err-msg & ref to doc
Nechda d3bd8d8
Test err msg
Nechda 977c430
Add release notes
Nechda f1ed5fc
Simplify test
Nechda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.section __TEXT,__text | ||
.space 64 | ||
.section __DATA,__storage | ||
.space 128 |
47 changes: 47 additions & 0 deletions
47
llvm/test/tools/llvm-objcopy/MachO/update-section-object.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# REQUIRES: aarch64-registered-target | ||
|
||
# RUN: llvm-mc -assemble -triple=arm64-apple-macos11 -filetype=obj %p/Inputs/macho_sections.s -o %t.o | ||
# RUN: llvm-otool -l %t.o | FileCheck %s --check-prefix=ORIG | ||
|
||
|
||
# RUN: llvm-objcopy %t.o --update-section __DATA,__storage=%p/Inputs/macho_sections.s %t.new.o | ||
# RUN: llvm-otool -l %t.new.o | FileCheck %s --check-prefix=UPDATED | ||
|
||
# ORIG: cmd LC_SEGMENT_64 | ||
# ORIG-NEXT: cmdsize 232 | ||
# ORIG-NEXT: segname | ||
# ORIG-NEXT: vmaddr 0x0000000000000000 | ||
# ORIG-NEXT: vmsize 0x00000000000000c0 | ||
# ORIG-NEXT: fileoff 392 | ||
# ORIG-NEXT: filesize 192 | ||
# ORIG-NEXT: maxprot 0x00000007 | ||
# ORIG-NEXT: initprot 0x00000007 | ||
# ORIG-NEXT: nsects 2 | ||
# ORIG-NEXT: flags 0x0 | ||
|
||
# ORIG: Section | ||
# ORIG: sectname __storage | ||
# ORIG-NEXT: segname __DATA | ||
# ORIG-NEXT: addr 0x0000000000000040 | ||
# ORIG-NEXT: size 0x0000000000000080 | ||
|
||
|
||
### Make sure the file size and segment size have changed | ||
# UPDATED: cmd LC_SEGMENT_64 | ||
# UPDATED-NEXT: cmdsize 232 | ||
# UPDATED-NEXT: segname | ||
# UPDATED-NEXT: vmaddr 0x0000000000000000 | ||
# UPDATED-NEXT: vmsize 0x0000000000000090 | ||
# UPDATED-NEXT: fileoff 392 | ||
# UPDATED-NEXT: filesize 144 | ||
# UPDATED-NEXT: maxprot 0x00000007 | ||
# UPDATED-NEXT: initprot 0x00000007 | ||
# UPDATED-NEXT: nsects 2 | ||
# UPDATED-NEXT: flags 0x0 | ||
|
||
# UPDATED: Section | ||
# UPDATED: sectname __storage | ||
# UPDATED-NEXT: segname __DATA | ||
# UPDATED-NEXT: addr 0x0000000000000040 | ||
# UPDATED-NEXT: size 0x0000000000000050 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.