82 lines · plain
1# REQUIRES: x862# RUN: rm -fr %t && split-file %s %t3 4## Build an object with a trivial main function5# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t1.o6 7## Build %t.a which defines a global 'foo'8# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/archive.s -o %t2.o9# RUN: rm -f %t2.a10# RUN: llvm-ar rc %t2.a %t2.o11 12## Build %t.so that has a reference to 'foo'13# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/shlib.s -o %t3.o14# RUN: ld.lld %t3.o -o %t3.so -shared15 16## Test that 'foo' from %t2.a is fetched to define 'foo' needed by %t3.so.17## Test both cases where the archive is before or after the shared library in18## link order.19 20# RUN: ld.lld %t1.o %t2.a %t3.so -o %t.exe21# RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH22 23# RUN: ld.lld %t1.o %t3.so %t2.a -o %t.exe24# RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH25 26# CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo27 28## Unversioned undefined symbols also extract the archive definitions.29# RUN: yaml2obj %t/ver.yaml -o %t4.so30# RUN: ld.lld %t1.o %t4.so %t2.a -o %t.exe31# RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH32 33#--- main.s34.text35.globl _start36.type _start,@function37_start:38 ret39 40#--- archive.s41.global foo42foo:43 44#--- shlib.s45.global foo46 47#--- ver.yaml48--- !ELF49FileHeader:50 Class: ELFCLASS6451 Data: ELFDATA2LSB52 Type: ET_DYN53 Machine: EM_X86_6454Sections:55 - Name: .gnu.version56 Type: SHT_GNU_versym57 Flags: [ SHF_ALLOC ]58 Address: 0x000000000020021059 AddressAlign: 0x000000000000000260 EntSize: 0x000000000000000261## Test both index 0 and 1 for unversioned undefined symbols.62## https://sourceware.org/PR3357763 Entries: [ 0, 0, 1 ]64 - Name: .gnu.version_r65 Type: SHT_GNU_verneed66 Flags: [ SHF_ALLOC ]67 Address: 0x000000000020025068 AddressAlign: 0x000000000000000469 Dependencies:70 - Version: 171 File: dso.so.072 Entries:73 - Name: v174 Hash: 193775 Flags: 076 Other: 377DynamicSymbols:78 - Name: _start79 Binding: STB_GLOBAL80 - Name: foo81 Binding: STB_GLOBAL82