[PATCH] D101384: [llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 27 11:08:53 PDT 2021
alexshap created this revision.
alexshap added reviewers: MaskRay, ellis, smeenai.
alexshap created this object with visibility "All Users".
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a subscriber: abrachet.
alexshap requested review of this revision.
Herald added a project: LLVM.
Add support for LC_THREAD/LC_UNIXTHREAD (these load commands can be copied over without any modifications).
Test plan: make check-all
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101384
Files:
llvm/test/tools/llvm-objcopy/MachO/lc-thread.test
llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
Index: llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -371,6 +371,8 @@
case MachO::LC_LOAD_WEAK_DYLIB:
case MachO::LC_UUID:
case MachO::LC_SOURCE_VERSION:
+ case MachO::LC_THREAD:
+ case MachO::LC_UNIXTHREAD:
// Nothing to update.
break;
default:
Index: llvm/test/tools/llvm-objcopy/MachO/lc-thread.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/MachO/lc-thread.test
@@ -0,0 +1,79 @@
+## This test verifies that the load commands LC_THREAD/LC_UNIXTHREAD
+## are copied correctly.
+
+# RUN: rm -rf %t
+# RUN: split-file %s %t
+
+# RUN: yaml2obj %t/lc_thread.yaml -o %t/lc_thread.exe
+# RUN: llvm-objcopy %t/lc_thread.exe %t/lc_thread.exe.copy
+# RUN: cmp %t/lc_thread.exe %t/lc_thread.exe.copy
+
+# RUN: yaml2obj %t/lc_unixthread.yaml -o %t/lc_unixthread.exe
+# RUN: llvm-objcopy %t/lc_unixthread.exe %t/lc_unixthread.exe.copy
+# RUN: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, 0x0, 0x5C, 0xB, 0x0, 0x0,
+ 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101384.340923.patch
Type: text/x-patch
Size: 4488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/10736de5/attachment.bin>
More information about the llvm-commits
mailing list