File: force-load.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-- 2,678 bytes parent folder | download | duplicates (5)
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/archive-foo.s -o %t/archive-foo.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-baz.s -o %t/archive-baz.o
# RUN: llvm-ar rcs %t/foo.a %t/archive-foo.o
# RUN: llvm-ar rcs %t/baz.a %t/archive-baz.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o

# RUN: %lld -lSystem -force_load %t/foo.a %t/foo.o %t/test.o -o %t/test-force-load-first
# FORCE-LOAD-FIRST:  __TEXT,archive _foo
# RUN: llvm-objdump --syms %t/test-force-load-first | FileCheck %s --check-prefix=FORCE-LOAD-FIRST

# RUN: %lld %t/foo.o -lSystem -force_load %t/foo.a %t/test.o -o %t/test-force-load-second
# RUN: llvm-objdump --syms %t/test-force-load-second | FileCheck %s --check-prefix=FORCE-LOAD-SECOND
# FORCE-LOAD-SECOND: __TEXT,obj _foo

## If an archive has already been loaded w/o -force_load earlier in the command
## line, a later -force_load argument will not have an effect.
# RUN: %lld -lSystem %t/foo.a -force_load %t/foo.a %t/test.o -o %t/test-regular-then-force
# RUN: llvm-objdump --syms %t/test-regular-then-force | FileCheck %s --check-prefix=REGULAR-THEN-FORCE
# REGULAR-THEN-FORCE-NOT: _foo
## If the -force_load comes first, then the second load will just be a no-op.
# RUN: %lld -lSystem -force_load %t/foo.a %t/foo.a %t/test.o -o %t/test-force-then-regular
# RUN: llvm-objdump --syms %t/test-force-then-regular | FileCheck %s --check-prefix=FORCE-THEN-REGULAR
# FORCE-THEN-REGULAR: _foo

## Force-loading the same path twice is fine
# RUN: %lld -lSystem %t/foo.o -force_load %t/foo.a -force_load %t/foo.a %t/test.o -o /dev/null

## Note that we do not call realpath() before dedup'ing the force-load
## arguments, so this is an error.
# RUN: cd %t; not %lld -lSystem %t/foo.o -force_load %t/foo.a -force_load foo.a \
# RUN:   %t/test.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=DUP

# DUP: error: duplicate symbol: _bar

## Force-loading two different paths w/o conflicting symbols is fine
# RUN: %lld -lSystem -force_load %t/foo.a -force_load %t/baz.a %t/test.o -o %t/test-two-force-loads
# RUN: llvm-objdump --syms %t/test-two-force-loads | FileCheck %s --check-prefix=TWICE
# TWICE-DAG: __TEXT,archive _foo
# TWICE-DAG: __TEXT,archive _bar
# TWICE-DAG: __TEXT,archive _baz

#--- archive-foo.s
.section __TEXT,archive
.globl _foo, _bar
.weak_definition _foo
_foo:
_bar:

#--- archive-baz.s
.section __TEXT,archive
.globl _baz
_baz:

#--- foo.s
.section __TEXT,obj
.globl _foo
.weak_definition _foo
_foo:

#--- test.s
.globl _main
_main:
  ret