1# REQUIRES: x86-registered-target
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t
4
5## A non-existent symbol does not error.
6# RUN: llvm-objcopy --redefine-sym _func=_cnuf1234 --redefine-sym _foo=_ba --redefine-sym=_notexist= %t %t2 2>&1 | count 0
7# RUN: llvm-readobj --symbols %t2 | FileCheck %s
8
9# RUN: echo '_func _cnuf1234 #rename func' > %t.rename.txt
10# RUN: echo '  _foo _ba ' >> %t.rename.txt
11# RUN: echo '_notexist _notexist' >> %t.rename.txt
12# RUN: llvm-objcopy --redefine-syms %t.rename.txt %t %t3 2>&1 | count 0
13# RUN: cmp %t2 %t3
14
15# CHECK:      Symbol {
16# CHECK-NEXT:   Name: _ba (1)
17# CHECK-NEXT:   Extern
18# CHECK-NEXT:   Type: Section (0xE)
19# CHECK-NEXT:   Section: __const (0x2)
20# CHECK-NEXT:   RefType: UndefinedNonLazy (0x0)
21# CHECK-NEXT:   Flags [ (0x0)
22# CHECK-NEXT:   ]
23# CHECK-NEXT:   Value: 0x0
24# CHECK-NEXT: }
25# CHECK-NEXT: Symbol {
26# CHECK-NEXT:   Name: _cnuf1234 (5)
27# CHECK-NEXT:   Extern
28# CHECK-NEXT:   Type: Section (0xE)
29# CHECK-NEXT:   Section: __text (0x1)
30# CHECK-NEXT:   RefType: UndefinedNonLazy (0x0)
31# CHECK-NEXT:   Flags [ (0x0)
32# CHECK-NEXT:   ]
33# CHECK-NEXT:   Value: 0x0
34# CHECK-NEXT: }
35
36## Check that --redefine-sym executes before --strip-symbol.
37# RUN: llvm-objcopy --strip-symbol _foo --redefine-sym _foo=_ba %t %t.notstripped
38# RUN: llvm-readobj --symbols %t.notstripped | FileCheck %s --check-prefix=NOTSTRIPPED
39# NOTSTRIPPED: Name: _ba
40# NOTSTRIPPED: Name: _func
41
42## FIXME: _ba should be stripped after --strip-symbol is implemented.
43# RUN: llvm-objcopy --strip-symbol _ba --redefine-sym _foo=_ba %t %t.noba
44# RUN: llvm-readobj --symbols %t.noba | FileCheck %s --check-prefix=NOTSTRIPPED
45
46.globl _func
47_func:
48
49.section __TEXT,__const
50.globl _foo
51_foo:
52