[llvm] dba420b - [test][tools] Add missing and improve testing
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 04:24:47 PST 2019
Author: James Henderson
Date: 2019-12-09T12:24:23Z
New Revision: dba420bc05aec26c2b6d060cfd186169da30b5f7
URL: https://github.com/llvm/llvm-project/commit/dba420bc05aec26c2b6d060cfd186169da30b5f7
DIFF: https://github.com/llvm/llvm-project/commit/dba420bc05aec26c2b6d060cfd186169da30b5f7.diff
LOG: [test][tools] Add missing and improve testing
Mostly this adds testing for certain aliases in more explicit ways.
There are also a few tidy-ups, and additions of missing testing, where
the feature was either not tested at all, or not tested explicitly and
sufficiently.
Reviewed by: MaskRay, rupprecht, grimar
Differential Revision: https://reviews.llvm.org/D71116
Added:
llvm/test/tools/llvm-nm/elf-archive.test
llvm/test/tools/llvm-nm/elf-extern-only.test
llvm/test/tools/llvm-readobj/elf-relocations.test
Modified:
llvm/test/DebugInfo/symbolize-inlined.test
llvm/test/Object/nm-shared-object.test
llvm/test/tools/llvm-cxxfilt/simple.test
llvm/test/tools/llvm-cxxfilt/underscore.test
llvm/test/tools/llvm-nm/print-filename.test
llvm/test/tools/llvm-nm/print-size.test
llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
llvm/test/tools/llvm-objdump/all-headers.test
llvm/test/tools/llvm-readobj/elf-dynamic-tags.test
llvm/test/tools/llvm-readobj/elf-file-headers.test
llvm/test/tools/llvm-readobj/gnu-file-headers.test
llvm/test/tools/llvm-readobj/relocations.test
llvm/test/tools/llvm-symbolizer/functions.s
Removed:
################################################################################
diff --git a/llvm/test/DebugInfo/symbolize-inlined.test b/llvm/test/DebugInfo/symbolize-inlined.test
index 2757721b81f8..f3b391b14297 100644
--- a/llvm/test/DebugInfo/symbolize-inlined.test
+++ b/llvm/test/DebugInfo/symbolize-inlined.test
@@ -1,4 +1,6 @@
RUN: llvm-symbolizer --inlining --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s
+RUN: llvm-symbolizer -i --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s
+RUN: llvm-symbolizer --inlines --obj=%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc 0xa05 0x987 | FileCheck %s
CHECK: inlined_h
CHECK-NEXT: dwarfdump-inl-test.h:2
diff --git a/llvm/test/Object/nm-shared-object.test b/llvm/test/Object/nm-shared-object.test
index 6358295e654e..914c8dc23264 100644
--- a/llvm/test/Object/nm-shared-object.test
+++ b/llvm/test/Object/nm-shared-object.test
@@ -1,5 +1,7 @@
# RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-i386 \
# RUN: | FileCheck %s -check-prefix ELF-32
+# RUN: llvm-nm --dynamic %p/Inputs/shared-object-test.elf-i386 \
+# RUN: | FileCheck %s -check-prefix ELF-32
# ELF-32-NOT: U
# ELF-32: 000012c8 A __bss_start
@@ -12,6 +14,8 @@
# RUN: llvm-nm -D %p/Inputs/shared-object-test.elf-x86-64 \
# RUN: | FileCheck %s -check-prefix ELF-64
+# RUN: llvm-nm --dynamic %p/Inputs/shared-object-test.elf-x86-64 \
+# RUN: | FileCheck %s -check-prefix ELF-64
# ELF-64-NOT: U
# ELF-64: 0000000000200454 A __bss_start
diff --git a/llvm/test/tools/llvm-cxxfilt/simple.test b/llvm/test/tools/llvm-cxxfilt/simple.test
index 674f4f599b7e..90dd18d58dcb 100644
--- a/llvm/test/tools/llvm-cxxfilt/simple.test
+++ b/llvm/test/tools/llvm-cxxfilt/simple.test
@@ -1,7 +1,7 @@
-RUN: llvm-cxxfilt -n _Z1fi abc | FileCheck %s
-RUN: echo "Mangled _Z1fi and _Z3foov in string." | llvm-cxxfilt -n \
+RUN: llvm-cxxfilt _Z1fi abc | FileCheck %s
+RUN: echo "Mangled _Z1fi and _Z3foov in string." | llvm-cxxfilt \
RUN: | FileCheck %s --check-prefix=CHECK-STRING
-RUN: llvm-cxxfilt -n "CLI remains mangled _Z1fi" \
+RUN: llvm-cxxfilt "CLI remains mangled _Z1fi" \
RUN: | FileCheck %s --check-prefix=CHECK-MANGLED
CHECK: f(int)
diff --git a/llvm/test/tools/llvm-cxxfilt/underscore.test b/llvm/test/tools/llvm-cxxfilt/underscore.test
index f5b85110c62e..f84eac8087d9 100644
--- a/llvm/test/tools/llvm-cxxfilt/underscore.test
+++ b/llvm/test/tools/llvm-cxxfilt/underscore.test
@@ -1,5 +1,8 @@
RUN: llvm-cxxfilt -_ __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-STRIPPED
+RUN: llvm-cxxfilt --strip-underscore __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-STRIPPED
+RUN: llvm-cxxfilt __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED
RUN: llvm-cxxfilt -n __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED
+RUN: llvm-cxxfilt --no-strip-underscore __ZN2ns1fE _ZSt1f _f | FileCheck %s -check-prefix CHECK-UNSTRIPPED
CHECK-STRIPPED: ns::f
CHECK-STRIPPED: _ZSt1f
@@ -8,4 +11,3 @@ CHECK-STRIPPED: _f
CHECK-UNSTRIPPED: __ZN2ns1fE
CHECK-UNSTRIPPED: std::f
CHECK-UNSTRIPPED: _f
-
diff --git a/llvm/test/tools/llvm-nm/elf-archive.test b/llvm/test/tools/llvm-nm/elf-archive.test
new file mode 100644
index 000000000000..f03353f207a7
--- /dev/null
+++ b/llvm/test/tools/llvm-nm/elf-archive.test
@@ -0,0 +1,58 @@
+## Show that llvm-nm prints the symbols of all ELF members of an archive.
+
+# RUN: yaml2obj %s --docnum=1 -o %t1.o
+# RUN: yaml2obj %s --docnum=2 -o %t2.o
+
+# RUN: rm -f %t.symtab
+# RUN: llvm-ar rc %t.symtab %t1.o %t2.o
+# RUN: llvm-nm %t.symtab | FileCheck %s --match-full-lines
+
+# RUN: rm -f %t.nosymtab
+# RUN: llvm-ar rcS %t.nosymtab %t1.o %t2.o
+# RUN: llvm-nm %t.nosymtab | FileCheck %s --match-full-lines
+
+# CHECK: {{.*}}1.o:
+# CHECK-NEXT: 00000002 D global_data_symbol
+# CHECK-NEXT: 00000000 T global_function_symbol
+# CHECK-EMPTY:
+# CHECK-NEXT: {{.*}}2.o:
+# CHECK-NEXT: 00000001 D another_data_symbol
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_386
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [SHF_ALLOC, SHF_EXECINSTR]
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [SHF_ALLOC, SHF_WRITE]
+Symbols:
+ - Name: global_function_symbol
+ Value: 0x0
+ Binding: STB_GLOBAL
+ Section: .text
+ - Name: global_data_symbol
+ Binding: STB_GLOBAL
+ Section: .data
+ Value: 0x2
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_386
+Sections:
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [SHF_ALLOC, SHF_WRITE]
+Symbols:
+ - Name: another_data_symbol
+ Binding: STB_GLOBAL
+ Section: .data
+ Value: 0x1
diff --git a/llvm/test/tools/llvm-nm/elf-extern-only.test b/llvm/test/tools/llvm-nm/elf-extern-only.test
new file mode 100644
index 000000000000..d8bbd664acc7
--- /dev/null
+++ b/llvm/test/tools/llvm-nm/elf-extern-only.test
@@ -0,0 +1,49 @@
+## Test that the --extern-only switch only shows external ELF symbols.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-nm %t.o --extern-only --no-sort | FileCheck %s
+# RUN: llvm-nm %t.o -g --no-sort | FileCheck %s
+
+## Using --no-sort ensures that the symbols appear in the symbol table order
+## allowing our CHECK-NOTs to work as expected.
+# CHECK-NOT: local
+# CHECK: D global_data_symbol
+# CHECK-NEXT: T global_function_symbol
+# CHECK-NEXT: U undefined
+# CHECK-NEXT: W weak_symbol
+# CHECK-NOT: local
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_386
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [SHF_ALLOC, SHF_EXECINSTR]
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [SHF_ALLOC, SHF_WRITE]
+Symbols:
+ - Name: local_function_symbol
+ Binding: STB_LOCAL
+ Section: .text
+ - Name: local_data_symbol
+ Binding: STB_LOCAL
+ Section: .data
+ - Name: global_data_symbol
+ Binding: STB_GLOBAL
+ Section: .data
+ - Name: global_function_symbol
+ Binding: STB_GLOBAL
+ Section: .text
+ - Name: undefined
+ Binding: STB_GLOBAL
+ - Name: weak_symbol
+ Binding: STB_WEAK
+ Section: .data
+ - Name: local_at_end
+ Binding: STB_LOCAL
+ Section: .text
diff --git a/llvm/test/tools/llvm-nm/print-filename.test b/llvm/test/tools/llvm-nm/print-filename.test
index 6c47240b3d56..083045317a4e 100644
--- a/llvm/test/tools/llvm-nm/print-filename.test
+++ b/llvm/test/tools/llvm-nm/print-filename.test
@@ -1,7 +1,6 @@
-# RUN: yaml2obj %s > %t.o
-# RUN: llvm-nm --print-file-name %t.o | FileCheck %s -DFILE=%t.o
-# RUN: yaml2obj %s > %t.o
+# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm --print-file-name %t.o | FileCheck %s -DFILE=%t.o
+# RUN: llvm-nm -A %t.o | FileCheck %s -DFILE=%t.o
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-nm/print-size.test b/llvm/test/tools/llvm-nm/print-size.test
index 4614fd1177cd..52a5a1a9f5fd 100644
--- a/llvm/test/tools/llvm-nm/print-size.test
+++ b/llvm/test/tools/llvm-nm/print-size.test
@@ -1,5 +1,6 @@
-# RUN: yaml2obj %s > %t.o
+# RUN: yaml2obj %s -o %t.o
# RUN: llvm-nm --print-size %t.o | FileCheck %s --strict-whitespace
+# RUN: llvm-nm -S %t.o | FileCheck %s --strict-whitespace
!ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test b/llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
index c8a74a56c487..8a472430d3bc 100644
--- a/llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
+++ b/llvm/test/tools/llvm-objdump/X86/elf-dynamic-relocs.test
@@ -4,6 +4,7 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump --dynamic-reloc %t | FileCheck --implicit-check-not=R_X86 %s
+# RUN: llvm-objdump -R %t | FileCheck --implicit-check-not=R_X86 %s
# CHECK: file format ELF64-x86-64
# CHECK: DYNAMIC RELOCATION RECORDS
diff --git a/llvm/test/tools/llvm-objdump/all-headers.test b/llvm/test/tools/llvm-objdump/all-headers.test
index 7e57eba3b016..cf25fe6cfa56 100644
--- a/llvm/test/tools/llvm-objdump/all-headers.test
+++ b/llvm/test/tools/llvm-objdump/all-headers.test
@@ -1,5 +1,6 @@
-# RUN: yaml2obj %s > %t
+# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump --all-headers %t | FileCheck %s
+# RUN: llvm-objdump -x %t | FileCheck %s
## Note: --all-headers (-x) is an alias for --archive-headers --file-headers
## --section-headers --private-headers --reloc --syms (-afhprt). Test for them
diff --git a/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test b/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test
index dea94bee9ad1..bbf9f798cc6d 100644
--- a/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test
+++ b/llvm/test/tools/llvm-readobj/elf-dynamic-tags.test
@@ -1,7 +1,11 @@
-# Show that all non-machine specific tags can be read and printed correctly.
-# RUN: yaml2obj %s > %t
+## Show that all non-machine specific tags can be read and printed correctly.
+## Also show that -d is an alias for --dynamic-table.
+
+# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readobj -d %t | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readelf --dynamic-table %t | FileCheck %s --check-prefix=GNU
+# RUN: llvm-readelf -d %t | FileCheck %s --check-prefix=GNU
# LLVM: DynamicSection [ (61 entries)
# LLVM-NEXT: Tag Type Name/Value
diff --git a/llvm/test/tools/llvm-readobj/elf-file-headers.test b/llvm/test/tools/llvm-readobj/elf-file-headers.test
index 1cb3563a0774..d3282c804cc4 100644
--- a/llvm/test/tools/llvm-readobj/elf-file-headers.test
+++ b/llvm/test/tools/llvm-readobj/elf-file-headers.test
@@ -1,5 +1,7 @@
# RUN: yaml2obj %s --docnum=1 -o %t.i386
# RUN: llvm-readobj -h %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
+# RUN: llvm-readobj --file-header %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
+# RUN: llvm-readobj --file-headers %t.i386 | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
# I386:File: [[FILE]]
# I386-NEXT:Format: ELF32-i386
@@ -44,6 +46,10 @@ FileHeader:
# RUN: yaml2obj %s --docnum=2 -o %t.x86-64
# RUN: llvm-readobj -h %t.x86-64 \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
+# RUN: llvm-readobj --file-header %t.x86-64 \
+# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
+# RUN: llvm-readobj --file-headers %t.x86-64 \
+# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
# X86-64:File: [[FILE]]
# X86-64-NEXT:Format: ELF64-x86-64
@@ -88,6 +94,10 @@ FileHeader:
# RUN: yaml2obj %s --docnum=3 -o %t.lanai
# RUN: llvm-readobj -h %t.lanai \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI
+# RUN: llvm-readobj --file-header %t.lanai \
+# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI
+# RUN: llvm-readobj --file-headers %t.lanai \
+# RUN: | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.lanai --check-prefix LANAI
--- !ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-readobj/elf-relocations.test b/llvm/test/tools/llvm-readobj/elf-relocations.test
new file mode 100644
index 000000000000..1b02ad1725a5
--- /dev/null
+++ b/llvm/test/tools/llvm-readobj/elf-relocations.test
@@ -0,0 +1,375 @@
+## Check llvm-readobj and llvm-readelf print relocations as expected.
+
+## Show that ELF64 is dumped correctly.
+# RUN: yaml2obj %s --docnum=1 -o %t64
+# RUN: llvm-readobj -r %t64 \
+# RUN: | FileCheck %s --check-prefix=LLVM-64 --strict-whitespace --match-full-lines
+# RUN: llvm-readobj --relocs %t64 \
+# RUN: | FileCheck %s --check-prefix=LLVM-64 --strict-whitespace --match-full-lines
+# RUN: llvm-readobj --relocations %t64 \
+# RUN: | FileCheck %s --check-prefix=LLVM-64 --strict-whitespace --match-full-lines
+
+# LLVM-64:Relocations [
+# LLVM-64-NEXT: Section (2) .rel.text {
+# LLVM-64-NEXT: 0x0 R_X86_64_NONE rel_0 0x0
+# LLVM-64-NEXT: 0x1 R_X86_64_PC32 rel_neg 0x0
+# LLVM-64-NEXT: 0x5 R_X86_64_PLT32 rel_pos 0x0
+# LLVM-64-NEXT: 0x9 R_X86_64_64 rel_64 0x0
+# LLVM-64-NEXT: }
+# LLVM-64-NEXT: Section (3) .rela.text {
+# LLVM-64-NEXT: 0x0 R_X86_64_NONE rela_0 0x0
+# LLVM-64-NEXT: 0x1 R_X86_64_PC32 rela_neg 0xFFFFFFFFFFFFFFFF
+# LLVM-64-NEXT: 0x5 R_X86_64_PLT32 rela_pos 0x2
+# LLVM-64-NEXT: 0xFFFFFFFFFFFFFFFF R_X86_64_64 rela_minneg 0x8000000000000000
+# LLVM-64-NEXT: 0x9 R_X86_64_32S rela_maxpos 0x7FFFFFFFFFFFFFFF
+# LLVM-64-NEXT: }
+# LLVM-64-NEXT:]
+
+# RUN: llvm-readelf -r %t64 \
+# RUN: | FileCheck %s --check-prefix=GNU-64 --strict-whitespace --match-full-lines
+# RUN: llvm-readelf --relocs %t64 \
+# RUN: | FileCheck %s --check-prefix=GNU-64 --strict-whitespace --match-full-lines
+# RUN: llvm-readelf --relocations %t64 \
+# RUN: | FileCheck %s --check-prefix=GNU-64 --strict-whitespace --match-full-lines
+
+# GNU-64:Relocation section '.rel.text' at offset 0x51 contains 4 entries:
+# GNU-64-NEXT: Offset Info Type Symbol's Value Symbol's Name
+# GNU-64-NEXT:0000000000000000 0000000100000000 R_X86_64_NONE 0000000000000000 rel_0
+# GNU-64-NEXT:0000000000000001 0000000200000002 R_X86_64_PC32 0000000000000001 rel_neg
+# GNU-64-NEXT:0000000000000005 0000000300000004 R_X86_64_PLT32 0000000000000002 rel_pos
+# GNU-64-NEXT:0000000000000009 0000000400000001 R_X86_64_64 ffffffffffffffff rel_64
+# GNU-64-EMPTY:
+# GNU-64-NEXT:Relocation section '.rela.text' at offset 0x91 contains 5 entries:
+# GNU-64-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
+# GNU-64-NEXT:0000000000000000 0000000500000000 R_X86_64_NONE 0000000000000000 rela_0 + 0
+# GNU-64-NEXT:0000000000000001 0000000600000002 R_X86_64_PC32 0000000000000001 rela_neg - 1
+# GNU-64-NEXT:0000000000000005 0000000700000004 R_X86_64_PLT32 0000000000000002 rela_pos + 2
+# GNU-64-NEXT:ffffffffffffffff 0000000800000001 R_X86_64_64 0000000000000003 rela_minneg - 8000000000000000
+# GNU-64-NEXT:0000000000000009 000000090000000b R_X86_64_32S ffffffffffffffff rela_maxpos + 7fffffffffffffff
+
+## Show that --expand-relocs expands the relocation dump for LLVM style only
+## (and not GNU).
+# RUN: llvm-readobj -r --expand-relocs %t64 \
+# RUN: | FileCheck %s --check-prefix=LLVM-EXPAND-64 --match-full-lines --strict-whitespace
+# RUN: llvm-readelf -r --expand-relocs %t64 \
+# RUN: | FileCheck %s --check-prefix=GNU-64 --match-full-lines --strict-whitespace
+
+# LLVM-EXPAND-64:Relocations [
+# LLVM-EXPAND-64-NEXT: Section (2) .rel.text {
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x0
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_NONE (0)
+# LLVM-EXPAND-64-NEXT: Symbol: rel_0 (1)
+# LLVM-EXPAND-64-NEXT: Addend: 0x0
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x1
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_PC32 (2)
+# LLVM-EXPAND-64-NEXT: Symbol: rel_neg (2)
+# LLVM-EXPAND-64-NEXT: Addend: 0x0
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x5
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_PLT32 (4)
+# LLVM-EXPAND-64-NEXT: Symbol: rel_pos (3)
+# LLVM-EXPAND-64-NEXT: Addend: 0x0
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x9
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_64 (1)
+# LLVM-EXPAND-64-NEXT: Symbol: rel_64 (4)
+# LLVM-EXPAND-64-NEXT: Addend: 0x0
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Section (3) .rela.text {
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x0
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_NONE (0)
+# LLVM-EXPAND-64-NEXT: Symbol: rela_0 (5)
+# LLVM-EXPAND-64-NEXT: Addend: 0x0
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x1
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_PC32 (2)
+# LLVM-EXPAND-64-NEXT: Symbol: rela_neg (6)
+# LLVM-EXPAND-64-NEXT: Addend: 0xFFFFFFFFFFFFFFFF
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x5
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_PLT32 (4)
+# LLVM-EXPAND-64-NEXT: Symbol: rela_pos (7)
+# LLVM-EXPAND-64-NEXT: Addend: 0x2
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0xFFFFFFFFFFFFFFFF
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_64 (1)
+# LLVM-EXPAND-64-NEXT: Symbol: rela_minneg (8)
+# LLVM-EXPAND-64-NEXT: Addend: 0x8000000000000000
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: Relocation {
+# LLVM-EXPAND-64-NEXT: Offset: 0x9
+# LLVM-EXPAND-64-NEXT: Type: R_X86_64_32S (11)
+# LLVM-EXPAND-64-NEXT: Symbol: rela_maxpos (9)
+# LLVM-EXPAND-64-NEXT: Addend: 0x7FFFFFFFFFFFFFFF
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT: }
+# LLVM-EXPAND-64-NEXT:]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Content: '00FFFFFFFF020000001234567890ABCDEF'
+ - Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Relocations:
+ - Offset: 0x0
+ Symbol: rel_0
+ Type: R_X86_64_NONE
+ - Offset: 0x1
+ Symbol: rel_neg
+ Type: R_X86_64_PC32
+ - Offset: 0x5
+ Symbol: rel_pos
+ Type: R_X86_64_PLT32
+ - Offset: 0x9
+ Symbol: rel_64
+ Type: R_X86_64_64
+ - Name: .rela.text
+ Type: SHT_RELA
+ Info: .text
+ Relocations:
+ - Offset: 0x0
+ Symbol: rela_0
+ Type: R_X86_64_NONE
+ Addend: 0
+ - Offset: 0x1
+ Symbol: rela_neg
+ Type: R_X86_64_PC32
+ Addend: -1
+ - Offset: 0x5
+ Symbol: rela_pos
+ Type: R_X86_64_PLT32
+ Addend: 2
+ - Offset: 0xFFFFFFFFFFFFFFFF
+ Symbol: rela_minneg
+ Type: R_X86_64_64
+ Addend: -9223372036854775808 ## Min 64-bit signed.
+ - Offset: 0x9
+ Symbol: rela_maxpos
+ Type: R_X86_64_32S
+ Addend: 9223372036854775807 ## Max 64-bit signed.
+Symbols:
+ - Name: rel_0
+ Section: .text
+ Value: 0
+ - Name: rel_neg
+ Section: .text
+ Value: 1
+ - Name: rel_pos
+ Section: .text
+ Value: 2
+ - Name: rel_64
+ Section: .text
+ Value: 0xFFFFFFFFFFFFFFFF
+ - Name: rela_0
+ Section: .text
+ Value: 0
+ - Name: rela_neg
+ Section: .text
+ Value: 1
+ - Name: rela_pos
+ Section: .text
+ Value: 2
+ - Name: rela_minneg
+ Section: .text
+ Value: 3
+ - Name: rela_maxpos
+ Section: .text
+ Value: 0xFFFFFFFFFFFFFFFF
+
+## Show that ELF32 is dumped correctly.
+# RUN: yaml2obj %s --docnum=2 -o %t32
+# RUN: llvm-readobj -r %t32 \
+# RUN: | FileCheck %s --check-prefix=LLVM-32 --strict-whitespace --match-full-lines
+# RUN: llvm-readobj --relocs %t32 \
+# RUN: | FileCheck %s --check-prefix=LLVM-32 --strict-whitespace --match-full-lines
+# RUN: llvm-readobj --relocations %t32 \
+# RUN: | FileCheck %s --check-prefix=LLVM-32 --strict-whitespace --match-full-lines
+
+# LLVM-32:Relocations [
+# LLVM-32-NEXT: Section (2) .rel.text {
+# LLVM-32-NEXT: 0x0 R_386_NONE rel_0 0x0
+# LLVM-32-NEXT: 0x1 R_386_PC32 rel_neg 0x0
+# LLVM-32-NEXT: 0x5 R_386_PLT32 rel_pos 0x0
+# LLVM-32-NEXT: }
+# LLVM-32-NEXT: Section (3) .rela.text {
+# LLVM-32-NEXT: 0x0 R_386_NONE rela_0 0x0
+# LLVM-32-NEXT: 0x1 R_386_PC32 rela_neg 0xFFFFFFFF
+# LLVM-32-NEXT: 0x5 R_386_PLT32 rela_pos 0x2
+# LLVM-32-NEXT: 0xFFFFFFFF R_386_32 rela_minneg 0x80000000
+# LLVM-32-NEXT: 0x9 R_386_GOT32 rela_maxpos 0x7FFFFFFF
+# LLVM-32-NEXT: }
+# LLVM-32-NEXT:]
+
+# RUN: llvm-readelf -r %t32 \
+# RUN: | FileCheck %s --check-prefix=GNU-32 --strict-whitespace --match-full-lines
+# RUN: llvm-readelf --relocs %t32 \
+# RUN: | FileCheck %s --check-prefix=GNU-32 --strict-whitespace --match-full-lines
+# RUN: llvm-readelf --relocations %t32 \
+# RUN: | FileCheck %s --check-prefix=GNU-32 --strict-whitespace --match-full-lines
+
+# GNU-32:Relocation section '.rel.text' at offset 0x3d contains 3 entries:
+# GNU-32-NEXT: Offset Info Type Sym. Value Symbol's Name
+# GNU-32-NEXT:00000000 00000100 R_386_NONE 00000000 rel_0
+# GNU-32-NEXT:00000001 00000202 R_386_PC32 00000001 rel_neg
+# GNU-32-NEXT:00000005 00000304 R_386_PLT32 ffffffff rel_pos
+# GNU-32-EMPTY:
+# GNU-32-NEXT:Relocation section '.rela.text' at offset 0x55 contains 5 entries:
+# GNU-32-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
+# GNU-32-NEXT:00000000 00000400 R_386_NONE 00000000 rela_0 + 0
+# GNU-32-NEXT:00000001 00000502 R_386_PC32 00000001 rela_neg - 1
+# GNU-32-NEXT:00000005 00000604 R_386_PLT32 00000002 rela_pos + 2
+# GNU-32-NEXT:ffffffff 00000701 R_386_32 00000003 rela_minneg - 80000000
+# GNU-32-NEXT:00000009 00000803 R_386_GOT32 ffffffff rela_maxpos + 7fffffff
+
+## Show that --expand-relocs expands the relocation dump for LLVM style only
+## (and not GNU).
+# RUN: llvm-readobj -r --expand-relocs %t32 \
+# RUN: | FileCheck %s --check-prefix=LLVM-EXPAND-32 --strict-whitespace --match-full-lines
+# RUN: llvm-readelf -r --expand-relocs %t32 \
+# RUN: | FileCheck %s --check-prefix=GNU-32 --strict-whitespace --match-full-lines
+
+# LLVM-EXPAND-32:Relocations [
+# LLVM-EXPAND-32-NEXT: Section (2) .rel.text {
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x0
+# LLVM-EXPAND-32-NEXT: Type: R_386_NONE (0)
+# LLVM-EXPAND-32-NEXT: Symbol: rel_0 (1)
+# LLVM-EXPAND-32-NEXT: Addend: 0x0
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x1
+# LLVM-EXPAND-32-NEXT: Type: R_386_PC32 (2)
+# LLVM-EXPAND-32-NEXT: Symbol: rel_neg (2)
+# LLVM-EXPAND-32-NEXT: Addend: 0x0
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x5
+# LLVM-EXPAND-32-NEXT: Type: R_386_PLT32 (4)
+# LLVM-EXPAND-32-NEXT: Symbol: rel_pos (3)
+# LLVM-EXPAND-32-NEXT: Addend: 0x0
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Section (3) .rela.text {
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x0
+# LLVM-EXPAND-32-NEXT: Type: R_386_NONE (0)
+# LLVM-EXPAND-32-NEXT: Symbol: rela_0 (4)
+# LLVM-EXPAND-32-NEXT: Addend: 0x0
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x1
+# LLVM-EXPAND-32-NEXT: Type: R_386_PC32 (2)
+# LLVM-EXPAND-32-NEXT: Symbol: rela_neg (5)
+# LLVM-EXPAND-32-NEXT: Addend: 0xFFFFFFFF
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x5
+# LLVM-EXPAND-32-NEXT: Type: R_386_PLT32 (4)
+# LLVM-EXPAND-32-NEXT: Symbol: rela_pos (6)
+# LLVM-EXPAND-32-NEXT: Addend: 0x2
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0xFFFFFFFF
+# LLVM-EXPAND-32-NEXT: Type: R_386_32 (1)
+# LLVM-EXPAND-32-NEXT: Symbol: rela_minneg (7)
+# LLVM-EXPAND-32-NEXT: Addend: 0x80000000
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: Relocation {
+# LLVM-EXPAND-32-NEXT: Offset: 0x9
+# LLVM-EXPAND-32-NEXT: Type: R_386_GOT32 (3)
+# LLVM-EXPAND-32-NEXT: Symbol: rela_maxpos (8)
+# LLVM-EXPAND-32-NEXT: Addend: 0x7FFFFFFF
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT: }
+# LLVM-EXPAND-32-NEXT:]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_386
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Content: '00FFFFFFFF02000000'
+ - Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Relocations:
+ - Offset: 0x0
+ Symbol: rel_0
+ Type: R_386_NONE
+ - Offset: 0x1
+ Symbol: rel_neg
+ Type: R_386_PC32
+ - Offset: 0x5
+ Symbol: rel_pos
+ Type: R_386_PLT32
+ - Name: .rela.text
+ Type: SHT_RELA
+ Info: .text
+ Relocations:
+ - Offset: 0x0
+ Symbol: rela_0
+ Type: R_386_NONE
+ Addend: 0
+ - Offset: 0x1
+ Symbol: rela_neg
+ Type: R_386_PC32
+ Addend: -1
+ - Offset: 0x5
+ Symbol: rela_pos
+ Type: R_386_PLT32
+ Addend: 2
+ - Offset: 0xFFFFFFFF
+ Symbol: rela_minneg
+ Type: R_386_32
+ Addend: -2147483648 ## Min 32-bit signed.
+ - Offset: 0x9
+ Symbol: rela_maxpos
+ Type: R_386_GOT32
+ Addend: 2147483647 ## Max 32-bit signed.
+Symbols:
+ - Name: rel_0
+ Section: .text
+ Value: 0
+ - Name: rel_neg
+ Section: .text
+ Value: 1
+ - Name: rel_pos
+ Section: .text
+ Value: 0xFFFFFFFF
+ - Name: rela_0
+ Section: .text
+ Value: 0
+ - Name: rela_neg
+ Section: .text
+ Value: 1
+ - Name: rela_pos
+ Section: .text
+ Value: 2
+ - Name: rela_minneg
+ Section: .text
+ Value: 3
+ - Name: rela_maxpos
+ Section: .text
+ Value: 0xFFFFFFFF
diff --git a/llvm/test/tools/llvm-readobj/gnu-file-headers.test b/llvm/test/tools/llvm-readobj/gnu-file-headers.test
index c6060ca1beb7..c6287450989e 100644
--- a/llvm/test/tools/llvm-readobj/gnu-file-headers.test
+++ b/llvm/test/tools/llvm-readobj/gnu-file-headers.test
@@ -1,9 +1,21 @@
RUN: llvm-readelf -h %p/Inputs/trivial.obj.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF32
+RUN: llvm-readelf --file-header %p/Inputs/trivial.obj.elf-i386 \
+RUN: | FileCheck %s -check-prefix ELF32
+RUN: llvm-readelf --file-headers %p/Inputs/trivial.obj.elf-i386 \
+RUN: | FileCheck %s -check-prefix ELF32
RUN: llvm-readelf -h %p/Inputs/trivial.obj.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF64
+RUN: llvm-readelf --file-header %p/Inputs/trivial.obj.elf-x86-64 \
+RUN: | FileCheck %s -check-prefix ELF64
+RUN: llvm-readelf --file-headers %p/Inputs/trivial.obj.elf-x86-64 \
+RUN: | FileCheck %s -check-prefix ELF64
RUN: llvm-readelf -h %p/Inputs/trivial.obj.elf-mipsel \
RUN: | FileCheck %s -check-prefix MIPSEL
+RUN: llvm-readelf --file-header %p/Inputs/trivial.obj.elf-mipsel \
+RUN: | FileCheck %s -check-prefix MIPSEL
+RUN: llvm-readelf --file-headers %p/Inputs/trivial.obj.elf-mipsel \
+RUN: | FileCheck %s -check-prefix MIPSEL
ELF32: ELF Header:
ELF32-NEXT: Magic: 7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
diff --git a/llvm/test/tools/llvm-readobj/relocations.test b/llvm/test/tools/llvm-readobj/relocations.test
index a459981edf18..535170342989 100644
--- a/llvm/test/tools/llvm-readobj/relocations.test
+++ b/llvm/test/tools/llvm-readobj/relocations.test
@@ -4,8 +4,6 @@ RUN: llvm-readobj -r %p/Inputs/bad-relocs.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix BAD-COFF-RELOCS
RUN: llvm-readobj -r %p/Inputs/relocs-no-symtab.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix BAD-COFF-RELOCS
-RUN: llvm-readobj -r %p/Inputs/trivial.obj.elf-i386 \
-RUN: | FileCheck %s -check-prefix ELF
RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-i386 \
RUN: | FileCheck %s -check-prefix MACHO-I386
RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-x86-64 \
@@ -33,15 +31,6 @@ BAD-COFF-RELOCS-NEXT: 0xDEADBEEF IMAGE_REL_I386_ABSOLUTE -
BAD-COFF-RELOCS-NEXT: }
BAD-COFF-RELOCS-NEXT: ]
-ELF: Relocations [
-ELF-NEXT: Section (2) .rel.text {
-ELF-NEXT: 0xC R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
-ELF-NEXT: 0x12 R_386_GOTOFF .L.str 0x0
-ELF-NEXT: 0x1A R_386_PLT32 puts 0x0
-ELF-NEXT: 0x1F R_386_PLT32 SomeOtherFunction 0x0
-ELF-NEXT: }
-ELF-NEXT: ]
-
MACHO-I386: Relocations [
MACHO-I386-NEXT: Section __text {
MACHO-I386-NEXT: 0x18 1 2 1 GENERIC_RELOC_VANILLA 0 _SomeOtherFunction
diff --git a/llvm/test/tools/llvm-symbolizer/functions.s b/llvm/test/tools/llvm-symbolizer/functions.s
index 93cca51a0c17..3093d801d395 100644
--- a/llvm/test/tools/llvm-symbolizer/functions.s
+++ b/llvm/test/tools/llvm-symbolizer/functions.s
@@ -3,13 +3,18 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: llvm-symbolizer 0 --obj=%t.o | FileCheck %s --check-prefix=LINKAGE
+# RUN: llvm-symbolizer 0 -f --obj=%t.o | FileCheck %s --check-prefix=LINKAGE
# RUN: llvm-symbolizer 0 --functions --obj=%t.o | FileCheck %s --check-prefix=LINKAGE
+# RUN: llvm-symbolizer 0 -f=linkage --obj=%t.o | FileCheck %s --check-prefix=LINKAGE
# RUN: llvm-symbolizer 0 --functions=linkage --obj=%t.o | FileCheck %s --check-prefix=LINKAGE
+# RUN: llvm-symbolizer 0 -f=short --obj=%t.o | FileCheck %s --check-prefix=SHORT
# RUN: llvm-symbolizer 0 --functions=short --obj=%t.o | FileCheck %s --check-prefix=SHORT
+# RUN: llvm-symbolizer 0 -f=none --obj=%t.o | FileCheck %s --check-prefix=NONE
# RUN: llvm-symbolizer 0 --functions=none --obj=%t.o | FileCheck %s --check-prefix=NONE
## Characterise behaviour for no '=' sign. llvm-symbolizer treats the next option as an
## input address, and just prints it.
+# RUN: llvm-symbolizer 0 -f none --obj=%t.o | FileCheck %s --check-prefixes=LINKAGE,ERR
# RUN: llvm-symbolizer 0 --functions none --obj=%t.o | FileCheck %s --check-prefixes=LINKAGE,ERR
# LINKAGE: {{^}}foo(int){{$}}
More information about the llvm-commits
mailing list