Skip to content

Commit 0ffb249

Browse files
Merge pull request #10197 from adrian-prantl/145888306-6.1
[lldb] Objective-C runtime: Work around a bug in the shared cache bui…
2 parents e0a6ccb + 6b64899 commit 0ffb249

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,14 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
463463
464464
if (objc_opt->version == 16)
465465
{
466-
const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + objc_opt_v16->largeSharedCachesClassOffset);
466+
int32_t large_offset = objc_opt_v16->largeSharedCachesClassOffset;
467+
const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + large_offset);
468+
// Work around a bug in some version shared cache builder where the offset overflows 2GiB (rdar://146432183).
469+
uint32_t unsigned_offset = (uint32_t)large_offset;
470+
if (unsigned_offset > 0x7fffffff && unsigned_offset < 0x82000000) {
471+
clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + unsigned_offset);
472+
DEBUG_PRINTF("warning: applying largeSharedCachesClassOffset overflow workaround!\n");
473+
}
467474
const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
468475
469476
DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);

0 commit comments

Comments
 (0)