aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2013-08-21 17:25:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-08-21 17:25:48 +0000
commitbb34907ff5f60cf1600e83ea1bb4a6c26da6854e (patch)
treee6e093bd601223a0b9bbcf5af8ca4a2be8623f81
parentc8039337e3ee608e23f8ca6e5ea123d938b08029 (diff)
parent87c358524e479235aa6241736d2ce325f89daafc (diff)
downloadbionic-bb34907ff5f60cf1600e83ea1bb4a6c26da6854e.tar.gz
Merge "Make mips_relocate_got tolerate a missing got"
-rw-r--r--linker/linker.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 386f6dcbd..623be29f3 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1085,17 +1085,15 @@ static int soinfo_relocate(soinfo* si, Elf32_Rel* rel, unsigned count,
}
#ifdef ANDROID_MIPS_LINKER
-static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
- unsigned *got;
- unsigned local_gotno, gotsym, symtabno;
- Elf32_Sym *symtab, *sym;
- unsigned g;
-
- got = si->plt_got;
- local_gotno = si->mips_local_gotno;
- gotsym = si->mips_gotsym;
- symtabno = si->mips_symtabno;
- symtab = si->symtab;
+static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
+ unsigned* got = si->plt_got;
+ if (got == NULL) {
+ return true;
+ }
+ unsigned local_gotno = si->mips_local_gotno;
+ unsigned gotsym = si->mips_gotsym;
+ unsigned symtabno = si->mips_symtabno;
+ Elf32_Sym* symtab = si->symtab;
/*
* 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) {
- g = 0;
+ size_t g = 0;
got[g++] = 0xdeadbeef;
if (got[g] & 0x80000000) {
got[g++] = 0xdeadfeed;
@@ -1120,9 +1118,9 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
}
/* Now for the global GOT entries */
- sym = symtab + gotsym;
+ Elf32_Sym* sym = symtab + gotsym;
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;
Elf32_Sym* s;
soinfo* lsi;
@@ -1136,7 +1134,7 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
s = &symtab[g];
if (ELF32_ST_BIND(s->st_info) != STB_WEAK) {
DL_ERR("cannot locate \"%s\"...", sym_name);
- return -1;
+ return false;
}
*got = 0;
}
@@ -1148,7 +1146,7 @@ static int mips_relocate_got(soinfo* si, soinfo* needed[]) {
*got = lsi->load_bias + s->st_value;
}
}
- return 0;
+ return true;
}
#endif
@@ -1556,7 +1554,7 @@ static bool soinfo_link_image(soinfo* si) {
}
#ifdef ANDROID_MIPS_LINKER
- if (mips_relocate_got(si, needed)) {
+ if (!mips_relocate_got(si, needed)) {
return false;
}
#endif