Merge "Fix mips build"

This commit is contained in:
Dmitriy Ivanov 2014-11-13 03:36:54 +00:00 committed by Gerrit Code Review
commit 38b47f6eb4
2 changed files with 15 additions and 12 deletions

View File

@ -1721,21 +1721,20 @@ int soinfo::Relocate(ElfW(Rel)* rel, unsigned count, const soinfo_list_t& global
#endif #endif
#if defined(__mips__) #if defined(__mips__)
static bool mips_relocate_got(soinfo* si, const soinfo::soinfo_list_t& global_group, const soinfo::soinfo_list_t& local_group) { bool soinfo::mips_relocate_got(const soinfo_list_t& global_group, const soinfo_list_t& local_group) {
ElfW(Addr)** got = si->plt_got; ElfW(Addr)** got = plt_got;
if (got == nullptr) { if (got == nullptr) {
return true; return true;
} }
unsigned local_gotno = si->mips_local_gotno; unsigned local_gotno = mips_local_gotno;
unsigned gotsym = si->mips_gotsym; unsigned gotsym = mips_gotsym;
unsigned symtabno = si->mips_symtabno; unsigned symtabno = mips_symtabno;
ElfW(Sym)* symtab = si->symtab;
// got[0] is the address of the lazy resolver function. // got[0] is the address of the lazy resolver function.
// got[1] may be used for a GNU extension. // got[1] may be used for a GNU extension.
// Set it to a recognizable address in case someone calls it (should be _rtld_bind_start). // Set it to a recognizable address in case someone calls it (should be _rtld_bind_start).
// FIXME: maybe this should be in a separate routine? // FIXME: maybe this should be in a separate routine?
if ((si->flags & FLAG_LINKER) == 0) { if ((flags & FLAG_LINKER) == 0) {
size_t g = 0; size_t g = 0;
got[g++] = reinterpret_cast<ElfW(Addr)*>(0xdeadbeef); got[g++] = reinterpret_cast<ElfW(Addr)*>(0xdeadbeef);
if (reinterpret_cast<intptr_t>(got[g]) < 0) { if (reinterpret_cast<intptr_t>(got[g]) < 0) {
@ -1743,18 +1742,18 @@ static bool mips_relocate_got(soinfo* si, const soinfo::soinfo_list_t& global_gr
} }
// Relocate the local GOT entries. // Relocate the local GOT entries.
for (; g < local_gotno; g++) { for (; g < local_gotno; g++) {
got[g] = reinterpret_cast<ElfW(Addr)*>(reinterpret_cast<uintptr_t>(got[g]) + si->load_bias); got[g] = reinterpret_cast<ElfW(Addr)*>(reinterpret_cast<uintptr_t>(got[g]) + load_bias);
} }
} }
// Now for the global GOT entries... // Now for the global GOT entries...
ElfW(Sym)* sym = symtab + gotsym; ElfW(Sym)* sym = symtab + gotsym;
got = si->plt_got + local_gotno; got = plt_got + local_gotno;
for (size_t g = gotsym; g < symtabno; g++, sym++, got++) { for (size_t g = gotsym; g < symtabno; g++, sym++, got++) {
// This is an undefined reference... try to locate it. // This is an undefined reference... try to locate it.
const char* sym_name = si->get_string(sym->st_name); const char* sym_name = get_string(sym->st_name);
soinfo* lsi = nullptr; soinfo* lsi = nullptr;
ElfW(Sym)* s = soinfo_do_lookup(si, sym_name, &lsi, global_group, local_group); ElfW(Sym)* s = soinfo_do_lookup(this, sym_name, &lsi, global_group, local_group);
if (s == nullptr) { if (s == nullptr) {
// We only allow an undefined symbol if this is a weak reference. // We only allow an undefined symbol if this is a weak reference.
s = &symtab[g]; s = &symtab[g];
@ -2441,7 +2440,7 @@ bool soinfo::LinkImage(const soinfo_list_t& global_group, const soinfo_list_t& l
#endif #endif
#if defined(__mips__) #if defined(__mips__)
if (!mips_relocate_got(this, global_group, local_group)) { if (!mips_relocate_got(global_group, local_group)) {
return false; return false;
} }
#endif #endif

View File

@ -209,9 +209,13 @@ struct soinfo {
uint32_t* ARM_exidx; uint32_t* ARM_exidx;
size_t ARM_exidx_count; size_t ARM_exidx_count;
#elif defined(__mips__) #elif defined(__mips__)
private:
uint32_t mips_symtabno; uint32_t mips_symtabno;
uint32_t mips_local_gotno; uint32_t mips_local_gotno;
uint32_t mips_gotsym; uint32_t mips_gotsym;
bool mips_relocate_got(const soinfo_list_t& global_group, const soinfo_list_t& local_group);
public:
#endif #endif
size_t ref_count; size_t ref_count;