File: mh-header-link.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 (45 lines) | stat: -rw-r--r-- 1,404 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
# REQUIRES: x86

## This tests that we can link against these synthetic symbols even
## if they are not in the symbol table.

# RUN: rm -rf %t; split-file %s %t

## Test that in a dylib, we can link against __mh_dylib_header
## (but not in other types of files)

# RUN: llvm-mc %t/dylib.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/dylib.o
# RUN: %lld -dylib -dead_strip %t/dylib.o -o %t/dylib.out
# RUN: llvm-objdump -m --syms %t/dylib.out | FileCheck %s --check-prefix DYLIB

# RUN: not %lld -o /dev/null %t/dylib.o 2>&1 | FileCheck %s --check-prefix ERR-DYLIB

# DYLIB:      SYMBOL TABLE:
# DYLIB-NEXT: {{[0-9a-f]+}} g     F __TEXT,__text _main
# DYLIB-NEXT-EMPTY:
# ERR-DYLIB: error: undefined symbol: __mh_dylib_header

## Test that in an executable, we can link against __mh_execute_header
# RUN: llvm-mc %t/main.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/exec.o
# RUN: %lld -dead_strip -lSystem %t/exec.o -o %t/exec.out

## But it would be an error trying to reference __mh_execute_header in a dylib
# RUN: not %lld -o /dev/null -dylib %t/exec.o 2>&1 | FileCheck %s --check-prefix ERR-EXEC

# ERR-EXEC: error: undefined symbol: __mh_execute_header

#--- main.s
.text
.globl _main
_main:
 mov __mh_execute_header@GOTPCREL(%rip), %rax
 ret
.subsections_via_symbols

#--- dylib.s
.text
.globl _main
_main:
 mov __mh_dylib_header@GOTPCREL(%rip), %rax
 ret
.subsections_via_symbols