-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-objcopy] Add --skip-symbol and --skip-symbols options #80873
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
20 commits
Select commit
Hold shift + click to select a range
da84199
Add llvm-objcopy option --ignore-symbol
kuilpd a7b0edb
Adjust and expand ignore-symbols.test
kuilpd 85f031e
Update the llvm-objcopy documentation
kuilpd e9b8a8b
Add a test for checking various error cases
kuilpd 6491013
Adjust formatting and wording in tests
kuilpd 55af35c
Use %errc_ENOENT for 'No such file or directory' message
kuilpd e25e5f2
Use a wildcard instead of a regex in one of the test cases
kuilpd 151029c
Adjust test formatting
kuilpd 7f65088
Rename the options to --skip-symbols(s)
kuilpd 55d3fd8
Merge tests into one file
kuilpd 4006d11
Added the options to release notes
kuilpd 10f6e33
Address nits
kuilpd da81eb3
Move the option to common config and add checks in config manager
kuilpd 6dd0135
Add a test to check both multiple uses and order with --set-symbol-vi…
kuilpd a808003
Rename skip-symbols.test
kuilpd a470b13
Adjust description and formatting
kuilpd 251e820
Adjust the test to use multiple options and expand others to use more…
kuilpd 5d48d70
Adjust the doc description, make it similar to --keep-symbols
kuilpd f997fd9
Change test order
kuilpd 4163575
Move creation of %t.renames.list earlier
kuilpd 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
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,100 @@ | ||
## This test checks the functionality of options --skip-symbol and --skip-symbols. | ||
# RUN: yaml2obj %s -o %t.o | ||
# RUN: echo 'foo[2-3]' > %t.skip.regex | ||
|
||
## Check --skip-symbol functionality when changing symbol bindings. | ||
# RUN: llvm-objcopy %t.o %t2.o --localize-hidden --skip-symbol=foo3 | ||
# RUN: llvm-readelf -s %t2.o | FileCheck %s --check-prefix=LH-SYM | ||
# LH-SYM-DAG: LOCAL HIDDEN 1 foo1 | ||
# LH-SYM-DAG: LOCAL HIDDEN 1 foo2 | ||
# LH-SYM-DAG: GLOBAL HIDDEN 1 foo3 | ||
# LH-SYM-DAG: LOCAL HIDDEN 1 foo4 | ||
# LH-SYM-DAG: LOCAL HIDDEN 1 foo5 | ||
|
||
## Check --skip-symbols functionality when changing symbol bindings. | ||
# RUN: llvm-objcopy %t.o %t1.o --localize-hidden --skip-symbols=%t.skip.regex --regex | ||
# RUN: llvm-readelf -s %t1.o | FileCheck %s --check-prefix=LH-SYMS | ||
# LH-SYMS-DAG: LOCAL HIDDEN 1 foo1 | ||
# LH-SYMS-DAG: GLOBAL HIDDEN 1 foo2 | ||
# LH-SYMS-DAG: GLOBAL HIDDEN 1 foo3 | ||
# LH-SYMS-DAG: LOCAL HIDDEN 1 foo4 | ||
# LH-SYMS-DAG: LOCAL HIDDEN 1 foo5 | ||
|
||
## Check --skip-symbol functionality when changing symbol names. | ||
# RUN: echo -e "foo1 bar1\nfoo2 bar2" > %t.renames.list | ||
# RUN: llvm-objcopy %t.o %t4.o --redefine-syms=%t.renames.list \ | ||
# RUN: --skip-symbol='fo*' --wildcard | ||
# RUN: llvm-readelf -s %t4.o | FileCheck %s --check-prefix=RS-SYM | ||
# RS-SYM-DAG: foo1 | ||
# RS-SYM-DAG: foo2 | ||
# RS-SYM-DAG: foo3 | ||
# RS-SYM-DAG: foo4 | ||
# RS-SYM-DAG: foo5 | ||
|
||
## Check --skip-symbols functionality when changing symbol names. | ||
# RUN: llvm-objcopy %t.o %t3.o --redefine-syms=%t.renames.list \ | ||
# RUN: --skip-symbols=%t.skip.regex --regex | ||
# RUN: llvm-readelf -s %t3.o | FileCheck %s --check-prefix=RS-SYMS | ||
# RS-SYMS-DAG: bar1 | ||
# RS-SYMS-DAG: foo2 | ||
# RS-SYMS-DAG: foo3 | ||
# RS-SYMS-DAG: foo4 | ||
# RS-SYMS-DAG: foo5 | ||
|
||
## Check the functionality when using skip options multiple times. | ||
# RUN: echo "foo3" > %t.symbol0.list | ||
# RUN: echo "foo4" > %t.symbol1.list | ||
# RUN: llvm-objcopy %t.o %t5.o --set-symbol-visibility='foo*'=internal --wildcard \ | ||
# RUN: --skip-symbol=foo1 --skip-symbol=foo2 \ | ||
# RUN: --skip-symbols=%t.symbol0.list --skip-symbols=%t.symbol1.list | ||
# RUN: llvm-readelf -s %t5.o | FileCheck %s --check-prefix=BOTH | ||
# BOTH-DAG: GLOBAL HIDDEN 1 foo1 | ||
# BOTH-DAG: GLOBAL HIDDEN 1 foo2 | ||
# BOTH-DAG: GLOBAL HIDDEN 1 foo3 | ||
# BOTH-DAG: GLOBAL HIDDEN 1 foo4 | ||
## Only foo5 is not skipped. | ||
# BOTH-DAG: GLOBAL INTERNAL 1 foo5 | ||
|
||
## Check that using an invalid symbol name regex generates an error. | ||
# RUN: echo '*.' > %t.symbols.regex | ||
# RUN: not llvm-objcopy %t.o --skip-symbols=%t.symbols.regex --regex 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=SYMBOL | ||
# RUN: not llvm-objcopy %t.o --skip-symbol='*.' --regex 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=SYMBOL | ||
# SYMBOL: error: cannot compile regular expression '*.': repetition-operator operand invalid | ||
|
||
## Check passing an invalid filename generates an error. | ||
# RUN: not llvm-objcopy %t.o --skip-symbols=no_file 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=FILE -DMSG=%errc_ENOENT | ||
# FILE: error: 'no_file': [[MSG]] | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Symbols: | ||
- Name: foo1 | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Other: [ STV_HIDDEN ] | ||
- Name: foo2 | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Other: [ STV_HIDDEN ] | ||
- Name: foo3 | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Other: [ STV_HIDDEN ] | ||
- Name: foo4 | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Other: [ STV_HIDDEN ] | ||
- Name: foo5 | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Other: [ STV_HIDDEN ] |
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.
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.
Should this mention that this does not prevent removing symbols?
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.
I don't think it needs to: it explicitly states the things that it impacts (name/binding/visibility). It's probably harmless to add it though.