[llvm] [objcopy] Implement --weaken, --weaken-symbol(s) flags for MachO Object Files (PR #70560)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 01:08:43 PDT 2023
================
@@ -0,0 +1,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.rename.txt
+# RUN: echo _func >> %t.rename.txt
+# RUN: llvm-objcopy --weaken-symbols %t.rename.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
----------------
jh7370 wrote:
```suggestion
## Verify --weaken-symbol plays nice with --redefine-sym.
```
https://github.com/llvm/llvm-project/pull/70560
More information about the llvm-commits
mailing list