File: weaken.s

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (89 lines) | stat: -rw-r--r-- 2,673 bytes parent folder | download | duplicates (8)
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: