• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2## For a relative pathname in INPUT() or GROUP(), the parent directory of
3## the current linker script has priority over current working directory and -L.
4
5# RUN: rm -rf %t.dir && mkdir %t.dir && cd %t.dir
6
7# RUN: mkdir dir
8# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o
9# RUN: echo '.globl b, cwd; b: cwd:' | llvm-mc -filetype=obj -triple=x86_64 - -o b.o
10# RUN: echo '.globl b, dir; b: dir:' | llvm-mc -filetype=obj -triple=x86_64 - -o dir/b.o
11# RUN: llvm-ar rc libb.a b.o
12# RUN: llvm-ar rc dir/libb.a dir/b.o
13
14## A relative pathname is relative to the parent directory of the current linker script.
15## The directory has priority over current working directory and -L.
16# RUN: echo 'INPUT(libb.a)' > dir/relative.lds
17# RUN: ld.lld -L. a.o dir/relative.lds -o - | llvm-nm - | FileCheck --check-prefix=DIR %s
18## GROUP() uses the same search order.
19# RUN: echo 'GROUP(libb.a)' > dir/relative1.lds
20# RUN: ld.lld -L. a.o dir/relative1.lds -o - | llvm-nm - | FileCheck --check-prefix=DIR %s
21
22# DIR: T dir
23
24## -l does not use the special rule.
25# RUN: echo 'INPUT(-lb)' > dir/cwd.lds
26# RUN: ld.lld -L. a.o dir/cwd.lds -o - | llvm-nm - | FileCheck --check-prefix=CWD %s
27# RUN: echo 'GROUP(-lb)' > dir/cwd1.lds
28# RUN: ld.lld -L. a.o dir/cwd1.lds -o - | llvm-nm - | FileCheck --check-prefix=CWD %s
29
30# CWD: T cwd
31
32## The rules does not apply to an absolute path.
33# RUN: echo 'INPUT(/libb.a)' > dir/absolute.lds
34# RUN: not ld.lld a.o dir/absolute.lds -o /dev/null
35
36## If the parent directory of the current linker script does not contain the file,
37## fall back to the current working directory.
38# RUN: cp libb.a libc.a
39# RUN: echo 'INPUT(libc.a)' > dir/fallback.lds
40# RUN: ld.lld a.o dir/fallback.lds -o /dev/null
41
42.globl _start
43_start:
44  call b
45