Skip to content
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

[NativeAOT] Implement thunk page generation and mapping for iOS-like platforms #82317

Merged
merged 4 commits into from
Feb 25, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Reimplement PalAllocateThunksFromTemplate to work inside shared libra…
…ries
filipnavara committed Feb 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 49fb9f7ec339084a2b2ca8d6473e34ff6f4722f8
18 changes: 11 additions & 7 deletions src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp
Original file line number Diff line number Diff line change
@@ -503,12 +503,15 @@ REDHAWK_PALEXPORT UInt32_BOOL REDHAWK_PALAPI PalAllocateThunksFromTemplate(HANDL
{
#ifdef TARGET_APPLE
int f;
char *exepath;
Dl_info info;

int st = dladdr((const void*)hTemplateModule, &info);
if (st == 0)
{
return UInt32_FALSE;
}

// NOTE: We ignore hTemplateModule, it is always the current module
exepath = minipal_getexepath();
f = open(exepath, O_RDONLY);
free(exepath);
f = open(info.dli_fname, O_RDONLY);
if (f < 0)
{
return UInt32_FALSE;
@@ -519,8 +522,9 @@ REDHAWK_PALEXPORT UInt32_BOOL REDHAWK_PALAPI PalAllocateThunksFromTemplate(HANDL
// executable and determine the size from them.
if (thunks_section == NULL)
{
thunks_section = getsectbyname("__THUNKS", "__thunks");
thunks_data_section = getsectbyname("__THUNKS_DATA", "__thunks");
const struct mach_header_64 *hdr = (const struct mach_header_64 *)hTemplateModule;
thunks_section = getsectbynamefromheader_64(hdr, "__THUNKS", "__thunks");
thunks_data_section = getsectbynamefromheader_64(hdr, "__THUNKS_DATA", "__thunks");
}

*newThunksOut = mmap(