[Lldb-commits] [lldb] r158962 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Jason Molenda
jmolenda at apple.com
Thu Jun 21 20:28:35 PDT 2012
Author: jmolenda
Date: Thu Jun 21 22:28:35 2012
New Revision: 158962
URL: http://llvm.org/viewvc/llvm-project?rev=158962&view=rev
Log:
Additional comment in ObjectFileMachO::ParseSymtab to explain
the layout of the dyld shared cache file and how we're stepping
through it; also use offsetof to find offsets of struct elements.
Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=158962&r1=158961&r2=158962&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Jun 21 22:28:35 2012
@@ -1494,7 +1494,6 @@
uint64_t localSymbolsOffset;
uint64_t localSymbolsSize;
};
-
struct lldb_copy_dyld_cache_local_symbols_info
{
uint32_t nlistOffset;
@@ -1504,7 +1503,6 @@
uint32_t entriesOffset;
uint32_t entriesCount;
};
-
struct lldb_copy_dyld_cache_local_symbols_entry
{
uint32_t dylibOffset;
@@ -1512,6 +1510,18 @@
uint32_t nlistCount;
};
+ /* The dyld_cache_header has a pointer to the dyld_cache_local_symbols_info structure (localSymbolsOffset).
+ The dyld_cache_local_symbols_info structure gives us three things:
+ 1. The start and count of the nlist records in the dyld_shared_cache file
+ 2. The start and size of the strings for these nlist records
+ 3. The start and count of dyld_cache_local_symbols_entry entries
+
+ There is one dyld_cache_local_symbols_entry per dylib/framework in the dyld shared cache.
+ The "dylibOffset" field is the Mach-O header of this dylib/framework in the dyld shared cache.
+ The dyld_cache_local_symbols_entry also lists the start of this dylib/framework's nlist records
+ and the count of how many nlist records there are for this dylib/framework.
+ */
+
// Process the dsc header to find the unmapped symbols
//
// Save some VM space, do not map the entire cache in one shot.
@@ -1520,9 +1530,7 @@
{
DataExtractor dsc_header_data(dsc_data_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize());
- struct lldb_copy_dyld_cache_header* dsc_header_dummy = NULL;
-
- uint32_t offset = sizeof(dsc_header_dummy->magic);
+ uint32_t offset = offsetof (struct lldb_copy_dyld_cache_header, mappingOffset);
uint32_t mappingOffset = dsc_header_data.GetU32(&offset);
// If the mappingOffset points to a location inside the header, we've
@@ -1530,7 +1538,7 @@
if (mappingOffset >= sizeof(struct lldb_copy_dyld_cache_header))
{
- offset = (uint32_t)(uintptr_t)&dsc_header_dummy->localSymbolsOffset;
+ offset = offsetof (struct lldb_copy_dyld_cache_header, localSymbolsOffset);
uint64_t localSymbolsOffset = dsc_header_data.GetU64(&offset);
uint64_t localSymbolsSize = dsc_header_data.GetU64(&offset);
More information about the lldb-commits
mailing list