File: archive.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (66 lines) | stat: -rw-r--r-- 1,877 bytes parent folder | download | duplicates (18)
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
61
62
63
64
65
66
# REQUIRES: x86
# RUN: rm -rf %t; split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o

# RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o
# RUN: %lld %t/main.o %t/test.a -o %t/test.out

## TODO: Run llvm-nm -p to validate symbol order
# RUN: llvm-nm %t/test.out | FileCheck %s
# CHECK: T _bar
# CHECK: T _boo
# CHECK: T _main

## Linking with the archive first in the command line shouldn't change anything
# RUN: %lld %t/test.a %t/main.o -o %t/test.out
# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
# ARCHIVE-FIRST: T _bar
# ARCHIVE-FIRST: T _boo
# ARCHIVE-FIRST: T _main

# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE
# VISIBLE-NOT: T _undefined
# VISIBLE-NOT: T _unused

# RUN: %lld %t/test.a %t/main.o -o %t/all-load -noall_load -all_load
# RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
# ALL-LOAD: T _bar
# ALL-LOAD: T _boo
# ALL-LOAD: T _main
# ALL-LOAD: T _unused

# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load -all_load -noall_load
# RUN: llvm-nm %t/no-all-load | FileCheck %s --check-prefix NO-ALL-LOAD
# RUN: %lld %t/test.a %t/main.o -o %t/no-all-load-only -noall_load
# RUN: llvm-nm %t/no-all-load-only | FileCheck %s --check-prefix NO-ALL-LOAD
# NO-ALL-LOAD-NOT: T _unused

## Multiple archives defining the same symbols aren't an issue, due to lazy
## loading
# RUN: cp %t/test.a %t/test2.a
# RUN: %lld %t/test.a %t/test2.a %t/main.o -o /dev/null

#--- 2.s
.globl _boo
_boo:
  ret

#--- 3.s
.globl _bar
_bar:
  ret

#--- 4.s
.globl _undefined, _unused
_unused:
  ret

#--- main.s
.globl _main
_main:
  callq _boo
  callq _bar
  ret