[PATCH] D54233: [dsymutil] Copy the LC_BUILD_VERSION load command into the companion binary
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 8 08:57:40 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346412: [dsymutil] Copy the LC_BUILD_VERSION load command into the companion binary. (authored by adrian, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D54233?vs=173042&id=173178#toc
Repository:
rL LLVM
https://reviews.llvm.org/D54233
Files:
llvm/trunk/test/tools/dsymutil/Inputs/lc_build_version.x86_64
llvm/trunk/test/tools/dsymutil/X86/lc_build_version.test
llvm/trunk/tools/dsymutil/MachOUtils.cpp
Index: llvm/trunk/tools/dsymutil/MachOUtils.cpp
===================================================================
--- llvm/trunk/tools/dsymutil/MachOUtils.cpp
+++ llvm/trunk/tools/dsymutil/MachOUtils.cpp
@@ -368,27 +368,34 @@
bool Is64Bit = Writer.is64Bit();
MachO::symtab_command SymtabCmd = InputBinary.getSymtabLoadCommand();
- // Get UUID.
+ // Compute the number of load commands we will need.
+ unsigned LoadCommandSize = 0;
+ unsigned NumLoadCommands = 0;
+
+ // Get LC_UUID and LC_BUILD_VERSION.
MachO::uuid_command UUIDCmd;
+ MachO::build_version_command BuildVersionCmd;
memset(&UUIDCmd, 0, sizeof(UUIDCmd));
- UUIDCmd.cmd = MachO::LC_UUID;
- UUIDCmd.cmdsize = sizeof(MachO::uuid_command);
+ memset(&BuildVersionCmd, 0, sizeof(BuildVersionCmd));
for (auto &LCI : InputBinary.load_commands()) {
- if (LCI.C.cmd == MachO::LC_UUID) {
+ switch (LCI.C.cmd) {
+ case MachO::LC_UUID:
UUIDCmd = InputBinary.getUuidCommand(LCI);
+ ++NumLoadCommands;
+ LoadCommandSize += sizeof(MachO::uuid_command);
+ break;
+ case MachO::LC_BUILD_VERSION:
+ BuildVersionCmd = InputBinary.getBuildVersionLoadCommand(LCI);
+ ++NumLoadCommands;
+ LoadCommandSize += sizeof(MachO::build_version_command);
+ // LLDB doesn't care about the build tools for now.
+ BuildVersionCmd.ntools = 0;
+ break;
+ default:
break;
}
}
- // Compute the number of load commands we will need.
- unsigned LoadCommandSize = 0;
- unsigned NumLoadCommands = 0;
- // We will copy the UUID if there is one.
- if (UUIDCmd.cmd != 0) {
- ++NumLoadCommands;
- LoadCommandSize += sizeof(MachO::uuid_command);
- }
-
// If we have a valid symtab to copy, do it.
bool ShouldEmitSymtab =
isExecutable(InputBinary) && hasLinkEditSegment(InputBinary);
@@ -452,10 +459,18 @@
assert(OutFile.tell() == HeaderSize);
if (UUIDCmd.cmd != 0) {
Writer.W.write<uint32_t>(UUIDCmd.cmd);
- Writer.W.write<uint32_t>(UUIDCmd.cmdsize);
+ Writer.W.write<uint32_t>(sizeof(UUIDCmd));
OutFile.write(reinterpret_cast<const char *>(UUIDCmd.uuid), 16);
assert(OutFile.tell() == HeaderSize + sizeof(UUIDCmd));
}
+ if (BuildVersionCmd.cmd != 0) {
+ Writer.W.write<uint32_t>(BuildVersionCmd.cmd);
+ Writer.W.write<uint32_t>(sizeof(BuildVersionCmd));
+ Writer.W.write<uint32_t>(BuildVersionCmd.platform);
+ Writer.W.write<uint32_t>(BuildVersionCmd.minos);
+ Writer.W.write<uint32_t>(BuildVersionCmd.sdk);
+ Writer.W.write<uint32_t>(BuildVersionCmd.ntools);
+ }
assert(SymtabCmd.cmd && "No symbol table.");
uint64_t StringStart = SymtabStart + NumSyms * NListSize;
Index: llvm/trunk/test/tools/dsymutil/X86/lc_build_version.test
===================================================================
--- llvm/trunk/test/tools/dsymutil/X86/lc_build_version.test
+++ llvm/trunk/test/tools/dsymutil/X86/lc_build_version.test
@@ -0,0 +1,11 @@
+# RUN: dsymutil -f %p/../Inputs/lc_build_version.x86_64 -o - \
+# RUN: | obj2yaml | FileCheck %s
+
+CHECK: LoadCommands:
+CHECK: - cmd: LC_BUILD_VERSION
+CHECK-NEXT: cmdsize: 24
+CHECK-NEXT: platform: 1
+CHECK-NEXT: minos: 658944
+CHECK-NEXT: sdk: 658944
+CHECK-NEXT: ntools: 0
+CHECK-NEXT: - cmd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54233.173178.patch
Type: text/x-patch
Size: 3325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/9be9a0a1/attachment.bin>
More information about the llvm-commits
mailing list