[git commit] ARC: ldso: Use @pcl syntax.

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Mon Aug 18 09:52:16 UTC 2014


commit: http://git.uclibc.org/uClibc/commit/?id=6915b3a6b96e8e34601941c0eb7519cde1c0f999
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Joern Rennecke <joern.rennecke at embecosm.com>
Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 ldso/ldso/arc/dl-startup.h |   11 +++--------
 ldso/ldso/arc/dl-sysdep.h  |   17 ++++++++++++-----
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h
index 0161554..8e26ae8 100644
--- a/ldso/ldso/arc/dl-startup.h
+++ b/ldso/ldso/arc/dl-startup.h
@@ -33,14 +33,9 @@ __asm__(
     "   ; If ldso ran as cmd with executable file nm as arg     \n"
     "   ; skip the extra args calc by dl_start()                \n"
     "   ld_s    r1, [sp]       ; orig argc from aux-vec Tbl     \n"
-#ifdef STAR_9000535888_FIXED
-    "   ld      r12, [pcl, _dl_skip_args-.+(.&2)]               \n"
-#else
-    "   add     r12, pcl, _dl_skip_args-.+(.&2)                 \n"
-    "   ld      r12, [r12]                                      \n"
-#endif
+    "   ld      r12, [pcl, _dl_skip_args at pcl]                   \n"
 
-    "   add     r2, pcl, _dl_fini-.+(.&2)   ; finalizer         \n"
+    "   add     r2, pcl, _dl_fini at pcl       ; finalizer         \n"
 
     "   add2    sp, sp, r12    ; discard argv entries from stack\n"
     "   sub_s   r1, r1, r12    ; adjusted argc, on stack        \n"
diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h
index 97ce284..af4b180 100644
--- a/ldso/ldso/arc/dl-sysdep.h
+++ b/ldso/ldso/arc/dl-sysdep.h
@@ -124,14 +124,21 @@ static __always_inline Elf32_Addr elf_machine_dynamic(void)
 /* Return the run-time load address of the shared object.  */
 static __always_inline Elf32_Addr elf_machine_load_address(void)
 {
-    /* To find the loadaddr we subtract the runtime addr of any symbol
-     * say _dl_start from it's build-time addr.
+    /* To find the loadaddr we subtract the runtime addr of a non-local symbol
+     * say _DYNAMIC from it's build-time addr.
+     * N.B., gotpc loads get optimized by the linker if it finds the symbol
+     * is resolved locally.
+     * A more robust - and efficient - solution would be to use a symbol
+     * set by the linker.  To make it actually save space, we'd have to
+     * suppress the unwanted text relocation in the linked dso, though.
+     * (I.e. in ldso.so.*, though it's just another dso as far as bfd/ld
+     * are concerned.)
      */
 	Elf32_Addr addr, tmp;
 	__asm__ (
-        "ld  %1, [pcl, _dl_start at gotpc] ;build addr of _dl_start   \n"
-        "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n"
-        "sub %0, %0, %1                 ;delta                     \n"
+        "ld  %1, [pcl, _DYNAMIC at gotpc] ;build addr of _DYNAMIC"   "\n"
+        "add %0, pcl, _DYNAMIC at pcl     ;runtime addr of _DYNAMIC" "\n"
+        "sub %0, %0, %1                ;delta"                    "\n"
         : "=&r" (addr), "=r"(tmp)
     );
 	return addr;


More information about the uClibc-cvs mailing list