1## REQUIRES: x86 2## Test that we can parse SHT_GNU_verneed in a shared object and report certain errors. 3 4# RUN: echo '.globl _start; _start:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o 5 6## sh_offset(SHT_GNU_verneed) is out of bounds. 7# RUN: yaml2obj --docnum=1 %s -o %t1.so 8# RUN: not ld.lld %t.o %t1.so -o /dev/null 2>&1 | FileCheck --check-prefix=SHOFFSET %s 9# SHOFFSET: error: {{.*}}.so: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x0) that is greater than the file size (0x168) 10--- !ELF 11FileHeader: 12 Class: ELFCLASS64 13 Data: ELFDATA2LSB 14 Type: ET_DYN 15 Machine: EM_X86_64 16Sections: 17 - Name: .gnu.version_r 18 Type: SHT_GNU_verneed 19 Flags: [ SHF_ALLOC ] 20 Info: 1 21 ShOffset: 0xFFFFFFFF 22 23## A Verneed entry is misaligned (not a multiple of 4). This may happen 24## some interface shared objects. We use memcpy to read the fields, so 25## misalignment isn't a problem and there is no need to diagnose. 26# RUN: yaml2obj --docnum=2 %s -o %t2.so 27# RUN: ld.lld %t.o %t2.so -o /dev/null 28--- !ELF 29FileHeader: 30 Class: ELFCLASS64 31 Data: ELFDATA2LSB 32 Type: ET_DYN 33 Machine: EM_X86_64 34Sections: 35 - Type: Fill 36 Size: 0x1 37 - Name: .gnu.version_r 38 Type: SHT_GNU_verneed 39 Flags: [ SHF_ALLOC ] 40 Info: 1 41 Link: .dynstr 42 Dependencies: 43 - Version: 1 44 File: foo 45 Entries: 46 - Name: 'foo' 47 Hash: 0 48 Flags: 0 49 Other: 0 50DynamicSymbols: 51 - Name: foo 52 53## vn_aux points to a place outside of the file. 54# RUN: yaml2obj --docnum=3 -D VERNEED=0100010001000000040200000000000000000000 %s -o %t3.so 55# RUN: not ld.lld %t.o %t3.so -o /dev/null 2>&1 | FileCheck --check-prefix=AUX-OOB %s 56# AUX-OOB: {{.*}}.so has an invalid Vernaux 57--- !ELF 58FileHeader: 59 Class: ELFCLASS64 60 Data: ELFDATA2LSB 61 Type: ET_DYN 62 Machine: EM_X86_64 63Sections: 64 - Name: .gnu.version_r 65 Type: SHT_GNU_verneed 66 Flags: [ SHF_ALLOC ] 67 Info: 1 68 Link: .dynstr 69 Content: "[[VERNEED]]" 70DynamicSymbols: 71 - Name: foo 72 73## vn_aux is misaligned. 74# RUN: yaml2obj --docnum=3 -D VERNEED=0100010001000000110000000000000000000000 %s -o %t4.so 75# RUN: not ld.lld %t.o %t4.so -o /dev/null 2>&1 | FileCheck --check-prefix=AUX-MISALIGNED %s 76# AUX-MISALIGNED: {{.*}}.so has an invalid Vernaux 77 78## vna_name is out of bounds. 79# RUN: yaml2obj --docnum=3 -D VERNEED=010001000000000010000000000000009107000000000000ff00000000000000 %s -o %t5.so 80# RUN: not ld.lld %t.o %t5.so -o /dev/null 2>&1 | FileCheck --check-prefix=NAME-OOB %s 81# NAME-OOB: {{.*}}.so has a Vernaux with an invalid vna_name 82