brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 882bbb5 Raw
77 lines · plain
1## Check how we dump invalid SHT_RISCV_ATTRIBUTES sections.2 3## This test case is used to ensure llvm-readobj checks the version of4## attribute sections correctly. The only supported format is 'A' (41),5## here we use 'B' (42).6 7# RUN: yaml2obj %s -D BITS=32 -DCONTENT=42 -o %t1.32.o8# RUN: llvm-readobj -A %t1.32.o 2>&1 | \9# RUN:   FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT10# RUN: yaml2obj %s -D BITS=64 -DCONTENT=42 -o %t1.64.o11# RUN: llvm-readobj -A %t1.64.o 2>&1 | \12# RUN:   FileCheck -DFILE=%t1 %s --implicit-check-not=warning: --check-prefix=ERR-FORMAT13 14# ERR-FORMAT:      BuildAttributes {15# ERR-FORMAT-NEXT:   FormatVersion: 0x4216# ERR-FORMAT-NEXT: warning: '[[FILE]].{{32|64}}.o': unable to dump attributes from the SHT_RISCV_ATTRIBUTES section with index 1: unrecognized format-version: 0x4217# ERR-FORMAT-NEXT: }18 19--- !ELF20FileHeader:21  Class:   ELFCLASS[[BITS=64]]22  Data:    ELFDATA2LSB23  Type:    ET_REL24  Machine: EM_RISCV25Sections:26  - Name:     .riscv.attributes27    Type:     SHT_RISCV_ATTRIBUTES28    Content:  [[CONTENT]]29    ShOffset: [[SHOFFSET=<none>]]30 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 of33##        the output properly when a warning is reported by the attributes parser.34 35# RUN: yaml2obj %s -D BITS=32 -DCONTENT=4100000000 -o %t2.32.o36# RUN: llvm-readobj -A %t2.32.o 2>&1 | \37# RUN:   FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH38# RUN: yaml2obj %s -D BITS=64 -DCONTENT=4100000000 -o %t2.64.o39# RUN: llvm-readobj -A %t2.64.o 2>&1 | \40# RUN:   FileCheck -DFILE=%t2 %s --implicit-check-not=warning: --check-prefix=ERR-LENGTH41 42# ERR-LENGTH:      BuildAttributes {43# ERR-LENGTH-NEXT:   FormatVersion: 0x4144# 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 0x146# ERR-LENGTH-NEXT:   }47# ERR-LENGTH-NOT: {{.}}48 49## Check that we don't report a warning when the SHT_RISCV_ATTRIBUTES section contains the50## valid format version byte and no other data.51 52# RUN: yaml2obj %s -DCONTENT=41 -o %t3.o53# RUN: llvm-readobj -A %t3.o 2>&1 | \54# RUN:   FileCheck %s --implicit-check-not=warning: --check-prefix=NO-CONTENT55 56# NO-CONTENT:      BuildAttributes {57# NO-CONTENT-NEXT:   FormatVersion: 0x4158# NO-CONTENT-NEXT: }59 60## Check we report a warning when we are unable to read the content of the SHT_RISCV_ATTRIBUTES section.61 62# RUN: yaml2obj %s -DCONTENT="''" -DSHOFFSET=0xffffffff -o %t4.o63# RUN: llvm-readobj -A %t4.o 2>&1 | \64# RUN:   FileCheck %s -DFILE=%t4.o --implicit-check-not=warning: --check-prefix=BROKEN-CONTENT65 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: }69 70# RUN: yaml2obj %s -DCONTENT="''" -o %t5.o71# RUN: llvm-readobj -A %t5.o 2>&1 | \72# RUN:   FileCheck %s -DFILE=%t5.o --implicit-check-not=warning: --check-prefix=EMPTY-CONTENT73 74# EMPTY-CONTENT:      BuildAttributes {75# EMPTY-CONTENT-NEXT: warning: '[[FILE]]': the SHT_RISCV_ATTRIBUTES section with index 1 is empty76# EMPTY-CONTENT-NEXT: }77