File: wrap-defined.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 (33 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (21)
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
# REQUIRES: x86

# RUN: rm -rf %t && split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t/main.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/wrap.s -o %t/wrap.o
# RUN: ld.lld -shared --soname=fixed %t/wrap.o -o %t/wrap.so

## GNU ld does not wrap a defined symbol in an object file
## https://sourceware.org/bugzilla/show_bug.cgi?id=26358
## We choose to wrap defined symbols so that LTO, non-LTO and relocatable links
## behave the same. The 'call bar' in main.o will reference __wrap_bar. We cannot
## easily distinguish the case from cases where bar is not referenced, so we
## export __wrap_bar whenever bar is defined, regardless of whether it is indeed
## referenced.

# RUN: ld.lld -shared %t/main.o --wrap bar -o %t1.so
# RUN: llvm-objdump -d %t1.so | FileCheck %s
# RUN: ld.lld %t/main.o %t/wrap.so --wrap bar -o %t1
# RUN: llvm-objdump -d %t1 | FileCheck %s

# CHECK:      <_start>:
# CHECK-NEXT:   callq {{.*}} <__wrap_bar@plt>

#--- main.s
.globl _start, bar
_start:
  call bar
bar:

#--- wrap.s
.globl __wrap_bar
__wrap_bar:
  retq