aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-objcopy/MachO/weaken.s
blob: 722d29fe497fecea6381121e5de106c838214dec (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# REQUIRES: x86-registered-target

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

# RUN: llvm-objcopy -W _func %t %t2
# RUN: llvm-readobj --symbols %t2 | FileCheck %s -check-prefix=CHECK-1

# CHECK-1:      Symbol {
# CHECK-1-NEXT:   Name: _foo (1)
# CHECK-1-NEXT:   Extern
# CHECK-1-NEXT:   Type: Section (0xE)
# CHECK-1-NEXT:   Section: __const (0x2)
# CHECK-1-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-1-NEXT:   Flags [ (0x0)
# CHECK-1-NEXT:   ]
# CHECK-1-NEXT:   Value: 0x0
# CHECK-1-NEXT: }
# CHECK-1-NEXT: Symbol {
# CHECK-1-NEXT:   Name: _func (6)
# CHECK-1-NEXT:   Extern
# CHECK-1-NEXT:   Type: Section (0xE)
# CHECK-1-NEXT:   Section: __text (0x1)
# CHECK-1-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-1-NEXT:   Flags [ (0x80)
# CHECK-1-NEXT:     WeakDef (0x80)
# CHECK-1-NEXT:   ]
# CHECK-1-NEXT:   Value: 0x0
# CHECK-1-NEXT: }

# RUN: echo _foo > %t.weaken.txt
# RUN: echo _func >> %t.weaken.txt
# RUN: llvm-objcopy --weaken-symbols %t.weaken.txt %t %t3
# RUN: llvm-readobj --symbols %t3 | FileCheck %s -check-prefix=CHECK-2

# CHECK-2:      Symbol {
# CHECK-2-NEXT:   Name: _foo (1)
# CHECK-2-NEXT:   Extern
# CHECK-2-NEXT:   Type: Section (0xE)
# CHECK-2-NEXT:   Section: __const (0x2)
# CHECK-2-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-2-NEXT:   Flags [ (0x80)
# CHECK-2-NEXT:     WeakDef (0x80)
# CHECK-2-NEXT:   ]
# CHECK-2-NEXT:   Value: 0x0
# CHECK-2-NEXT: }
# CHECK-2-NEXT: Symbol {
# CHECK-2-NEXT:   Name: _func (6)
# CHECK-2-NEXT:   Extern
# CHECK-2-NEXT:   Type: Section (0xE)
# CHECK-2-NEXT:   Section: __text (0x1)
# CHECK-2-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-2-NEXT:   Flags [ (0x80)
# CHECK-2-NEXT:     WeakDef (0x80)
# CHECK-2-NEXT:   ]
# CHECK-2-NEXT:   Value: 0x0
# CHECK-2-NEXT: }

## Verify --weaken-symbol plays nice with --redefine-sym.
# RUN: llvm-objcopy -W _foo --redefine-sym _foo=_bar %t %t4
# RUN: llvm-readobj --symbols %t4 | FileCheck %s -check-prefix=CHECK-3

# CHECK-3:      Symbol {
# CHECK-3-NEXT:   Name: _bar (1)
# CHECK-3-NEXT:   Extern
# CHECK-3-NEXT:   Type: Section (0xE)
# CHECK-3-NEXT:   Section: __const (0x2)
# CHECK-3-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-3-NEXT:   Flags [ (0x80)
# CHECK-3-NEXT:     WeakDef (0x80)
# CHECK-3-NEXT:   ]
# CHECK-3-NEXT:   Value: 0x0
# CHECK-3-NEXT: }
# CHECK-3-NEXT: Symbol {
# CHECK-3-NEXT:   Name: _func (6)
# CHECK-3-NEXT:   Extern
# CHECK-3-NEXT:   Type: Section (0xE)
# CHECK-3-NEXT:   Section: __text (0x1)
# CHECK-3-NEXT:   RefType: UndefinedNonLazy (0x0)
# CHECK-3-NEXT:   Flags [ (0x0)
# CHECK-3-NEXT:   ]
# CHECK-3-NEXT:   Value: 0x0
# CHECK-3-NEXT: }

.globl _func
_func:

.section __TEXT,__const
.globl _foo
_foo: