[llvm-objcopy][MachO] Copy LC_LINKER_OPTIMIZATION_HINT
authorFangrui Song <i@maskray.me>
Wed, 16 Jun 2021 19:09:49 +0000 (12:09 -0700)
committerFangrui Song <i@maskray.me>
Wed, 16 Jun 2021 19:09:50 +0000 (12:09 -0700)
This fixes `error: unsupported load command (cmd=0x2e)`

llvm/test/tools/llvm-objcopy/MachO/basic-executable-copy.test
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

index ce176b6..0ec84f7 100644 (file)
@@ -169,6 +169,10 @@ LoadCommands:
   - cmd:             LC_SOURCE_VERSION
     cmdsize:         16
     version:         0
+  - cmd:             LC_LINKER_OPTIMIZATION_HINT
+    cmdsize:         16
+    dataoff:         0
+    datasize:        0
   - cmd:             LC_MAIN
     cmdsize:         24
     entryoff:        3984
index c6cbfee..c72600a 100644 (file)
@@ -356,6 +356,7 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
     // LC_ENCRYPT_INFO/LC_ENCRYPTION_INFO_64 need to be adjusted.
     case MachO::LC_ENCRYPTION_INFO:
     case MachO::LC_ENCRYPTION_INFO_64:
+    case MachO::LC_LINKER_OPTIMIZATION_HINT:
     case MachO::LC_LOAD_DYLINKER:
     case MachO::LC_MAIN:
     case MachO::LC_RPATH: