[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / symbol-reserved.s
blob740213457d9723c55c37e94cf1d7f2bbc047b963
1 # REQUIRES: x86
3 ## Test linker synthesized symbols (e.g. __ehdr_start, _end) can be used in linker scripts.
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
10 # CHECK: 0000000000200005 l .text 0000000000000000 .hidden newsym
12 # RUN: ld.lld -o %t1.so %t.script %t -shared
13 # RUN: llvm-objdump -t %t1.so | FileCheck --check-prefix=SHARED %s
15 # SHARED: 0000000000000005 l .dynsym 0000000000000000 .hidden newsym
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
21 # ALIGNED: 0000000000200005 l .text 0000000000000000 .hidden newsym
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 l *ABS* 0000000000000000 .hidden newsym
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 l *ABS* 0000000000000000 .hidden newsym
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 l .text 0000000000000000 .hidden newsym
37 # RELATIVE: 0000000000201127 g .text 0000000000000000 _end
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 l .text 0000000000000000 .hidden newsym
43 # RELATIVE-ADD: 0000000000000007 l .text 0000000000000000 .hidden _end
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 l .text 0000000000000000 .hidden newsym
49 # RELATIVE-SUB: 0000000000000007 l .text 0000000000000000 .hidden _end
51 .global _start
52 _start:
53 lea newsym(%rip),%rax