-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-objcopy] Add --remove-symbol-prefix #79415
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c176f9b
Add functionality to llvm-objcopy to remove prefixes
kongy ec9d7dd
Address review comments
kongy 8566506
Add entry in llvm-objcopy.rst
kongy 3350886
Update llvm/docs/CommandGuide/llvm-objcopy.rst
kongy 1e17cb9
Fix comment
kongy 914280f
Update llvm/test/tools/llvm-objcopy/ELF/prefix-symbols-remove.test
kongy 52b1621
Update test to check for exact number of symbols
kongy 6cb17d3
Rewrite test that shows operation order
kongy 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
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
65 changes: 65 additions & 0 deletions
65
llvm/test/tools/llvm-objcopy/ELF/prefix-symbols-remove.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,65 @@ | ||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy --remove-symbol-prefix __pf_ %t %t2 | ||
# RUN: llvm-readelf --symbols %t2 | FileCheck %s | ||
|
||
## Show that an empty string is permitted as the argument to | ||
## --remove-symbol-prefix. | ||
# RUN: llvm-objcopy --remove-symbol-prefix= %t2 %t3 | ||
# RUN: cmp %t2 %t3 | ||
|
||
## When both options are present, llvm-objcopy should remove | ||
## prefixes first, before adding prefixes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you forget There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
# RUN: llvm-objcopy --prefix-symbols=__1_ %t %t4 | ||
# RUN: llvm-objcopy --prefix-symbols=__2_ %t %t5 | ||
# RUN: llvm-objcopy --remove-symbol-prefix=__1_ --prefix-symbols=__2_ %t4 %t6 | ||
# RUN: cmp %t5 %t6 | ||
|
||
## Show that the last --remove-symbol-prefix option wins. | ||
# RUN: llvm-objcopy --remove-symbol-prefix=__pf_ --remove-symbol-prefix=__ %t %7 | ||
# RUN: llvm-objcopy --remove-symbol-prefix=__ %t %8 | ||
# RUN: cmp %7 %8 | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] | ||
Address: 0x1000 | ||
AddressAlign: 0x0000000000000010 | ||
Size: 64 | ||
Symbols: | ||
- Name: __pf_foo | ||
Type: STT_SECTION | ||
Section: .text | ||
- Name: __pf_bar | ||
Type: STT_FILE | ||
Section: .text | ||
- Name: foobar | ||
Type: STT_FUNC | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
- Name: foo__pf_bar1 | ||
Type: STT_FUNC | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
- Name: __pf_foo__pf_bar2 | ||
Type: STT_FUNC | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
- Name: undef | ||
Binding: STB_GLOBAL | ||
|
||
# CHECK: Symbol table '.symtab' contains 7 entries: | ||
# CHECK-NEXT: Name | ||
# CHECK-NEXT: {{ $}} | ||
# CHECK-NEXT: __pf_foo | ||
# CHECK-NEXT: bar | ||
# CHECK-NEXT: foobar | ||
# CHECK-NEXT: foo__pf_bar1 | ||
# CHECK-NEXT: foo__pf_bar2 | ||
# CHECK-NEXT: undef |
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
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.