xref: /llvm-project/lld/test/MachO/weak-private-extern.s (revision 88b76cb130bb88bd20c9a07dc546f5a5efc3fc20)
1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.o
4# RUN: %lld -dylib %t.o -o %t.dylib -lSystem
5
6# RUN: llvm-objdump --macho --bind --weak-bind %t.dylib | FileCheck %s
7# CHECK-NOT: __got
8# CHECK-NOT: __la_symbol_ptr
9
10# RUN: llvm-objdump --macho --private-header %t.dylib | \
11# RUN:     FileCheck --check-prefix=HEADERS %s
12# HEADERS-NOT: WEAK_DEFINES
13# HEADERS-NOT: BINDS_TO_WEAK
14
15## Check that N_WEAK_DEF isn't set in the symbol table.
16## This is different from ld64, which makes private extern weak symbols non-weak
17## for binds and relocations, but it still marks them as weak in the symbol table.
18## Since `nm -m` doesn't look at N_WEAK_DEF for N_PEXT symbols this is not
19## observable via nm, but it feels slightly more correct.
20## (It is observable in `llvm-objdump --syms` output.)
21# RUN: llvm-readobj --syms %t.dylib | FileCheck --check-prefix=SYMS %s
22# SYMS-NOT: WeakDef (0x80)
23
24.globl _use
25_use:
26  mov _weak_private_extern_gotpcrel@GOTPCREL(%rip), %rax
27  callq _weak_private_extern
28  retq
29
30.private_extern _weak_private_extern
31.globl _weak_private_extern
32.weak_definition _weak_private_extern
33_weak_private_extern:
34  retq
35
36.private_extern _weak_private_extern_gotpcrel
37.globl _weak_private_extern_gotpcrel
38.weak_definition _weak_private_extern_gotpcrel
39_weak_private_extern_gotpcrel:
40  .quad 0x1234
41