1 ## Check how we dump invalid SHT_RISCV_ATTRIBUTES sections.
3 ## This test case is used to ensure llvm-readobj checks the version of
4 ## attribute sections correctly. The only supported format is 'A' (41),
5 ## here we use 'B' (42).
7 # RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o
8 # RUN: llvm-readobj -A %t1.32.o 2>&1 | \
9 # RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT
10 # RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o
11 # RUN: llvm-readobj -A %t1.64.o 2>&1 | \
12 # RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT
14 # ERR-FORMAT: BuildAttributes {
15 # ERR-FORMAT-NEXT: FormatVersion: 0x42
16 # ERR-FORMAT-NEXT: warning: '[[FILE]].{{32|64}}.o': unable to dump attributes from the SHT_RISCV_ATTRIBUTES section with index 1: unrecognized format-version: 0x42
21 Class: ELFCLASS[[BITS=64]]
26 - Name: .riscv.attributes
27 Type: SHT_RISCV_ATTRIBUTES
29 ShOffset: [[SHOFFSET=<none>]]
31 ## Check we report a warning when we are unable to parse the attribute section data.
32 ## FIXME: this test case documents that we don't close the "Section X" clause of
33 ## the output properly when a warning is reported by the attributes parser.
35 # RUN: yaml2obj %s -D BITS=32 -DCONTENT=4100000000 -o %t2.32.o
36 # RUN: llvm-readobj -A %t2.32.o 2>&1 | \
37 # RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH
38 # RUN: yaml2obj %s -D BITS=64 -DCONTENT=4100000000 -o %t2.64.o
39 # RUN: llvm-readobj -A %t2.64.o 2>&1 | \
40 # RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH
42 # ERR-LENGTH: BuildAttributes {
43 # ERR-LENGTH-NEXT: FormatVersion: 0x41
44 # ERR-LENGTH-NEXT: Section 1 {
45 # ERR-LENGTH-NEXT: warning: '[[FILE]].{{32|64}}.o': unable to dump attributes from the SHT_RISCV_ATTRIBUTES section with index 1: invalid section length 0 at offset 0x1
47 # ERR-LENGTH-NOT: {{.}}
49 ## Check that we don't report a warning when the SHT_RISCV_ATTRIBUTES section contains the
50 ## valid format version byte and no other data.
52 # RUN: yaml2obj %s -DCONTENT=41 -o %t3.o
53 # RUN: llvm-readobj -A %t3.o 2>&1 | \
54 # RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NO-CONTENT
56 # NO-CONTENT: BuildAttributes {
57 # NO-CONTENT-NEXT: FormatVersion: 0x41
60 ## Check we report a warning when we are unable to read the content of the SHT_RISCV_ATTRIBUTES section.
62 # RUN: yaml2obj %s -DCONTENT="''" -DSHOFFSET=0xffffffff -o %t4.o
63 # RUN: llvm-readobj -A %t4.o 2>&1 | \
64 # RUN: FileCheck %s -DFILE=%t4.o --implicit-check-not=warning: --check-prefix=BROKEN-CONTENT
66 # BROKEN-CONTENT: BuildAttributes {
67 # BROKEN-CONTENT-NEXT: warning: '[[FILE]]': unable to read the content of the SHT_RISCV_ATTRIBUTES section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x0) that is greater than the file size (0x168)
68 # BROKEN-CONTENT-NEXT: }
70 # RUN: yaml2obj %s -DCONTENT="''" -o %t5.o
71 # RUN: llvm-readobj -A %t5.o 2>&1 | \
72 # RUN: FileCheck %s -DFILE=%t5.o --implicit-check-not=warning: --check-prefix=EMPTY-CONTENT
74 # EMPTY-CONTENT: BuildAttributes {
75 # EMPTY-CONTENT-NEXT: warning: '[[FILE]]': the SHT_RISCV_ATTRIBUTES section with index 1 is empty
76 # EMPTY-CONTENT-NEXT: }