Bug 1081034 part 3 - Resolve libc symbols with our linker. r=nfroyd

This allows to resolve weak symbols from some Android device's libc that
dlsym() won't. This is effectively an alternative fix to bug 791419, without
requiring wrapping symbols.
This commit is contained in:
Mike Hommey 2014-10-16 09:20:14 +09:00
parent 9c53800a82
commit eb75074fdb
2 changed files with 15 additions and 1 deletions

View File

@ -499,14 +499,20 @@ ElfLoader::Init()
if (dladdr(_DYNAMIC, &info) != 0) {
self_elf = LoadedElf::Create(info.dli_fname, info.dli_fbase);
}
#if defined(ANDROID)
if (dladdr(FunctionPtr(syscall), &info) != 0) {
libc = LoadedElf::Create(info.dli_fname, info.dli_fbase);
}
#endif
}
ElfLoader::~ElfLoader()
{
LibHandleList list;
/* Release self_elf */
/* Release self_elf and libc */
self_elf = nullptr;
libc = nullptr;
/* Build up a list of all library handles with direct (external) references.
* We actually skip system library handles because we want to keep at least

View File

@ -463,6 +463,14 @@ private:
* is used to resolve wrapped functions. */
mozilla::RefPtr<LibHandle> self_elf;
#if defined(ANDROID)
/* System loader handle for the libc. This is used to resolve weak symbols
* that some libcs contain that the Android linker won't dlsym(). Normally,
* we wouldn't treat non-Android differently, but glibc uses versioned
* symbols which this linker doesn't support. */
mozilla::RefPtr<LibHandle> libc;
#endif
/* Bookkeeping */
typedef std::vector<LibHandle *> LibHandleList;
LibHandleList handles;