Skip to content

Commit 4035b73

Browse files
committed
[6.0][Runtime] Add weak check to use of _dyld_find_pointer_hash_table_entry.
Needed to avoid availability errors in some configurations. rdar://127621414 (cherry picked from commit ae71658)
1 parent a98b6e9 commit 4035b73

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

stdlib/public/runtime/LibPrespecialized.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,20 @@ getMetadataFromPointerKeyedMap(const LibPrespecializedState &state,
391391
const TypeContextDescriptor *description,
392392
const void *const *arguments) {
393393
#if DYLD_FIND_POINTER_HASH_TABLE_ENTRY_DEFINED
394-
auto *generics = description->getGenericContext();
395-
if (!generics)
396-
return nullptr;
394+
if (SWIFT_RUNTIME_WEAK_CHECK(_dyld_find_pointer_hash_table_entry)) {
395+
auto *generics = description->getGenericContext();
396+
if (!generics)
397+
return nullptr;
397398

398-
auto argumentCount = generics->getGenericContextHeader().NumKeyArguments;
399+
auto argumentCount = generics->getGenericContextHeader().NumKeyArguments;
399400

400-
auto *map = state.data->getPointerKeyedMetadataMap();
401-
auto result = _dyld_find_pointer_hash_table_entry(
402-
map, description, argumentCount, const_cast<const void **>(arguments));
403-
LOG("Looking up description %p in dyld table, found %p.", description,
404-
result);
405-
return reinterpret_cast<Metadata *>(const_cast<void *>(result));
401+
auto *map = state.data->getPointerKeyedMetadataMap();
402+
auto result = SWIFT_RUNTIME_WEAK_USE(_dyld_find_pointer_hash_table_entry(
403+
map, description, argumentCount, const_cast<const void **>(arguments)));
404+
LOG("Looking up description %p in dyld table, found %p.", description,
405+
result);
406+
return reinterpret_cast<Metadata *>(const_cast<void *>(result));
407+
}
406408
#else
407409
LOG("Looking up description %p but dyld hash table call not available.",
408410
description);

0 commit comments

Comments
 (0)