1ade2fbbfSGeorgii Rymar## Check how we dump invalid SHT_RISCV_ATTRIBUTES sections. 2ade2fbbfSGeorgii Rymar 3ade2fbbfSGeorgii Rymar## This test case is used to ensure llvm-readobj checks the version of 4ade2fbbfSGeorgii Rymar## attribute sections correctly. The only supported format is 'A' (41), 5ade2fbbfSGeorgii Rymar## here we use 'B' (42). 6ade2fbbfSGeorgii Rymar 7ade2fbbfSGeorgii Rymar# RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o 8*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t1.32.o 2>&1 | \ 9*137a25f0SGeorgii Rymar# RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT 10ade2fbbfSGeorgii Rymar# RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o 11*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t1.64.o 2>&1 | \ 12*137a25f0SGeorgii Rymar# RUN: FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT 13ade2fbbfSGeorgii Rymar 14*137a25f0SGeorgii Rymar# ERR-FORMAT: BuildAttributes { 15*137a25f0SGeorgii Rymar# ERR-FORMAT-NEXT: FormatVersion: 0x42 16*137a25f0SGeorgii Rymar# 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 17*137a25f0SGeorgii Rymar# ERR-FORMAT-NEXT: } 18ade2fbbfSGeorgii Rymar 19ade2fbbfSGeorgii Rymar--- !ELF 20ade2fbbfSGeorgii RymarFileHeader: 21ade2fbbfSGeorgii Rymar Class: ELFCLASS[[BITS=64]] 22ade2fbbfSGeorgii Rymar Data: ELFDATA2LSB 23ade2fbbfSGeorgii Rymar Type: ET_REL 24ade2fbbfSGeorgii Rymar Machine: EM_RISCV 25ade2fbbfSGeorgii RymarSections: 26ade2fbbfSGeorgii Rymar - Name: .riscv.attributes 27ade2fbbfSGeorgii Rymar Type: SHT_RISCV_ATTRIBUTES 28ade2fbbfSGeorgii Rymar Content: [[CONTENT]] 29*137a25f0SGeorgii Rymar ShOffset: [[SHOFFSET=<none>]] 30ade2fbbfSGeorgii Rymar 31ade2fbbfSGeorgii Rymar## Check we report a warning when we are unable to parse the attribute section data. 32*137a25f0SGeorgii Rymar## FIXME: this test case documents that we don't close the "Section X" clause of 33*137a25f0SGeorgii Rymar## the output properly when a warning is reported by the attributes parser. 34ade2fbbfSGeorgii Rymar 35ade2fbbfSGeorgii Rymar# RUN: yaml2obj %s -D BITS=32 -DCONTENT=4100000000 -o %t2.32.o 36*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t2.32.o 2>&1 | \ 37*137a25f0SGeorgii Rymar# RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH 38ade2fbbfSGeorgii Rymar# RUN: yaml2obj %s -D BITS=64 -DCONTENT=4100000000 -o %t2.64.o 39*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t2.64.o 2>&1 | \ 40*137a25f0SGeorgii Rymar# RUN: FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH 41ade2fbbfSGeorgii Rymar 42*137a25f0SGeorgii Rymar# ERR-LENGTH: BuildAttributes { 43*137a25f0SGeorgii Rymar# ERR-LENGTH-NEXT: FormatVersion: 0x41 44*137a25f0SGeorgii Rymar# ERR-LENGTH-NEXT: Section 1 { 45*137a25f0SGeorgii Rymar# 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 46*137a25f0SGeorgii Rymar# ERR-LENGTH-NEXT: } 47*137a25f0SGeorgii Rymar# ERR-LENGTH-NOT: {{.}} 48*137a25f0SGeorgii Rymar 49*137a25f0SGeorgii Rymar## Check that we don't report a warning when the SHT_RISCV_ATTRIBUTES section contains the 50*137a25f0SGeorgii Rymar## valid format version byte and no other data. 51*137a25f0SGeorgii Rymar 52*137a25f0SGeorgii Rymar# RUN: yaml2obj %s -DCONTENT=41 -o %t3.o 53*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t3.o 2>&1 | \ 54*137a25f0SGeorgii Rymar# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NO-CONTENT 55*137a25f0SGeorgii Rymar 56*137a25f0SGeorgii Rymar# NO-CONTENT: BuildAttributes { 57*137a25f0SGeorgii Rymar# NO-CONTENT-NEXT: FormatVersion: 0x41 58*137a25f0SGeorgii Rymar# NO-CONTENT-NEXT: } 59*137a25f0SGeorgii Rymar 60*137a25f0SGeorgii Rymar## Check we report a warning when we are unable to read the content of the SHT_RISCV_ATTRIBUTES section. 61*137a25f0SGeorgii Rymar 62*137a25f0SGeorgii Rymar# RUN: yaml2obj %s -DCONTENT="''" -DSHOFFSET=0xffffffff -o %t4.o 63*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t4.o 2>&1 | \ 64*137a25f0SGeorgii Rymar# RUN: FileCheck %s -DFILE=%t4.o --implicit-check-not=warning: --check-prefix=BROKEN-CONTENT 65*137a25f0SGeorgii Rymar 66*137a25f0SGeorgii Rymar# BROKEN-CONTENT: BuildAttributes { 67*137a25f0SGeorgii Rymar# 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*137a25f0SGeorgii Rymar# BROKEN-CONTENT-NEXT: } 69*137a25f0SGeorgii Rymar 70*137a25f0SGeorgii Rymar# RUN: yaml2obj %s -DCONTENT="''" -o %t5.o 71*137a25f0SGeorgii Rymar# RUN: llvm-readobj -A %t5.o 2>&1 | \ 72*137a25f0SGeorgii Rymar# RUN: FileCheck %s -DFILE=%t5.o --implicit-check-not=warning: --check-prefix=EMPTY-CONTENT 73*137a25f0SGeorgii Rymar 74*137a25f0SGeorgii Rymar# EMPTY-CONTENT: BuildAttributes { 75*137a25f0SGeorgii Rymar# EMPTY-CONTENT-NEXT: warning: '[[FILE]]': the SHT_RISCV_ATTRIBUTES section with index 1 is empty 76*137a25f0SGeorgii Rymar# EMPTY-CONTENT-NEXT: } 77