Skip to content

Commit

Permalink
i#2154 Android64: Adjust loader to remove 'CURIOSITIES' (#7205)
Browse files Browse the repository at this point in the history
There was special handling for old Android behaviour where Android did
not map the whole file at once. This behaviour is not present in more
recent versions of Android, and the associated handling causes
'CURIOSITY'-ies on debug builds, which it was originally introduced to
prevent: #1860

These CURIOSITIES were caused by the delayed call to
os_module_update_dynamic_info() that only happened for Android.

Issues: #2154, #1860, #7125
  • Loading branch information
felixc-arm authored Jan 24, 2025
1 parent ea447bc commit bdeedf9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions core/lib/globals_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,12 @@ typedef struct _instr_t instr_t;
# define IF_NOT_ANDROID(x) x
#endif

#ifdef ANDROID32
# define IF_NOT_ANDROID32(x)
#else
# define IF_NOT_ANDROID32(x) x
#endif

#ifdef X64
# define IF_X64(x) x
# define IF_X64_ELSE(x, y) x
Expand Down
11 changes: 8 additions & 3 deletions core/unix/module_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,15 @@ module_walk_program_headers(app_pc base, size_t view_size, bool at_map, bool dyn
LOG(GLOBAL, LOG_INTERP | LOG_VMAREAS, 2,
"%s " PFX ": %s dynamic info\n", __FUNCTION__, base,
out_data->have_dynamic_info ? "have" : "no");
/* i#1860: on Android a later os_module_update_dynamic_info() will
* fill in info once .dynamic is mapped in.
/* i#1860: on 32-bit Android a later
* os_module_update_dynamic_info() will fill in info
* once .dynamic is mapped in.
* i#7215: This is not needed on newer versions of 64-bit
* Android, however we are not able to test with newer
* versions of 32-bit Android, so this may still be
* required.
*/
IF_NOT_ANDROID(ASSERT(out_data->have_dynamic_info));
IF_NOT_ANDROID32(ASSERT(out_data->have_dynamic_info));
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion core/unix/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -8482,9 +8482,12 @@ mmap_check_for_module_overlap(app_pc base, size_t size, bool readable, uint64 in
});
}
os_get_module_info_unlock();
#ifdef ANDROID
#ifdef ANDROID32
/* i#1860: we need to keep looking for the segment with .dynamic as Android's
* loader does not map the whole file up front.
* i#7215: This is not needed on newer versions of 64-bit Android, however we
* are not able to test with newer versions of 32-bit Android, so this may
* still be required.
*/
if (ma != NULL && at_map && readable)
os_module_update_dynamic_info(base, size, at_map);
Expand Down

0 comments on commit bdeedf9

Please sign in to comment.