1# REQUIRES: x86
2
3# RUN: echo '.globl a1, a2; .type a1, @function; .type a2, @function; a1: a2: ret' | \
4# RUN:   llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %ta.o
5# RUN: ld.lld %ta.o --shared --soname=a.so -o %ta.so
6
7# RUN: echo '.globl b; .type b, @function; b: jmp a1@PLT' | \
8# RUN:   llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %tb.o
9# RUN: ld.lld %tb.o %ta.so --shared --soname=b.so -o %tb.so
10
11# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
12# RUN: ld.lld %t.o %tb.so --as-needed %ta.so -o %t
13# RUN: llvm-readelf -d %t | FileCheck %s
14
15# RUN: ld.lld %t.o %tb.so --as-needed %ta.so --gc-sections -o %t
16# RUN: llvm-readelf -d %t | FileCheck %s
17
18# The symbol a1 (defined in a.so) is not referenced by a regular object,
19# the reference to a2 is weak, don't add a DT_NEEDED entry for a.so.
20# CHECK-NOT: a.so
21
22# RUN: ld.lld %t.o %tb.so --as-needed %ta.so --no-as-needed %ta.so -o %t
23# RUN: llvm-readelf -d %t | FileCheck %s -check-prefix=NEEDED
24
25# a.so is needed because one of its occurrences is needed.
26# NEEDED: a.so
27
28.global _start
29.weak a2
30_start:
31  jmp b@PLT
32  jmp a2
33