Skip to content

[6.0][Runtime] Add weak check to use of _dyld_find_pointer_hash_table_entry. #73787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions stdlib/public/runtime/LibPrespecialized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,20 @@ getMetadataFromPointerKeyedMap(const LibPrespecializedState &state,
const TypeContextDescriptor *description,
const void *const *arguments) {
#if DYLD_FIND_POINTER_HASH_TABLE_ENTRY_DEFINED
auto *generics = description->getGenericContext();
if (!generics)
return nullptr;
if (SWIFT_RUNTIME_WEAK_CHECK(_dyld_find_pointer_hash_table_entry)) {
auto *generics = description->getGenericContext();
if (!generics)
return nullptr;

auto argumentCount = generics->getGenericContextHeader().NumKeyArguments;
auto argumentCount = generics->getGenericContextHeader().NumKeyArguments;

auto *map = state.data->getPointerKeyedMetadataMap();
auto result = _dyld_find_pointer_hash_table_entry(
map, description, argumentCount, const_cast<const void **>(arguments));
LOG("Looking up description %p in dyld table, found %p.", description,
result);
return reinterpret_cast<Metadata *>(const_cast<void *>(result));
auto *map = state.data->getPointerKeyedMetadataMap();
auto result = SWIFT_RUNTIME_WEAK_USE(_dyld_find_pointer_hash_table_entry(
map, description, argumentCount, const_cast<const void **>(arguments)));
LOG("Looking up description %p in dyld table, found %p.", description,
result);
return reinterpret_cast<Metadata *>(const_cast<void *>(result));
}
#else
LOG("Looking up description %p but dyld hash table call not available.",
description);
Expand Down