[git commit] ARC: Conditionalise certain relocations as provided by TLS tools only

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Mon Feb 16 20:52:13 UTC 2015


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

uClibc mainline supports NPTL which in turns depends on TLS support in
the tools (gcc/binutils), which is yet to be merged in dev branches.

However there is some non NPTL code in uClibc, added as part of NPTL
effort, which relies on certain relocations only provided by NPTL
binutils. As a result building the current upstream even for LT.old
breaks.

So conditionalize that code on tools, bu tin lack of specific versions,
we use NPTL enabling as a sign the tools are equipped to handle those
relos.

Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 extra/Configs/defconfigs/arc/defconfig |    2 +-
 ldso/ldso/arc/dl-startup.h             |    7 +++++++
 ldso/ldso/arc/dl-sysdep.h              |   10 ++++++++++
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/extra/Configs/defconfigs/arc/defconfig b/extra/Configs/defconfigs/arc/defconfig
index 840c59f..db4308f 100644
--- a/extra/Configs/defconfigs/arc/defconfig
+++ b/extra/Configs/defconfigs/arc/defconfig
@@ -6,7 +6,7 @@ KERNEL_HEADERS="%KERNEL_HEADERS%"
 # LDSO_CACHE_SUPPORT is not set
 LDSO_RUNPATH=y
 # LDSO_SAFE_RUNPATH is not set
-UCLIBC_HAS_THREADS_NATIVE=y
+LINUXTHREADS_OLD=y
 PTHREADS_DEBUG_SUPPORT=y
 UCLIBC_HAS_OBSTACK=y
 UCLIBC_SUSV2_LEGACY=y
diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h
index 8e26ae8..ef89b53 100644
--- a/ldso/ldso/arc/dl-startup.h
+++ b/ldso/ldso/arc/dl-startup.h
@@ -33,9 +33,16 @@ __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 __UCLIBC_HAS_THREADS_NATIVE__
     "   ld      r12, [pcl, _dl_skip_args at pcl]                   \n"
 
     "   add     r2, pcl, _dl_fini at pcl       ; finalizer         \n"
+#else
+    "   add     r12, pcl, _dl_skip_args-.+(.&2)                 \n"
+    "   ld      r12, [r12]                                      \n"
+    "   add     r2, pcl, _dl_fini-.+(.&2)   ; finalizer         \n"
+#endif
 
     "   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 d71e16b..08b3bad 100644
--- a/ldso/ldso/arc/dl-sysdep.h
+++ b/ldso/ldso/arc/dl-sysdep.h
@@ -127,6 +127,7 @@ 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)
 {
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
     /* 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
@@ -144,6 +145,15 @@ static __always_inline Elf32_Addr elf_machine_load_address(void)
         "sub %0, %0, %1                ;delta"                    "\n"
         : "=&r" (addr), "=r"(tmp)
     );
+#else
+	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"
+         : "=&r" (addr), "=r"(tmp)
+     );
+#endif
 	return addr;
 }
 


More information about the uClibc-cvs mailing list