Browse Source

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.
devel
Josef Söntgen 7 years ago committed by Christian Helmuth
parent
commit
2490e399dc
  1. 10
      repos/base/src/lib/ldso/main.cc

10
repos/base/src/lib/ldso/main.cc

@ -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);

Loading…
Cancel
Save