[Lldb-commits] [PATCH] D100164: Don't treat corefile binaries like dylibs in the shared cache, even if they say they are

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 9 00:16:21 PDT 2021


jasonmolenda created this revision.
jasonmolenda added a reviewer: friss.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

There is a corefile writer that is including uninitialized data in the Mach-O header 'flags' field. I'll work with them to fix that, but it only causes a problem in one part of lldb today, in ObjectFileMachO::SanitizeSegmentCommand where there is code that is trying to detect an LC_SEGMENT in a binary in the shared cache.  The shared cache flag bit is set in this corefile, so we adjust the offsets and the corefile parsing fails big time.

lldb doesn't make a lot of decisions based on the mach header flags field, and even fewer of them when dealing with corefiles, so to handle these corefiles that are floating around, I'd like to add a guard to the code to explicitly opt out when working on a corefile, to work around this.

Fred, this is an edit to your change from last summer in  https://reviews.llvm.org/D83023 .  Are you OK with this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100164

Files:
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1330,7 +1330,8 @@
   if (m_length == 0 || seg_cmd.filesize == 0)
     return;
 
-  if ((m_header.flags & MH_DYLIB_IN_CACHE) && !IsInMemory()) {
+  if (m_header.filetype != MH_CORE && (m_header.flags & MH_DYLIB_IN_CACHE) &&
+      !IsInMemory()) {
     // In shared cache images, the load commands are relative to the
     // shared cache file, and not the the specific image we are
     // examining. Let's fix this up so that it looks like a normal


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100164.336326.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210409/c11f8b4e/attachment.bin>


More information about the lldb-commits mailing list