Bug 681203 - Bind all symbols when dynamic symbol lookup is not supported. r=mwu
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 23 Aug 2011 16:12:44 +0200
changeset 75741 93e8590445364cc0a5710e276912aa55b8a938e4
parent 75740 4ec64d3561f0edf1a33c5e9e7f2009721f0e1027
child 75742 5847fed3426746e8692fdf4221acbd0917237d42
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmwu
bugs681203
milestone9.0a1
Bug 681203 - Bind all symbols when dynamic symbol lookup is not supported. r=mwu
other-licenses/android/linker.c
--- a/other-licenses/android/linker.c
+++ b/other-licenses/android/linker.c
@@ -1949,19 +1949,23 @@ static unsigned int plt_reloc(soinfo *si
     "mov ip, r0\n"
     /* Restore r0-r3 to be used as arguments when calling the resolved
      * function, r4 which we saved to realign the stack and lr which
      * was saved by the plt trampoline. */
     "ldmia sp!, {r0-r4,lr}\n"
     /* Jump to the resolved function. */
     "bx ip\n"
 );
+#else
+#define ANDROID_NO_RUNTIME_RELOC
 #endif
 
+#ifndef ANDROID_NO_RUNTIME_RELOC
 static void runtime_reloc() __attribute__((used));
+#endif
 
 static int link_image(soinfo *si, unsigned wr_offset)
 {
     unsigned *d;
     Elf32_Phdr *phdr = si->phdr;
     int phnum = si->phnum;
 
     INFO("[ %5d linking %s ]\n", pid, si->name);
@@ -2196,39 +2200,51 @@ static int link_image(soinfo *si, unsign
                later on when we resolve relocations, trying to look up a symgol
                with dlsym().
             */
             d[1] = (unsigned)lsi;
             lsi->refcount++;
         }
     }
 
+#ifndef ANDROID_NO_RUNTIME_RELOC
     /* Initialize GOT[1] and GOT[2], which are used by the PLT trampoline */
     Elf32_Addr *got = (Elf32_Addr *)si->plt_got;
     got[1] = (Elf32_Addr) si;
     got[2] = (Elf32_Addr) runtime_reloc;
+#endif
 
     if(si->plt_rel) {
         DEBUG("[ %5d relocating %s plt ]\n", pid, si->name );
+#ifdef ANDROID_NO_RUNTIME_RELOC
+        if(reloc_library(si, si->plt_rel, si->plt_rel_count))
+            goto fail;
+#else
         /* Relocate PLT GOT */
         for (d = got + 3; d < got + 3 + si->plt_rel_count; d++)
             *d += si->base;
+#endif
     }
     if(si->rel) {
         DEBUG("[ %5d relocating %s ]\n", pid, si->name );
         if(reloc_library(si, si->rel, si->rel_count))
             goto fail;
     }
 
 #ifdef ANDROID_SH_LINKER
     if(si->plt_rela) {
         DEBUG("[ %5d relocating %s plt ]\n", pid, si->name );
+#ifdef ANDROID_NO_RUNTIME_RELOC
+        if(reloc_library_a(si, si->plt_rela, si->plt_rela_count))
+            goto fail;
+#else
         /* Relocate PLT GOT */
         for (d = got + 3; d < got + 3 + si->plt_rela_count; d++)
             *d += si->base;
+#endif
     }
     if(si->rela) {
         DEBUG("[ %5d relocating %s ]\n", pid, si->name );
         if(reloc_library_a(si, si->rela, si->rela_count))
             goto fail;
     }
 #endif /* ANDROID_SH_LINKER */