126 lines · plain
1## Show that llvm-readobj can dump SHT_LLVM_ADDRSIG sections.2 3# RUN: yaml2obj --docnum=1 %s -o %t1.o4# RUN: llvm-readobj --addrsig %t1.o | FileCheck -DFILE=%t1.o %s --check-prefix=LLVM5# RUN: llvm-readelf --addrsig %t1.o | \6# RUN: FileCheck -DFILE=%t1.o %s --strict-whitespace --match-full-lines --check-prefix=GNU7 8# LLVM: Addrsig [9# LLVM-NEXT: Sym: foo (1)10# LLVM-NEXT: Sym: bar (2)11# LLVM-NEXT: ]12 13# GNU:Address-significant symbols section '.llvm_addrsig' contains 2 entries:14# GNU-NEXT: Num: Name15# GNU-NEXT: 1: foo16# GNU-NEXT: 2: bar17# GNU-EMPTY:18# GNU-NOT:{{.}}19 20--- !ELF21FileHeader:22 Class: ELFCLASS6423 Data: ELFDATA2LSB24 Type: ET_DYN25Sections:26 - Name: .llvm_addrsig27 ShName: [[NAME=<none>]]28 Type: SHT_LLVM_ADDRSIG29 Symbols: [ foo, bar ]30Symbols:31 - Name: foo32 - Name: bar33 34## Check what we print when it is impossible to read the name of the SHT_LLVM_ADDRSIG section.35## llvm-readelf reports a warning in this case.36 37# RUN: yaml2obj --docnum=1 -DNAME=0xff %s -o %t1.name.o38# RUN: llvm-readobj --addrsig %t1.name.o 2>&1 | \39# RUN: FileCheck -DFILE=%t1.name.o %s --check-prefix=LLVM --implicit-check-not=warning:40# RUN: llvm-readelf --addrsig %t1.name.o 2>&1 | \41# RUN: FileCheck -DFILE=%t1.name.o %s --check-prefix=NAME-GNU --implicit-check-not=warning:42 43# NAME-GNU: warning: '[[FILE]]': unable to get the name of SHT_LLVM_ADDRSIG section with index 1: a section [index 1] has an invalid sh_name (0xff) offset which goes past the end of the section name string table44# NAME-GNU: Address-significant symbols section '<?>' contains 2 entries:45# NAME-GNU-NEXT: Num: Name46# NAME-GNU-NEXT: 1: foo47# NAME-GNU-NEXT: 2: bar48 49## Check that llvm-readobj dumps any SHT_LLVM_ADDRSIG section when --all50## is specified for LLVM style, but not for GNU style.51 52# RUN: llvm-readobj --all %t1.o | FileCheck %s --check-prefix=LLVM53# RUN: llvm-readelf --all %t1.o | FileCheck %s --implicit-check-not="Address-significant"54 55## Check we report a warning when the content of the SHT_LLVM_ADDRSIG section56## is broken (e.g. contains a malformed uleb128).57 58# RUN: yaml2obj --docnum=2 %s -o %t2.1.o59# RUN: llvm-readobj --addrsig %t2.1.o 2>&1 | FileCheck %s -DFILE=%t2.1.o --check-prefix=MALFORMED-LLVM60# RUN: llvm-readelf --addrsig %t2.1.o 2>&1 | FileCheck %s -DFILE=%t2.1.o --check-prefix=MALFORMED-GNU61 62# MALFORMED-LLVM: Addrsig [63# MALFORMED-LLVM-NEXT: warning: '[[FILE]]': unable to decode SHT_LLVM_ADDRSIG section with index 1: malformed uleb128, extends past end64# MALFORMED-LLVM-NEXT: ]65 66# MALFORMED-GNU: warning: '[[FILE]]': unable to decode SHT_LLVM_ADDRSIG section with index 1: malformed uleb128, extends past end67# MALFORMED-GNU-NOT:{{.}}68 69--- !ELF70FileHeader:71 Class: ELFCLASS6472 Data: ELFDATA2LSB73 Type: ET_DYN74Sections:75 - Name: .llvm_addrsig76 Type: SHT_LLVM_ADDRSIG77 Content: "FF"78 ShOffset: [[OFFSET=<none>]]79 80## Check we report a warning when the content of the SHT_LLVM_ADDRSIG section can't be read.81 82# RUN: yaml2obj --docnum=2 -DOFFSET=0xffffffff %s -o %t2.2.o83# RUN: llvm-readobj --addrsig %t2.2.o 2>&1 | FileCheck %s -DFILE=%t2.2.o --check-prefix=BROKEN-SEC-LLVM84# RUN: llvm-readelf --addrsig %t2.2.o 2>&1 | FileCheck %s -DFILE=%t2.2.o --check-prefix=BROKEN-SEC-GNU85 86# BROKEN-SEC-LLVM: Addrsig [87# BROKEN-SEC-LLVM-NEXT: warning: '[[FILE]]': section [index 1] has a sh_offset (0xffffffff) + sh_size (0x1) that is greater than the file size (0x168)88# BROKEN-SEC-LLVM-NEXT: ]89 90# BROKEN-SEC-GNU: warning: '[[FILE]]': section [index 1] has a sh_offset (0xffffffff) + sh_size (0x1) that is greater than the file size (0x168)91# BROKEN-SEC-GNU-NOT:{{.}}92 93## Check we report a warning when SHT_LLVM_ADDRSIG references a symbol that can't be94## dumped (e.g. the index value is larger than the number of symbols in .symtab).95 96# RUN: yaml2obj --docnum=3 %s -o %t3.o97# RUN: llvm-readobj --addrsig %t3.o 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALID-INDEX-LLVM98# RUN: llvm-readelf --addrsig %t3.o 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALID-INDEX-GNU99 100# INVALID-INDEX-LLVM: Addrsig [101# INVALID-INDEX-LLVM-NEXT: Sym: foo (1)102# INVALID-INDEX-LLVM-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 255: unable to get symbol from section [index 2]: invalid symbol index (255)103# INVALID-INDEX-LLVM-NEXT: Sym: <?> (255)104# INVALID-INDEX-LLVM-NEXT: Sym: bar (2)105# INVALID-INDEX-LLVM-NEXT: ]106 107# INVALID-INDEX-GNU: Address-significant symbols section '.llvm_addrsig' contains 3 entries:108# INVALID-INDEX-GNU-NEXT: Num: Name109# INVALID-INDEX-GNU-NEXT: 1: foo110# INVALID-INDEX-GNU-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 255: unable to get symbol from section [index 2]: invalid symbol index (255)111# INVALID-INDEX-GNU-NEXT: 2: <?>112# INVALID-INDEX-GNU-NEXT: 3: bar113 114--- !ELF115FileHeader:116 Class: ELFCLASS64117 Data: ELFDATA2LSB118 Type: ET_DYN119Sections:120 - Name: .llvm_addrsig121 Type: SHT_LLVM_ADDRSIG122 Symbols: [ 1, 255, 2 ]123Symbols:124 - Name: foo125 - Name: bar126