Skip to content

Commit

Permalink
[mono] Mark AOT modules unusable if no AOT version is found (dotnet#1…
Browse files Browse the repository at this point in the history
…06026)

On Android, we might hit a collision where we instead of <libName>.dll.so try to load <libName>.so. By detecting this issue early we can mark the library as AOT unusable. We do this by checking if we were able to get the AOT file version and if not, we mark the .so file as unusable.
---------

Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
  • Loading branch information
matouskozak and lambdageek committed Aug 7, 2024
1 parent 4153092 commit af1b3b0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/mono/mono/mini/aot-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,15 +2102,13 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer
find_symbol (sofile, globals, "mono_aot_file_info", (gpointer*)&info);
}

// Copy aotid to MonoImage
memcpy(&assembly->image->aotid, info->aotid, 16);

if (version_symbol) {
/* Old file format */
version = atoi (version_symbol);
} else {
g_assert (info);
} else if (info) {
version = info->version;
} else {
version = -1;
}

if (version != MONO_AOT_FILE_VERSION) {
Expand All @@ -2120,6 +2118,11 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer
guint8 *blob;
void *handle;

g_assert (info);

// Copy aotid to MonoImage
memcpy(&assembly->image->aotid, info->aotid, 16);

if (info->flags & MONO_AOT_FILE_FLAG_SEPARATE_DATA) {
aot_data = open_aot_data (assembly, info, &handle);

Expand Down

0 comments on commit af1b3b0

Please sign in to comment.