Revert "runtime_loader: allow the ABI version symbol to be local."

This reverts commit 61987fe7a2.

The original commit had a typo in it preventing this logic from
working (the "true" should be after the first ")".) It ultimately
doesn't seem to be needed, and just complicates the ELF lookup logic.

Change-Id: I23df8c86ad61cac4db45af2ae4ab69635a9e4a33
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7852
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-07-23 23:24:36 +00:00
committed by waddlesplash
parent 3d2ea73c7b
commit ac702ffd21
3 changed files with 6 additions and 16 deletions
@@ -216,9 +216,10 @@ analyze_image_haiku_version_and_abi(int fd, image_t* image, elf_ehdr& eheader,
// Haiku API version
elf_sym* symbol = find_symbol(image,
SymbolLookupInfo(B_SHARED_OBJECT_HAIKU_VERSION_VARIABLE_NAME,
B_SYMBOL_TYPE_DATA, true));
B_SYMBOL_TYPE_DATA));
if (symbol != NULL && symbol->st_shndx != SHN_UNDEF
&& symbol->st_value > 0
&& symbol->Type() == STT_OBJECT
&& symbol->st_size >= sizeof(uint32)) {
image->api_version
= *(uint32*)(symbol->st_value + image->regions[0].delta);
@@ -93,19 +93,8 @@ patch_undefined_symbol(image_t* rootImage, image_t* image, const char* name,
}
static bool
is_symbol_visible(elf_sym* symbol)
{
if (symbol->Bind() == STB_GLOBAL)
return true;
if (symbol->Bind() == STB_WEAK)
return true;
return false;
}
elf_sym*
find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo, bool allowLocal)
find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo)
{
if (image->dynamic_ptr == 0)
return NULL;
@@ -120,7 +109,8 @@ find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo, bool allowLocal)
elf_sym* symbol = &image->syms[i];
if (symbol->st_shndx != SHN_UNDEF
&& (allowLocal || is_symbol_visible(symbol))
&& ((symbol->Bind() == STB_GLOBAL)
|| (symbol->Bind() == STB_WEAK))
&& !strcmp(SYMNAME(image, symbol), lookupInfo.name)) {
// check if the type matches
@@ -132,8 +132,7 @@ void patch_undefined_symbol(image_t* rootImage, image_t* image,
const char* name, image_t** foundInImage, void** symbol,
int32* type);
elf_sym* find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo,
bool allowLocal = false);
elf_sym* find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo);
status_t find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo,
void** _location);
status_t find_symbol_breadth_first(image_t* image,