Skip to content

[llvm-objcopy][test] Use llvm-readelf instead for clearer visualization #79874

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 3 commits into from
Feb 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 10 additions & 50 deletions llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy --prefix-symbols prefix %t %t2
# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefixes=COMMON,BASIC
# RUN: llvm-readelf --symbols %t2 | FileCheck %s --check-prefixes=COMMON,BASIC
# RUN: llvm-objcopy --redefine-sym bar=baz --prefix-symbols prefix %t %t3
# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefixes=COMMON,REDEF
# RUN: llvm-readelf --symbols %t3 | FileCheck %s --check-prefixes=COMMON,REDEF

## Show that an empty string is permitted as the argument to
## --prefix-symbols.
Expand Down Expand Up @@ -40,51 +40,11 @@ Symbols:
- Name: undef
Binding: STB_GLOBAL

# COMMON: Symbols [
# COMMON-NEXT: Symbol {
# COMMON-NEXT: Name:
# COMMON-NEXT: Value: 0x0
# COMMON-NEXT: Size: 0
# COMMON-NEXT: Binding: Local
# COMMON-NEXT: Type: None
# COMMON-NEXT: Other: 0
# COMMON-NEXT: Section: Undefined
# COMMON-NEXT: }
# COMMON-NEXT: Symbol {
# COMMON-NEXT: Name: foo
# COMMON-NEXT: Value: 0x0
# COMMON-NEXT: Size: 0
# COMMON-NEXT: Binding: Local
# COMMON-NEXT: Type: Section
# COMMON-NEXT: Other: 0
# COMMON-NEXT: Section: .text
# COMMON-NEXT: }
# COMMON-NEXT: Symbol {
# BASIC-NEXT: Name: prefixbar
# REDEF-NEXT: Name: prefixbaz
# COMMON-NEXT: Value: 0x0
# COMMON-NEXT: Size: 0
# COMMON-NEXT: Binding: Local
# COMMON-NEXT: Type: File
# COMMON-NEXT: Other: 0
# COMMON-NEXT: Section: .text
# COMMON-NEXT: }
# COMMON-NEXT: Symbol {
# COMMON-NEXT: Name: prefixfoobar
# COMMON-NEXT: Value: 0x0
# COMMON-NEXT: Size: 0
# COMMON-NEXT: Binding: Global
# COMMON-NEXT: Type: Function
# COMMON-NEXT: Other: 0
# COMMON-NEXT: Section: .text
# COMMON-NEXT: }
# COMMON-NEXT: Symbol {
# COMMON-NEXT: Name: prefixundef
# COMMON-NEXT: Value: 0x0
# COMMON-NEXT: Size: 0
# COMMON-NEXT: Binding: Global
# COMMON-NEXT: Type: None
# COMMON-NEXT: Other: 0
# COMMON-NEXT: Section: Undefined
# COMMON-NEXT: }
# COMMON-NEXT:]
#COMMON: Symbol table '.symtab' contains 5 entries:
#COMMON-NEXT: Num: Value Size Type Bind Vis Ndx Name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is usually a space after #

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#COMMON-NEXT: 0: {{.*}} 0 NOTYPE LOCAL {{.*}}
#COMMON-NEXT: 1: {{.*}} 0 SECTION LOCAL {{.*}} foo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For defined non-ABS symbols, [[#]] (which matches a decimal) is slightly better than {{.*}}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#BASIC-NEXT: 2: {{.*}} 0 FILE LOCAL {{.*}} prefixbar
#REDEF-NEXT: 2: {{.*}} 0 FILE LOCAL {{.*}} prefixbaz
#COMMON-NEXT: 3: {{.*}} 0 FUNC GLOBAL {{.*}} prefixfoobar
#COMMON-NEXT: 4: {{.*}} 0 NOTYPE GLOBAL {{.*}} prefixundef