ldso: check binary pointer before lookup

Check if the binary pointer is valid before attempting to lookup the
symbol. Shared objects with unresolved symbols and missing depencies,
e.g a library that references 'errno' but is not linked against libc,
will now produce an error message when they are loaded by the dynamic
linker.

Fixes #1904.
This commit is contained in:
Josef Söntgen 2016-03-08 16:39:15 +01:00 committed by Christian Helmuth
parent f46a504bb6
commit 2490e399dc
1 changed files with 8 additions and 2 deletions

View File

@ -484,8 +484,14 @@ Elf::Sym const *Linker::lookup_symbol(char const *name, Dependency const *dep,
}
/* try searching binary's dependencies */
if (!weak_symbol && dep->root && dep != binary->dep.head())
return lookup_symbol(name, binary->dep.head(), base, undef, other);
if (!weak_symbol && dep->root) {
if (binary && dep != binary->dep.head()) {
return lookup_symbol(name, binary->dep.head(), base, undef, other);
} else {
PERR("Could not lookup symbol \"%s\"", name);
throw Not_found();
}
}
if (dep->root && verbose_lookup)
PDBG("Return %p", weak_symbol);