[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / version-script.s
blob52382eeb1245c46749d98cf4c8f059c1ba9677cf
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
4 # RUN: echo "bar = foo; VERSION { V { global: foo; bar; local: *; }; }" > %t.script
5 # RUN: ld.lld -T %t.script -shared --no-undefined-version %t.o -o %t.so
6 # RUN: llvm-readobj -V %t.so | FileCheck %s
8 # RUN: echo "SECTIONS { .text : { bar = foo; *(.text) } }" > %t.script
9 # RUN: echo "VERSION { V { global: foo; bar; local: *; }; }" >> %t.script
10 # RUN: ld.lld -T %t.script -shared --no-undefined-version %t.o -o %t.so
11 # RUN: llvm-readobj -V %t.so | FileCheck %s
13 ## Check that we are able to version symbols defined in script.
14 # CHECK: VersionSymbols [
15 # CHECK-NEXT: Symbol {
16 # CHECK-NEXT: Version: 0
17 # CHECK-NEXT: Name:
18 # CHECK-NEXT: }
19 # CHECK-NEXT: Symbol {
20 # CHECK-NEXT: Version: 1
21 # CHECK-NEXT: Name: und
22 # CHECK-NEXT: }
23 # CHECK-NEXT: Symbol {
24 # CHECK-NEXT: Version: 2
25 # CHECK-NEXT: Name: foo@@V
26 # CHECK-NEXT: }
27 # CHECK-NEXT: Symbol {
28 # CHECK-NEXT: Version: 2
29 # CHECK-NEXT: Name: bar@@V
30 # CHECK-NEXT: }
31 # CHECK-NEXT: ]
33 # RUN: echo "bar = und; VERSION { V { global: foo; bar; local: *; }; }" > %t.script
34 # RUN: not ld.lld -T %t.script -shared --no-undefined-version %t.o -o /dev/null \
35 # RUN: 2>&1 | FileCheck --check-prefix=ERR %s
36 # ERR: symbol not found: und
38 # RUN: echo "und = 0x1; VERSION { V { global: und; local: *; }; }" > %t.script
39 # RUN: ld.lld -T %t.script -shared --no-undefined-version %t.o -o %t.so
40 # RUN: llvm-readobj -V %t.so | FileCheck %s --check-prefix=UNDEF
41 # UNDEF: VersionSymbols [
42 # UNDEF-NEXT: Symbol {
43 # UNDEF-NEXT: Version: 0
44 # UNDEF-NEXT: Name:
45 # UNDEF-NEXT: }
46 # UNDEF-NEXT: Symbol {
47 # UNDEF-NEXT: Version: 2
48 # UNDEF-NEXT: Name: und@@V
49 # UNDEF-NEXT: }
50 # UNDEF-NEXT: ]
52 .global und
54 .text
55 .globl foo
56 .type foo,@function
57 foo: