diff options
author | Jason Molenda <jmolenda@apple.com> | 2012-06-22 03:28:35 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2012-06-22 03:28:35 +0000 |
commit | f813086c8579472ca8d18af103c9c2d982139d0f (patch) | |
tree | b767116deaa38ee8ed772bb813677b34e094b3b3 /lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | |
parent | 321d41a8710e87616d72c83f07c6064e356b42ad (diff) | |
download | bcm5719-llvm-f813086c8579472ca8d18af103c9c2d982139d0f.tar.gz bcm5719-llvm-f813086c8579472ca8d18af103c9c2d982139d0f.zip |
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.
llvm-svn: 158962
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 60609d1fe54..afe897e86c3 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1494,7 +1494,6 @@ struct lldb_copy_dyld_cache_header uint64_t localSymbolsOffset; uint64_t localSymbolsSize; }; - struct lldb_copy_dyld_cache_local_symbols_info { uint32_t nlistOffset; @@ -1504,7 +1503,6 @@ struct lldb_copy_dyld_cache_local_symbols_info uint32_t entriesOffset; uint32_t entriesCount; }; - struct lldb_copy_dyld_cache_local_symbols_entry { uint32_t dylibOffset; @@ -1512,6 +1510,18 @@ struct lldb_copy_dyld_cache_local_symbols_entry 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry { 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 @@ struct lldb_copy_dyld_cache_local_symbols_entry 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); |