runtime_loader: accept type STT_FUNC when STT_OBJECT is requested
trying to load a PIE executable produced by golang show the following (for pthread_create)
12: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND pthread_create
12655: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND pthread_create
It's the same for Linux or Solaris, so I suppose we're being too picky.
Change-Id: Ibe817c231365aba8b2eb88eb3f556d2bd1db384a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5392
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
@@ -127,7 +127,7 @@ find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo, bool allowLocal)
|
|||||||
uint32 type = symbol->Type();
|
uint32 type = symbol->Type();
|
||||||
if ((lookupInfo.type == B_SYMBOL_TYPE_TEXT && type != STT_FUNC)
|
if ((lookupInfo.type == B_SYMBOL_TYPE_TEXT && type != STT_FUNC)
|
||||||
|| (lookupInfo.type == B_SYMBOL_TYPE_DATA
|
|| (lookupInfo.type == B_SYMBOL_TYPE_DATA
|
||||||
&& type != STT_OBJECT)) {
|
&& type != STT_OBJECT && type != STT_FUNC)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,8 +495,6 @@ resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym,
|
|||||||
int32 type = B_SYMBOL_TYPE_ANY;
|
int32 type = B_SYMBOL_TYPE_ANY;
|
||||||
if (sym->Type() == STT_FUNC)
|
if (sym->Type() == STT_FUNC)
|
||||||
type = B_SYMBOL_TYPE_TEXT;
|
type = B_SYMBOL_TYPE_TEXT;
|
||||||
else if (sym->Type() == STT_OBJECT)
|
|
||||||
type = B_SYMBOL_TYPE_DATA;
|
|
||||||
|
|
||||||
if (sym->Bind() == STB_LOCAL) {
|
if (sym->Bind() == STB_LOCAL) {
|
||||||
// Local symbols references are always resolved to the given symbol.
|
// Local symbols references are always resolved to the given symbol.
|
||||||
@@ -537,8 +535,9 @@ resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym,
|
|||||||
sharedImage = NULL;
|
sharedImage = NULL;
|
||||||
}
|
}
|
||||||
} else if (sym->Type() != STT_NOTYPE
|
} else if (sym->Type() != STT_NOTYPE
|
||||||
&& sym->Type() != sharedSym->Type()) {
|
&& sym->Type() != sharedSym->Type()
|
||||||
// symbol not of the requested type
|
&& (sym->Type() != STT_OBJECT || sharedSym->Type() != STT_FUNC)) {
|
||||||
|
// symbol not of the requested type, except object which can match function
|
||||||
lookupError = ERROR_WRONG_TYPE;
|
lookupError = ERROR_WRONG_TYPE;
|
||||||
sharedImage = NULL;
|
sharedImage = NULL;
|
||||||
} else if (sharedSym->Bind() != STB_GLOBAL
|
} else if (sharedSym->Bind() != STB_GLOBAL
|
||||||
|
|||||||
Reference in New Issue
Block a user