This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ARM dynamic loader fix for current GCC


The current ARM ld.so uses asm("r10") to find the PIC base, which
normally points at the beginning of the GOT.  But in GCC 4.2, Richard
Earnshaw rewrote the ARM PIC handling to use a pseudo-register instead
of a hard register for the PIC base.  This means it's prone to moving
around, and in fact it doesn't wind up in r10 for this function any
more.  So, load and relocate it ourselves like most other ports do.

-- 
Daniel Jacobowitz
CodeSourcery

2006-05-30  Daniel Jacobowitz  <dan@codesourcery.com>

	* sysdeps/arm/dl-machine.h (elf_machine_dynamic): Rewrite to load
	_GLOBAL_OFFSET_TABLE_ explicitly.

Index: glibc/ports/sysdeps/arm/dl-machine.h
===================================================================
--- glibc.orig/ports/sysdeps/arm/dl-machine.h	2006-05-26 16:06:15.000000000 -0400
+++ glibc/ports/sysdeps/arm/dl-machine.h	2006-05-26 16:48:08.000000000 -0400
@@ -46,13 +46,19 @@ elf_machine_matches_host (const Elf32_Eh
 
 
 /* Return the link-time address of _DYNAMIC.  Conveniently, this is the
-   first element of the GOT.  This must be inlined in a function which
-   uses global data.  */
+   first element of the GOT.  We used to use the PIC register to do this
+   without a constant pool reference, but GCC 4.2 will use a pseudo-register
+   for the PIC base, so it may not be in r10.  */
 static inline Elf32_Addr __attribute__ ((unused))
 elf_machine_dynamic (void)
 {
-  register Elf32_Addr *got asm ("r10");
-  return *got;
+  Elf32_Addr dynamic;
+  asm ("ldr %0, 2f\n"
+       "1: add %0, pc, %0\n"
+       "b 3f\n"
+       "2: .word _GLOBAL_OFFSET_TABLE_ - (1b+8)\n"
+       "3:" : "=r" (dynamic));
+  return dynamic;
 }
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]