1# REQUIRES: x86
2
3# RUN: rm -rf %t.dir
4# RUN: split-file %s %t.dir
5# RUN: cd %t.dir
6
7## Verify that in the following case:
8##
9##   <exec>
10##   +- ref.so (weak reference to foo)
11##   +- wrap.so (non-weak reference to foo)
12##      +- def.so (defines foo)
13##
14## we don't report that foo is undefined in ref.so when linking <exec>.
15
16# RUN: llvm-mc -filetype=obj -triple=x86_64 ref.s -o ref.o
17# RUN: llvm-mc -filetype=obj -triple=x86_64 wrap.s -o wrap.o
18# RUN: llvm-mc -filetype=obj -triple=x86_64 def.s -o def.o
19# RUN: ld.lld -shared ref.o -o ref.so
20# RUN: ld.lld -shared def.o -soname def.so -o def.so
21# RUN: ld.lld -shared wrap.o def.so -o wrap.so
22
23# RUN: llvm-mc -filetype=obj -triple=x86_64 start.s -o start.o
24# RUN: ld.lld --no-allow-shlib-undefined start.o wrap.so ref.so -o /dev/null 2>&1 | count 0
25
26#--- start.s
27.globl _start
28_start:
29  callq wrap_get_foo@PLT
30
31#--- ref.s
32.weak foo
33.globl ref_get_foo
34ref_get_foo:
35  movq foo@GOTPCREL(%rip), %rax
36  retq
37
38#--- wrap.s
39.globl wrap_get_foo
40wrap_get_foo:
41  movq foo@GOTPCREL(%rip), %rax
42  retq
43
44#--- def.s
45.data
46.globl foo
47foo:
48  .long 0
49