File: provide-defined.s

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (60 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (6)
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
55
56
57
58
59
60
# REQUIRES: x86
## Test the GC behavior when the PROVIDE symbol is defined by a relocatable file.

# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
# RUN: llvm-as c.ll -o c.bc
# RUN: ld.lld -T a.t --gc-sections a.o b.o -o a
# RUN: llvm-readelf -s a | FileCheck %s

# RUN: ld.lld -T a.t -shared a.o b.o c.bc -o a.so
# RUN: llvm-readelf -s -r a.so | FileCheck %s --check-prefix=DSO

# CHECK:     1: {{.*}}               0 NOTYPE  GLOBAL DEFAULT     1 _start
# CHECK-NEXT:2: {{.*}}               0 NOTYPE  WEAK   DEFAULT     2 f3
# CHECK-NOT: {{.}}

# DSO:     .rela.plt
# DSO-NOT: f5
# DSO:     Symbol table '.dynsym'
# DSO-NOT: f5
# DSO:     Symbol table '.symtab'
# DSO:     {{.*}}               0 NOTYPE  LOCAL  HIDDEN  [[#]] f5

#--- a.s
.global _start, f1, f2, bar
.weak f3
_start:
  call f3

.section .text.f1,"ax"; f1:
.section .text.f2,"ax"; f2: # referenced by another relocatable file
.section .text.f3,"ax"; f3: # live
.section .text.bar,"ax"; bar:

.comm comm,4,4

#--- b.s
  call f2

#--- c.ll
target triple = "x86_64-unknown-linux-gnu"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

declare void @f5()

define void @f3() {
  call void @f5()
  ret void
}

#--- a.t
SECTIONS {
  . = . + SIZEOF_HEADERS;
  PROVIDE(f1 = bar+1);
  PROVIDE(f2 = bar+2);
  PROVIDE(f3 = bar+3);
  PROVIDE(f4 = comm+4);
  PROVIDE_HIDDEN(f5 = bar+5);
}