Skip to content

Commit 6b64899

Browse files
committed
[lldb] Objective-C runtime: Work around a bug in the shared cache builder (llvm#130209)
where it can overflow a 2GB offset by just a little bit by applying a heuristic. rdar://145888306 (cherry picked from commit ca0850f)
1 parent b3bb7aa commit 6b64899

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)