1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3
4# Simple symbol assignment. Should raise conflict in case we
5# have duplicates in any input section, but currently simply
6# replaces the value.
7# RUN: echo "SECTIONS {.text : {*(.text.*)} text_end = .;}" > %t.script
8# RUN: ld.lld -o %t1 --script %t.script %t
9# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=SIMPLE %s
10# SIMPLE: .text  0000000000000000 text_end
11
12# The symbol is not referenced. Don't provide it.
13# RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > %t.script
14# RUN: ld.lld -o %t1 --script %t.script %t
15# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s
16# DONTPROVIDE-NOT: newsym
17
18# The symbol is not referenced. Don't provide it.
19# RUN: echo "SECTIONS { PROVIDE_HIDDEN(newsym = 1);}" > %t.script
20# RUN: ld.lld -o %t1 --script %t.script %t
21# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s
22
23# Provide existing symbol. The value should be 0, even though we
24# have value of 1 in PROVIDE()
25# RUN: echo "SECTIONS { PROVIDE(somesym = 1);}" > %t.script
26# RUN: ld.lld -o %t1 --script %t.script %t
27# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=PROVIDE2 %s
28# PROVIDE2: 0000000000000000 g       *ABS*  0000000000000000 somesym
29
30# Provide existing symbol. The value should be 0, even though we
31# have value of 1 in PROVIDE_HIDDEN(). Visibility should not change
32# RUN: echo "SECTIONS { PROVIDE_HIDDEN(somesym = 1);}" > %t.script
33# RUN: ld.lld -o %t1 --script %t.script %t
34# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN2 %s
35# HIDDEN2: 0000000000000000 g       *ABS*  0000000000000000 somesym
36
37# Hidden symbol assignment.
38# RUN: echo "SECTIONS { HIDDEN(newsym = 1);}" > %t.script
39# RUN: ld.lld -o %t1 --script %t.script %t
40# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN3 %s
41# HIDDEN3: 0000000000000001 l       *ABS*  0000000000000000 .hidden newsym
42
43# The symbol is not referenced. Don't provide it.
44# RUN: echo "PROVIDE(newsym = 1);" > %t.script
45# RUN: ld.lld -o %t1 --script %t.script %t
46# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s
47
48# The symbol is not referenced. Don't provide it.
49# RUN: echo "PROVIDE_HIDDEN(newsym = 1);" > %t.script
50# RUN: ld.lld -o %t1 --script %t.script %t
51# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s
52
53# Provide existing symbol. The value should be 0, even though we
54# have value of 1 in PROVIDE()
55# RUN: echo "PROVIDE(somesym = 1);" > %t.script
56# RUN: ld.lld -o %t1 --script %t.script %t
57# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=PROVIDE5 %s
58# PROVIDE5: 0000000000000000 g       *ABS*  0000000000000000 somesym
59
60# Provide existing symbol. The value should be 0, even though we
61# have value of 1 in PROVIDE_HIDDEN(). Visibility should not change
62# RUN: echo "PROVIDE_HIDDEN(somesym = 1);" > %t.script
63# RUN: ld.lld -o %t1 --script %t.script %t
64# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN5 %s
65# HIDDEN5: 0000000000000000 g       *ABS*  0000000000000000 somesym
66
67# Simple symbol assignment. All three symbols should have the
68# same value.
69# RUN: echo "foo = 0x100; SECTIONS { bar = foo; } baz = bar;" > %t.script
70# RUN: ld.lld -o %t1 --script %t.script %t
71# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=SIMPLE2 %s
72# SIMPLE2: 0000000000000100 g       *ABS*  0000000000000000 foo
73# SIMPLE2: 0000000000000100 g       *ABS*  0000000000000000 bar
74# SIMPLE2: 0000000000000100 g       *ABS*  0000000000000000 baz
75
76.global _start
77_start:
78 nop
79
80.global somesym
81somesym = 0
82