77 lines
3.3 KiB
Plaintext
77 lines
3.3 KiB
Plaintext
|
## Check how we dump invalid SHT_RISCV_ATTRIBUTES sections.
|
||
|
|
||
|
## This test case is used to ensure llvm-readobj checks the version of
|
||
|
## attribute sections correctly. The only supported format is 'A' (41),
|
||
|
## here we use 'B' (42).
|
||
|
|
||
|
# RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o
|
||
|
# RUN: llvm-readobj -A %t1.32.o 2>&1 | \
|
||
|
# RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT
|
||
|
# RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o
|
||
|
# RUN: llvm-readobj -A %t1.64.o 2>&1 | \
|
||
|
# RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT
|
||
|
|
||
|
# ERR-FORMAT: BuildAttributes {
|
||
|
# ERR-FORMAT-NEXT: FormatVersion: 0x42
|
||
|
# 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
|
||
|
# ERR-FORMAT-NEXT: }
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS[[BITS=64]]
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Machine: EM_RISCV
|
||
|
Sections:
|
||
|
- Name: .riscv.attributes
|
||
|
Type: SHT_RISCV_ATTRIBUTES
|
||
|
Content: [[CONTENT]]
|
||
|
ShOffset: [[SHOFFSET=<none>]]
|
||
|
|
||
|
## Check we report a warning when we are unable to parse the attribute section data.
|
||
|
## FIXME: this test case documents that we don't close the "Section X" clause of
|
||
|
## the output properly when a warning is reported by the attributes parser.
|
||
|
|
||
|
# RUN: yaml2obj %s -D BITS=32 -DCONTENT=4100000000 -o %t2.32.o
|
||
|
# RUN: llvm-readobj -A %t2.32.o 2>&1 | \
|
||
|
# RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH
|
||
|
# RUN: yaml2obj %s -D BITS=64 -DCONTENT=4100000000 -o %t2.64.o
|
||
|
# RUN: llvm-readobj -A %t2.64.o 2>&1 | \
|
||
|
# RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH
|
||
|
|
||
|
# ERR-LENGTH: BuildAttributes {
|
||
|
# ERR-LENGTH-NEXT: FormatVersion: 0x41
|
||
|
# ERR-LENGTH-NEXT: Section 1 {
|
||
|
# 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
|
||
|
# ERR-LENGTH-NEXT: }
|
||
|
# ERR-LENGTH-NOT: {{.}}
|
||
|
|
||
|
## Check that we don't report a warning when the SHT_RISCV_ATTRIBUTES section contains the
|
||
|
## valid format version byte and no other data.
|
||
|
|
||
|
# RUN: yaml2obj %s -DCONTENT=41 -o %t3.o
|
||
|
# RUN: llvm-readobj -A %t3.o 2>&1 | \
|
||
|
# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NO-CONTENT
|
||
|
|
||
|
# NO-CONTENT: BuildAttributes {
|
||
|
# NO-CONTENT-NEXT: FormatVersion: 0x41
|
||
|
# NO-CONTENT-NEXT: }
|
||
|
|
||
|
## Check we report a warning when we are unable to read the content of the SHT_RISCV_ATTRIBUTES section.
|
||
|
|
||
|
# RUN: yaml2obj %s -DCONTENT="''" -DSHOFFSET=0xffffffff -o %t4.o
|
||
|
# RUN: llvm-readobj -A %t4.o 2>&1 | \
|
||
|
# RUN: FileCheck %s -DFILE=%t4.o --implicit-check-not=warning: --check-prefix=BROKEN-CONTENT
|
||
|
|
||
|
# BROKEN-CONTENT: BuildAttributes {
|
||
|
# 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)
|
||
|
# BROKEN-CONTENT-NEXT: }
|
||
|
|
||
|
# RUN: yaml2obj %s -DCONTENT="''" -o %t5.o
|
||
|
# RUN: llvm-readobj -A %t5.o 2>&1 | \
|
||
|
# RUN: FileCheck %s -DFILE=%t5.o --implicit-check-not=warning: --check-prefix=EMPTY-CONTENT
|
||
|
|
||
|
# EMPTY-CONTENT: BuildAttributes {
|
||
|
# EMPTY-CONTENT-NEXT: warning: '[[FILE]]': the SHT_RISCV_ATTRIBUTES section with index 1 is empty
|
||
|
# EMPTY-CONTENT-NEXT: }
|