[PATCH] D91221: [MachO] Allow the LC_IDENT load command
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 17:03:56 PST 2020
vsk created this revision.
vsk added reviewers: JDevlieghere, lhames, jasonmolenda.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
vsk requested review of this revision.
xnu coredumps include an LC_IDENT load command. It's helpful to be able
to just ignore these. IIUC an interested client can grab the identifier
using the MachOObjectFile::load_commands() API.
The status quo is that llvm bails out when it finds an LC_IDENT because
the command is obsolete (see isLoadCommandObsolete).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91221
Files:
llvm/lib/Object/MachOObjectFile.cpp
llvm/test/ObjectYAML/MachO/lc-ident.yaml
Index: llvm/test/ObjectYAML/MachO/lc-ident.yaml
===================================================================
--- /dev/null
+++ llvm/test/ObjectYAML/MachO/lc-ident.yaml
@@ -0,0 +1,22 @@
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x80000003
+ filetype: 0x00000002
+ ncmds: 1
+ sizeofcmds: 16
+ flags: 0x00218085
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_IDENT
+ cmdsize: 16
+ PayloadBytes: [ 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 ]
+...
+
+# CHECK: LoadCommands:
+# CHECK-NEXT: - cmd: LC_IDENT
+# CHECK-NEXT: cmdsize: 16
+# CHECK-NEXT: PayloadBytes: [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 ]
Index: llvm/lib/Object/MachOObjectFile.cpp
===================================================================
--- llvm/lib/Object/MachOObjectFile.cpp
+++ llvm/lib/Object/MachOObjectFile.cpp
@@ -1596,6 +1596,9 @@
if ((Err = checkTwoLevelHintsCommand(*this, Load, I,
&TwoLevelHintsLoadCmd, Elements)))
return;
+ } else if (Load.C.cmd == MachO::LC_IDENT) {
+ // Note: LC_IDENT is ignored.
+ continue;
} else if (isLoadCommandObsolete(Load.C.cmd)) {
Err = malformedError("load command " + Twine(I) + " for cmd value of: " +
Twine(Load.C.cmd) + " is obsolete and not "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91221.304357.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201111/bd8b1166/attachment.bin>
More information about the llvm-commits
mailing list