Merge "Make mips_relocate_got tolerate a missing got"

This commit is contained in:
Brian Carlstrom 2013-08-21 17:25:48 +00:00 committed by Gerrit Code Review
commit bb34907ff5

View File

@ -1085,17 +1085,15 @@ static int soinfo_relocate(soinfo* si, Elf32_Rel* rel, unsigned count,
} }
#ifdef ANDROID_MIPS_LINKER #ifdef ANDROID_MIPS_LINKER
static int mips_relocate_got(soinfo* si, soinfo* needed[]) { static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
unsigned *got; unsigned* got = si->plt_got;
unsigned local_gotno, gotsym, symtabno; if (got == NULL) {
Elf32_Sym *symtab, *sym; return true;
unsigned g; }
unsigned local_gotno = si->mips_local_gotno;
got = si->plt_got; unsigned gotsym = si->mips_gotsym;
local_gotno = si->mips_local_gotno; unsigned symtabno = si->mips_symtabno;
gotsym = si->mips_gotsym; Elf32_Sym* symtab = si->symtab;
symtabno = si->mips_symtabno;
symtab = si->symtab;
/* /*
* got[0] is address of lazy resolver function * got[0] is address of lazy resolver function
@ -1106,7 +1104,7 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
*/ */
if ((si->flags & FLAG_LINKER) == 0) { if ((si->flags & FLAG_LINKER) == 0) {
g = 0; size_t g = 0;
got[g++] = 0xdeadbeef; got[g++] = 0xdeadbeef;
if (got[g] & 0x80000000) { if (got[g] & 0x80000000) {
got[g++] = 0xdeadfeed; got[g++] = 0xdeadfeed;
@ -1120,9 +1118,9 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
} }
/* Now for the global GOT entries */ /* Now for the global GOT entries */
sym = symtab + gotsym; Elf32_Sym* sym = symtab + gotsym;
got = si->plt_got + local_gotno; got = si->plt_got + local_gotno;
for (g = gotsym; g < symtabno; g++, sym++, got++) { for (size_t g = gotsym; g < symtabno; g++, sym++, got++) {
const char* sym_name; const char* sym_name;
Elf32_Sym* s; Elf32_Sym* s;
soinfo* lsi; soinfo* lsi;
@ -1136,7 +1134,7 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
s = &symtab[g]; s = &symtab[g];
if (ELF32_ST_BIND(s->st_info) != STB_WEAK) { if (ELF32_ST_BIND(s->st_info) != STB_WEAK) {
DL_ERR("cannot locate \"%s\"...", sym_name); DL_ERR("cannot locate \"%s\"...", sym_name);
return -1; return false;
} }
*got = 0; *got = 0;
} }
@ -1148,7 +1146,7 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
*got = lsi->load_bias + s->st_value; *got = lsi->load_bias + s->st_value;
} }
} }
return 0; return true;
} }
#endif #endif
@ -1556,7 +1554,7 @@ static bool soinfo_link_image(soinfo* si) {
} }
#ifdef ANDROID_MIPS_LINKER #ifdef ANDROID_MIPS_LINKER
if (mips_relocate_got(si, needed)) { if (!mips_relocate_got(si, needed)) {
return false; return false;
} }
#endif #endif