File: weak-private-extern.s

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (40 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download | duplicates (22)
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
# REQUIRES: x86

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.o
# RUN: %lld -dylib %t.o -o %t.dylib -lSystem

# RUN: llvm-objdump --macho --bind --weak-bind %t.dylib | FileCheck %s
# CHECK-NOT: __got
# CHECK-NOT: __la_symbol_ptr

# RUN: llvm-objdump --macho --private-header %t.dylib | \
# RUN:     FileCheck --check-prefix=HEADERS %s
# HEADERS-NOT: WEAK_DEFINES
# HEADERS-NOT: BINDS_TO_WEAK

## Check that N_WEAK_DEF isn't set in the symbol table.
## This is different from ld64, which makes private extern weak symbols non-weak
## for binds and relocations, but it still marks them as weak in the symbol table.
## Since `nm -m` doesn't look at N_WEAK_DEF for N_PEXT symbols this is not
## observable via nm, but it feels slightly more correct.
## (It is observable in `llvm-objdump --syms` output.)
# RUN: llvm-readobj --syms %t.dylib | FileCheck --check-prefix=SYMS %s
# SYMS-NOT: WeakDef (0x80)

.globl _use
_use:
  mov _weak_private_extern_gotpcrel@GOTPCREL(%rip), %rax
  callq _weak_private_extern
  retq

.private_extern _weak_private_extern
.globl _weak_private_extern
.weak_definition _weak_private_extern
_weak_private_extern:
  retq

.private_extern _weak_private_extern_gotpcrel
.globl _weak_private_extern_gotpcrel
.weak_definition _weak_private_extern_gotpcrel
_weak_private_extern_gotpcrel:
  .quad 0x1234