summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <alexshap@fb.com>2021-04-28 16:27:53 -0700
committerAlexander Shaposhnikov <alexshap@fb.com>2021-04-28 16:29:33 -0700
commit86f291ebb2dfc5a93e1ee83b2d5965dcfa5d8bb1 (patch)
tree844b9fab634a2511ebe047b2d6f4d02ea65a14b3
parent3d3782397a3f13970ead4b56cd404d0b20600497 (diff)
downloadllvm-86f291ebb2dfc5a93e1ee83b2d5965dcfa5d8bb1.tar.gz
[llvm-objcopy][MachO] Add support for LC_THREAD/LC_UNIXTHREAD
Add support for LC_THREAD/LC_UNIXTHREAD (these load commands can be copied over without any modifications). Test plan: make check-all Differential revision: https://reviews.llvm.org/D101384
-rw-r--r--llvm/test/tools/llvm-objcopy/MachO/lc-thread.test44
-rw-r--r--llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp2
2 files changed, 46 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-objcopy/MachO/lc-thread.test b/llvm/test/tools/llvm-objcopy/MachO/lc-thread.test
new file mode 100644
index 000000000000..5da0bd65d07e
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/MachO/lc-thread.test
@@ -0,0 +1,44 @@
+## This test verifies that the load commands LC_THREAD/LC_UNIXTHREAD
+## are copied correctly.
+
+# RUN: yaml2obj -D LC_NAME=LC_THREAD %s -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 -D LC_NAME=LC_UNIXTHREAD %s -o %t.lc_unixthread.exe
+# RUN: llvm-objcopy %t.lc_unixthread.exe %t.lc_unixthread.exe.copy
+# RUN: cmp %t.lc_unixthread.exe %t.lc_unixthread.exe.copy
+
+--- !mach-o
+IsLittleEndian: true
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x1000007
+ cpusubtype: 0x3
+ filetype: 0x2
+ ncmds: 1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
diff --git a/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp b/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
index 8e2bf36238ec..c6cbfee44e67 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -371,6 +371,8 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
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: