File: wrap-drop-shared-original.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 (48 lines) | stat: -rw-r--r-- 1,912 bytes parent folder | download | duplicates (15)
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
## If the original of a wrapped symbol becomes unreferenced after wrapping, it
## should be dropped from the dynamic symbol table even if defined in a shared
## library.

# REQUIRES: x86

# RUN: rm -rf %t && split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/original.s -o %t/original.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/wrapped.s -o %t/wrapped.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-elf %t/ref.s -o %t/ref.o
# RUN: ld.lld -shared -o %t/liboriginal.so -soname liboriginal.so %t/original.o
# RUN: ld.lld -shared -o %t/liboriginal-and-wrapped.so \
# RUN:   -soname liboriginal-and-wrapped.so %t/original.o %t/wrapped.o
# RUN: ld.lld -shared -o %t/libref-with-original.so %t/ref.o \
# RUN:   --as-needed %t/liboriginal.so --wrap foo
# RUN: llvm-readelf --dynamic --dyn-syms %t/libref-with-original.so | \
# RUN:   FileCheck --check-prefix=ORIGINAL %s
# RUN: ld.lld -shared -o %t/libref-with-original-and-wrapped.so %t/ref.o \
# RUN:   --as-needed %t/liboriginal-and-wrapped.so --wrap foo
# RUN: llvm-readelf --dynamic --dyn-syms %t/libref-with-original-and-wrapped.so | \
# RUN:   FileCheck --check-prefix=ORIGINAL-AND-WRAPPED %s

# ORIGINAL-NOT: (NEEDED) Shared library: [liboriginal.so]
# ORIGINAL:      Symbol table '.dynsym' contains 3 entries:
# ORIGINAL:      NOTYPE  LOCAL  DEFAULT   UND
# ORIGINAL-NEXT: NOTYPE  GLOBAL DEFAULT   UND __wrap_foo
# ORIGINAL-NEXT: NOTYPE  GLOBAL DEFAULT     6 ref

# ORIGINAL-AND-WRAPPED: (NEEDED) Shared library: [liboriginal-and-wrapped.so]
# ORIGINAL-AND-WRAPPED:      Symbol table '.dynsym' contains 3 entries:
# ORIGINAL-AND-WRAPPED:      NOTYPE  LOCAL  DEFAULT   UND
# ORIGINAL-AND-WRAPPED-NEXT: NOTYPE  GLOBAL DEFAULT   UND __wrap_foo
# ORIGINAL-AND-WRAPPED-NEXT: NOTYPE  GLOBAL DEFAULT     6 ref

#--- original.s
.globl foo
foo:
	retq

#--- wrapped.s
.globl __wrap_foo
__wrap_foo:
	retq

#--- ref.s
.globl ref
ref:
	jmp	foo@plt