File: symbolreferenced.s

package info (click to toggle)
llvm-toolchain-18 1%3A18.1.8-18
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,908,340 kB
  • sloc: cpp: 6,667,937; ansic: 1,440,452; asm: 883,619; python: 230,549; objc: 76,880; f90: 74,238; lisp: 35,989; pascal: 16,571; sh: 10,229; perl: 7,459; ml: 5,047; awk: 3,523; makefile: 2,987; javascript: 2,149; xml: 892; fortran: 649; cs: 573
file content (54 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# REQUIRES: x86
# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o

# Provide new symbol. The value should be 1, like set in PROVIDE()
# RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > a1.t
# RUN: ld.lld -o a1 -T a1.t a.o
# RUN: llvm-objdump -t a1 | FileCheck --check-prefix=PROVIDE1 %s
# PROVIDE1: 0000000000000001 g       *ABS*  0000000000000000 newsym

# Provide new symbol (hidden). The value should be 1
# RUN: echo "SECTIONS { PROVIDE_HIDDEN(newsym = 1);}" > a2.t
# RUN: ld.lld -o a2 -T a2.t a.o
# RUN: llvm-objdump -t a2 | FileCheck --check-prefix=HIDDEN1 %s
# HIDDEN1: 0000000000000001 l       *ABS*  0000000000000000 .hidden newsym

# RUN: echo 'SECTIONS { PROVIDE_HIDDEN("newsym" = 1);}' > a2.t
# RUN: ld.lld -o a2 -T a2.t a.o
# RUN: llvm-objdump -t a2 | FileCheck --check-prefix=HIDDEN1 %s

# RUN: ld.lld -o chain -T chain.t a.o
# RUN: llvm-nm chain | FileCheck %s

# CHECK:      0000000000001000 a f1
# CHECK-NEXT: 0000000000001000 A f2
# CHECK-NEXT: 0000000000001000 a g1
# CHECK-NEXT: 0000000000001000 A g2
# CHECK-NEXT: 0000000000001000 A newsym

# RUN: not ld.lld -T chain2.t a.o 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
# ERR-COUNT-3: error: chain2.t:1: symbol not found: undef

#--- a.s
.global _start
_start:
 nop

.globl patatino
patatino:
  movl newsym, %eax

#--- chain.t
PROVIDE(f2 = 0x1000);
PROVIDE_HIDDEN(f1 = f2);
PROVIDE(newsym = f1);

PROVIDE(g2 = 0x1000);
PROVIDE_HIDDEN(g1 = g2);
PROVIDE(unused = g1);

#--- chain2.t
PROVIDE(f2 = undef);
PROVIDE_HIDDEN(f1 = f2);
PROVIDE(newsym = f1);