Index: llvm/test/tools/llvm-readobj/ELF/gnu-symbols.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/gnu-symbols.test +++ /dev/null @@ -1,57 +0,0 @@ -RUN: llvm-readelf --symbols %p/Inputs/symbols-proc-specific.elf-hexagon \ -RUN: | FileCheck %s --check-prefix ELF32 -RUN: llvm-readelf --symbols %p/Inputs/relocs.obj.elf-x86_64 \ -RUN: | FileCheck %s --check-prefix ELF64 -RUN: llvm-readelf --symbols %p/Inputs/gnuhash.so.elf-x86_64 \ -RUN: | FileCheck %s --check-prefixes=SYMTAB,DYN -RUN: llvm-readelf --dyn-symbols %p/Inputs/gnuhash.so.elf-x86_64 \ -RUN: | FileCheck %s --check-prefixes=NO-SYMTAB,DYN -RUN: llvm-readelf --symbols --dyn-symbols %p/Inputs/gnuhash.so.elf-x86_64 \ -RUN: | FileCheck %s --check-prefixes=SYMTAB,DYN - -ELF32: Symbol table '.symtab' contains 5 entries: -ELF32-NEXT: Num: Value Size Type Bind Vis Ndx Name -ELF32-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND -ELF32-NEXT: 1: 00000000 0 FILE LOCAL DEFAULT ABS a.c -ELF32-NEXT: 2: 00000000 20 FUNC GLOBAL DEFAULT 2 main -ELF32-NEXT: 3: 00000004 4 OBJECT GLOBAL DEFAULT PRC[0xff03] x -ELF32-NEXT: 4: 00000000 4 OBJECT GLOBAL DEFAULT 3 y - -ELF64: Symbol table '.symtab' contains 6 entries: -ELF64-NEXT: Num: Value Size Type Bind Vis Ndx Name -ELF64-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -ELF64-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text -ELF64-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 .data -ELF64-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .bss -ELF64-NEXT: 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND _GLOBAL_OFFSET_TABLE_ -ELF64-NEXT: 5: 0000000000000000 0 TLS GLOBAL DEFAULT UND sym - -NO-SYMTAB-NOT: Symbol table '.symtab' - -DYN: Symbol table '.dynsym' contains 5 entries: -DYN-NEXT: Num: Value Size Type Bind Vis Ndx Name -DYN-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -DYN-NEXT: 1: 00000000000001b8 0 NOTYPE GLOBAL DEFAULT 4 foo -DYN-NEXT: 2: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 _edata -DYN-NEXT: 3: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 _end -DYN-NEXT: 4: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 __bss_start - -DYN-NOT: .dynsym -NO-SYMTAB-NOT: Symbol table '.symtab' - -SYMTAB: Symbol table '.symtab' contains 12 entries: -SYMTAB-NEXT: Num: Value Size Type Bind Vis Ndx Name -SYMTAB-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -SYMTAB-NEXT: 1: 00000000000000e8 0 SECTION LOCAL DEFAULT 1 .gnu.hash -SYMTAB-NEXT: 2: 0000000000000120 0 SECTION LOCAL DEFAULT 2 .dynsym -SYMTAB-NEXT: 3: 0000000000000198 0 SECTION LOCAL DEFAULT 3 .dynstr -SYMTAB-NEXT: 4: 00000000000001b8 0 SECTION LOCAL DEFAULT 4 .eh_frame -SYMTAB-NEXT: 5: 00000000002001b8 0 SECTION LOCAL DEFAULT 5 .dynamic -SYMTAB-NEXT: 6: 00000000002001b8 0 OBJECT LOCAL DEFAULT 5 _DYNAMIC -SYMTAB-NEXT: 7: 0000000000200268 0 OBJECT LOCAL DEFAULT 5 _GLOBAL_OFFSET_TABLE_ -SYMTAB-NEXT: 8: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 __bss_start -SYMTAB-NEXT: 9: 00000000000001b8 0 NOTYPE GLOBAL DEFAULT 4 foo -SYMTAB-NEXT: 10: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 _edata -SYMTAB-NEXT: 11: 0000000000200268 0 NOTYPE GLOBAL DEFAULT 5 _end - -DYN-NOT: .dynsym Index: llvm/test/tools/llvm-readobj/ELF/symbols.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/symbols.test +++ llvm/test/tools/llvm-readobj/ELF/symbols.test @@ -1,42 +1,118 @@ ## This is a general test for --symbols option and its aliases. ## There are also other symbols* tests that check specific things. -# RUN: llvm-readobj --symbols %p/Inputs/trivial.obj.elf-i386 | FileCheck %s +## Case 1: Test how llvm-readobj and llvm-readelf dumps symbols. +# RUN: yaml2obj %s --docnum=1 -o %t64 +# RUN: llvm-readobj --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM +# RUN: llvm-readelf --symbols %t64 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU64 +# RUN: yaml2obj %s --docnum=2 -o %t32 +# RUN: llvm-readobj --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-LLVM +# RUN: llvm-readelf --symbols %t32 | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=SYMBOLS-GNU32 -## Check flag aliases produce identical output. -# RUN: llvm-readobj --symbols %p/Inputs/trivial.obj.elf-i386 > %t.symbols -# RUN: llvm-readobj --syms %p/Inputs/trivial.obj.elf-i386 > %t.syms +# SYMBOLS-LLVM:Symbols [ +# SYMBOLS-LLVM-NEXT: Symbol { +# SYMBOLS-LLVM-NEXT: Name: (0) +# SYMBOLS-LLVM-NEXT: Value: 0x0 +# SYMBOLS-LLVM-NEXT: Size: 0 +# SYMBOLS-LLVM-NEXT: Binding: Local (0x0) +# SYMBOLS-LLVM-NEXT: Type: None (0x0) +# SYMBOLS-LLVM-NEXT: Other: 0 +# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0) +# SYMBOLS-LLVM-NEXT: } +# SYMBOLS-LLVM-NEXT: Symbol { +# SYMBOLS-LLVM-NEXT: Name: foo (5) +# SYMBOLS-LLVM-NEXT: Value: 0x1 +# SYMBOLS-LLVM-NEXT: Size: 0 +# SYMBOLS-LLVM-NEXT: Binding: Local (0x0) +# SYMBOLS-LLVM-NEXT: Type: None (0x0) +# SYMBOLS-LLVM-NEXT: Other: 0 +# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0) +# SYMBOLS-LLVM-NEXT: } +# SYMBOLS-LLVM-NEXT: Symbol { +# SYMBOLS-LLVM-NEXT: Name: bar (1) +# SYMBOLS-LLVM-NEXT: Value: 0x2 +# SYMBOLS-LLVM-NEXT: Size: 0 +# SYMBOLS-LLVM-NEXT: Binding: Local (0x0) +# SYMBOLS-LLVM-NEXT: Type: None (0x0) +# SYMBOLS-LLVM-NEXT: Other: 0 +# SYMBOLS-LLVM-NEXT: Section: Undefined (0x0) +# SYMBOLS-LLVM-NEXT: } +# SYMBOLS-LLVM-NEXT:] + +# SYMBOLS-GNU64:Symbol table '.symtab' contains 3 entries: +# SYMBOLS-GNU64-NEXT: Num: Value Size Type Bind Vis Ndx Name +# SYMBOLS-GNU64-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +# SYMBOLS-GNU64-NEXT: 1: 0000000000000001 0 NOTYPE LOCAL DEFAULT UND foo +# SYMBOLS-GNU64-NEXT: 2: 0000000000000002 0 NOTYPE LOCAL DEFAULT UND bar + +# SYMBOLS-GNU32:Symbol table '.symtab' contains 3 entries: +# SYMBOLS-GNU32-NEXT: Num: Value Size Type Bind Vis Ndx Name +# SYMBOLS-GNU32-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND +# SYMBOLS-GNU32-NEXT: 1: 00000001 0 NOTYPE LOCAL DEFAULT UND foo +# SYMBOLS-GNU32-NEXT: 2: 00000002 0 NOTYPE LOCAL DEFAULT UND bar + +## Case 2: Check flag aliases produce identical output +# RUN: llvm-readobj --symbols %t64 > %t.symbols +# RUN: llvm-readobj --syms %t64 > %t.syms # RUN: cmp %t.symbols %t.syms -# RUN: llvm-readobj -t %p/Inputs/trivial.obj.elf-i386 > %t.t +# RUN: llvm-readobj -t %t64 > %t.t # RUN: cmp %t.symbols %t.t -# RUN: llvm-readelf -s --elf-output-style LLVM %p/Inputs/trivial.obj.elf-i386 > %t.lowers +# RUN: llvm-readelf -s --elf-output-style=LLVM %t64 > %t.lowers # RUN: cmp %t.symbols %t.lowers -# CHECK: Symbols [ -# CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: (0) -# CHECK-NEXT: Value: 0x0 -# CHECK-NEXT: Size: 0 -# CHECK-NEXT: Binding: Local (0x0) -# CHECK-NEXT: Type: None (0x0) -# CHECK-NEXT: Other: 0 -# CHECK-NEXT: Section: Undefined (0x0) -# CHECK-NEXT: } -# CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: trivial.ll (1) -# CHECK-NEXT: Value: 0x0 -# CHECK-NEXT: Size: 0 -# CHECK-NEXT: Binding: Local (0x0) -# CHECK-NEXT: Type: File (0x4) -# CHECK-NEXT: Other: 0 -# CHECK-NEXT: Section: Absolute (0xFFF1) -# CHECK-NEXT: } -# CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: .L.str (39) -# CHECK-NEXT: Value: 0x0 -# CHECK-NEXT: Size: 13 -# CHECK-NEXT: Binding: Local (0x0) -# CHECK-NEXT: Type: Object (0x1) -# CHECK-NEXT: Other: 0 -# CHECK-NEXT: Section: .rodata.str1.1 (0x5) -# CHECK-NEXT: } +# RUN: llvm-readelf --symbols %t64 > %t.symbols.gnu +# RUN: llvm-readelf --syms %t64 > %t.syms.gnu +# RUN: cmp %t.symbols.gnu %t.syms.gnu +## There is no -t option in llvm-readelf. +# RUN: not llvm-readelf -t %t64 2>&1 | FileCheck %s --check-prefix=NO-T-ERR +# NO-T-ERR: Unknown command line argument '-t' +## -s is an llvm-readobj option to dump sections. +# RUN: llvm-readobj -s --elf-output-style=GNU %t64 | FileCheck %s --implicit-check-not="Symbol table" + +## Case 3: Test that both regular and dynamic symbols are dumped when `--symbols` and `--dyn-symbols` +## are specified together. Note that the order is different for different styles. +# RUN: llvm-readobj --symbols --dyn-symbols %t64 | FileCheck %s --check-prefix=BOTH-LLVM +# RUN: llvm-readelf --symbols --dyn-symbols %t64 | FileCheck %s --check-prefix=BOTH-GNU + +# BOTH-LLVM: Symbols [ +# BOTH-LLVM: DynamicSymbols [ + +# BOTH-GNU: Symbol table '.dynsym' +# BOTH-GNU: Symbol table '.symtab' + +## Case 4: Test that `--symbols` triggers `--dyn-symbols` implicitly for llvm-readelf, +## but not for llvm-readobj. +# RUN: llvm-readobj --symbols %t64 | FileCheck %s --implicit-check-not="DynamicSymbols [" +# RUN: llvm-readelf --symbols %t64 | FileCheck %s --check-prefix=BOTH-GNU + +## Case 5: Test that `--dyn-symbols` does not trigger `--symbols` implicitly. +# RUN: llvm-readobj --dyn-symbols %t64 | FileCheck %s --implicit-check-not="{{^}}Symbols [" +# RUN: llvm-readelf --dyn-symbols %t64 | FileCheck %s --implicit-check-not="Symbol table '.symtab'" + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Symbols: + - Name: foo + Value: 0x1 + - Name: bar + Value: 0x2 +DynamicSymbols: + - Name: zed + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Symbols: + - Name: foo + Value: 0x1 + - Name: bar + Value: 0x2 +DynamicSymbols: + - Name: zed