runtime_loader: dlsym(RTLD_NEXT) searches all regions for the caller address

clang/lld can put code in multiple regions.

Change-Id: I495e3f12105ef2e894809da7e4a91bac08a12fd6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8961
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
This commit is contained in:
Jérôme Duval
2025-02-10 07:37:47 +00:00
parent 7d6ff0554b
commit 146617c29b
+1 -10
View File
@@ -1006,16 +1006,7 @@ get_library_symbol(void* handle, void* caller, const char* symbolName,
// calling image. Return the next after the caller symbol.
// First of all, find the caller image.
image_t* callerImage = get_loaded_images().head;
for (; callerImage != NULL; callerImage = callerImage->next) {
elf_region_t& text = callerImage->regions[0];
if ((addr_t)caller >= text.vmstart
&& (addr_t)caller < text.vmstart + text.vmsize) {
// found the image
break;
}
}
image_t* callerImage = find_loaded_image_by_address((addr_t)caller);
if (callerImage != NULL) {
// found the caller -- now search the global scope until we find
// the next symbol