xref: /llvm-project-15.0.7/lld/test/ELF/wrap-defined.s (revision d24b94f0)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2
3# RUN: rm -rf %t && split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t/main.o
5# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/wrap.s -o %t/wrap.o
6# RUN: ld.lld -shared --soname=fixed %t/wrap.o -o %t/wrap.so
7
8## GNU ld does not wrap a defined symbol in an object file
9## https://sourceware.org/bugzilla/show_bug.cgi?id=26358
10## We choose to wrap defined symbols so that LTO, non-LTO and relocatable links
11## behave the same. The 'call bar' in main.o will reference __wrap_bar. We cannot
12## easily distinguish the case from cases where bar is not referenced, so we
13## export __wrap_bar whenever bar is defined, regardless of whether it is indeed
14## referenced.
15
16# RUN: ld.lld -shared %t/main.o --wrap bar -o %t1.so
17# RUN: llvm-objdump -d %t1.so | FileCheck %s
18# RUN: ld.lld %t/main.o %t/wrap.so --wrap bar -o %t1
19# RUN: llvm-objdump -d %t1 | FileCheck %s
20
21# CHECK:      <_start>:
22# CHECK-NEXT:   callq {{.*}} <__wrap_bar@plt>
23
24#--- main.s
25.globl _start, bar
26_start:
27  call bar
28bar:
29
30#--- wrap.s
31.globl __wrap_bar
32__wrap_bar:
33  retq
34

served by {OpenGrok

Last Index Update: Fri May 15 20:09:11 GMT 2026