Skip to content

Commit 4b9233c

Browse files
author
George Rimar
committed
[llvm-nm] - Add a test case for case when we dump a symbol that belongs to a section with a broken sh_name.
It adds a test case for a problem fixed by D66976. It was introduced by me in D66089. The error reported was never consumed because of a wrong variable name used, so it could fail when LLVM_ENABLE_ABI_BREAKING_CHECKS is used. Differential revision: https://reviews.llvm.org/D67002 llvm-svn: 370661
1 parent 9c68edd commit 4b9233c

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

llvm/test/tools/llvm-nm/format-sysv-section.test

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# RUN: yaml2obj %s > %t.o
2-
# RUN: llvm-nm %t.o --format=sysv | FileCheck %s
1+
# RUN: yaml2obj --docnum=1 %s > %t1.o
2+
# RUN: llvm-nm %t1.o --format=sysv | FileCheck %s
33

4-
!ELF
4+
--- !ELF
55
FileHeader:
66
Class: ELFCLASS64
77
Data: ELFDATA2LSB
@@ -33,3 +33,27 @@ Symbols:
3333
# CHECK-NEXT: symbol_absolute {{.*}}| |*ABS*
3434
# CHECK-NEXT: symbol_common {{.*}}| |*COM*
3535
# CHECK-NEXT: symbol_undefined {{.*}}| |*UND*
36+
37+
## Here we have a symbol that belongs to a section with a broken name
38+
## (sh_name offset goes past the end of the sections name string table).
39+
## We test that we can still print a reasonable output and don't crash/assert.
40+
41+
# RUN: yaml2obj --docnum=2 %s > %t2.o
42+
# RUN: llvm-nm %t2.o --format=sysv | FileCheck %s --check-prefix=ERR
43+
44+
# ERR: foo |0000000000000000| ? | NOTYPE|0000000000000000| |
45+
46+
--- !ELF
47+
FileHeader:
48+
Class: ELFCLASS64
49+
Data: ELFDATA2LSB
50+
Type: ET_REL
51+
Machine: EM_X86_64
52+
Sections:
53+
- Name: .broken
54+
Type: SHT_PROGBITS
55+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
56+
ShName: 0xffff
57+
Symbols:
58+
- Name: foo
59+
Section: .broken

0 commit comments

Comments
 (0)