1# REQUIRES: x86
2
3## Test linker synthesized symbols (e.g. __ehdr_start, _end) can be used in linker scripts.
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
6# RUN: echo "PROVIDE_HIDDEN(newsym = __ehdr_start + 5);" > %t.script
7# RUN: ld.lld -o %t1 %t.script %t
8# RUN: llvm-objdump -t %t1 | FileCheck %s
9
10# CHECK: 0000000000200005 .text 00000000 .hidden newsym
11
12# RUN: ld.lld -o %t1.so %t.script %t -shared
13# RUN: llvm-objdump -t %t1.so | FileCheck --check-prefix=SHARED %s
14
15# SHARED: 0000000000000005 .dynsym 00000000 .hidden newsym
16
17# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(__ehdr_start, CONSTANT(MAXPAGESIZE)) + 5);" > %t.script
18# RUN: ld.lld -o %t1 %t.script %t
19# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=ALIGNED %s
20
21# ALIGNED: 0000000000200005 .text 00000000 .hidden newsym
22
23# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(3, 8) + 10);" > %t.script
24# RUN: ld.lld -o %t1 %t.script %t
25# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=ALIGN-ADD %s
26# ALIGN-ADD: 0000000000000012 *ABS* 00000000 .hidden newsym
27
28# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(11, 8) - 10);" > %t.script
29# RUN: ld.lld -o %t1 %t.script %t
30# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=ALIGN-SUB %s
31# ALIGN-SUB: 0000000000000006 *ABS* 00000000 .hidden newsym
32
33# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) + 5);" > %t.script
34# RUN: ld.lld -o %t1 %t %t.script
35# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE %s
36# RELATIVE: 0000000000202005 .text 00000000 .hidden newsym
37# RELATIVE: 0000000000201127 .text 00000000 _end
38
39# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) + 5);" > %t.script
40# RUN: ld.lld -o %t1 --script %p/Inputs/symbol-reserved.script %t %t.script
41# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE-ADD %s
42# RELATIVE-ADD: 0000000000001005 .text 00000000 .hidden newsym
43# RELATIVE-ADD: 0000000000000007 .text 00000000 .hidden _end
44
45# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) - 5);" > %t.script
46# RUN: ld.lld -o %t1 --script %p/Inputs/symbol-reserved.script %t %t.script
47# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE-SUB %s
48# RELATIVE-SUB: 0000000000000ffb .text 00000000 .hidden newsym
49# RELATIVE-SUB: 0000000000000007 .text 00000000 .hidden _end
50
51.global _start
52_start:
53  lea newsym(%rip),%rax
54