[llvm-objcopy][MachO] Ignore LC_LINKER_OPTION when redefining symbols
authorKeith Smiley <keithbsmiley@gmail.com>
Sat, 29 Jan 2022 04:06:51 +0000 (20:06 -0800)
committerKeith Smiley <keithbsmiley@gmail.com>
Mon, 31 Jan 2022 23:49:06 +0000 (15:49 -0800)
Previously you would get this error:

```
error: unsupported load command (cmd=0x2d)
```

If the binary you were redefining the symbols of contained a
LC_LINKER_OPTION load command. This command does not need to be changed
when redefining symbols so we can ignore it like many others.

Differential Revision: https://reviews.llvm.org/D118526

llvm/test/tools/llvm-objcopy/MachO/redefine-symbol.s
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

index 82d20ca..5919c93 100644 (file)
@@ -43,6 +43,7 @@
 # RUN: llvm-objcopy --strip-symbol _ba --redefine-sym _foo=_ba %t %t.noba
 # RUN: llvm-readobj --symbols %t.noba | FileCheck %s --check-prefix=NOTSTRIPPED
 
+.linker_option "-lc"
 .globl _func
 _func:
 
index 3cac774..6b731ab 100644 (file)
@@ -417,6 +417,7 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
     case MachO::LC_SUB_UMBRELLA:
     case MachO::LC_SUB_CLIENT:
     case MachO::LC_SUB_LIBRARY:
+    case MachO::LC_LINKER_OPTION:
       // Nothing to update.
       break;
     default: