[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / loadaddr.s
blob055b7422baeb55762aa53bbfb2c197dbca068694
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3 # RUN: echo "SECTIONS { \
4 # RUN: . = 0x1000; \
5 # RUN: .aaa : AT(0x2000) { *(.aaa) } \
6 # RUN: .bbb : { *(.bbb) } \
7 # RUN: .ccc : AT(0x3000) { *(.ccc) } \
8 # RUN: .ddd : AT(0x4000) { *(.ddd) } \
9 # RUN: .text : { *(.text) } \
10 # RUN: aaa_lma = LOADADDR(.aaa); \
11 # RUN: bbb_lma = LOADADDR(.bbb); \
12 # RUN: ccc_lma = LOADADDR(.ccc); \
13 # RUN: ddd_lma = LOADADDR(.ddd); \
14 # RUN: txt_lma = LOADADDR(.text); \
15 # RUN: }" > %t.script
16 # RUN: ld.lld %t --script %t.script -o %t2
17 # RUN: llvm-objdump -t %t2 | FileCheck %s
18 # RUN: echo "SECTIONS { v = LOADADDR(.zzz); }" > %t.script
19 # RUN: not ld.lld %t --script %t.script -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR %s
21 # CHECK: 0000000000002000 g *ABS* 0000000000000000 aaa_lma
22 # CHECK-NEXT: 0000000000002008 g *ABS* 0000000000000000 bbb_lma
23 # CHECK-NEXT: 0000000000003000 g *ABS* 0000000000000000 ccc_lma
24 # CHECK-NEXT: 0000000000004000 g *ABS* 0000000000000000 ddd_lma
25 # CHECK-NEXT: 0000000000004008 g *ABS* 0000000000000000 txt_lma
26 # ERROR: {{.*}}.script:1: undefined section .zzz
28 .global _start
29 _start:
30 nop
32 .section .aaa, "a"
33 .quad 0
35 .section .bbb, "a"
36 .quad 0
38 .section .ccc, "a"
39 .quad 0
41 .section .ddd, "a"
42 .quad 0