From 181d410ad00cddd1d6c9f4835e129136b74c5187 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Sat, 14 Feb 2015 15:25:37 +0530 Subject: ARC: Conditionalise certain relocations as provided by TLS tools only 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 Signed-off-by: Bernhard Reutner-Fischer --- ldso/ldso/arc/dl-startup.h | 7 +++++++ ldso/ldso/arc/dl-sysdep.h | 10 ++++++++++ 2 files changed, 17 insertions(+) (limited to 'ldso') diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h index 8e26ae8d9..ef89b5317 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@pcl] \n" " add r2, pcl, _dl_fini@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 d71e16b32..08b3bade8 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@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; } -- cgit v1.2.3 From afab56958f1cbb47b831ee3ebff231dfbae74af2 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Thu, 19 Feb 2015 19:13:59 +0530 Subject: ARCv2 ISA support This is next gen Instruction Set Architecture from Synopsys and basis for the ARC HS family of processors. http://www.synopsys.com/dw/ipdir.php?ds=arc-hs38-processor&elq_mid=5732&elq_cid=458802 http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/arc-hs/Pages/default.aspx Signed-off-by: Vineet Gupta Signed-off-by: Bernhard Reutner-Fischer --- ldso/ldso/arc/dl-sysdep.h | 15 +++++++++++++-- ldso/ldso/arc/elfinterp.c | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'ldso') diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index 08b3bade8..ca62a2c04 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -69,11 +69,16 @@ do { \ } while(0) /* Here we define the magic numbers that this dynamic loader should accept */ +#ifdef __A7__ #define MAGIC1 EM_ARCOMPACT +#define ELF_TARGET "ARCompact" /* For error messages */ +#elif defined(__HS__) +#define MAGIC1 EM_ARCV2 +#define ELF_TARGET "ARCv2" /* For error messages */ +#endif + #undef MAGIC2 -/* Used for error messages */ -#define ELF_TARGET "ARC" struct elf_resolve; extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, @@ -81,6 +86,8 @@ extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, extern unsigned __udivmodsi4(unsigned, unsigned) attribute_hidden; +#ifdef __A7__ +/* using "C" causes an indirection via __umodsi3 -> __udivmodsi4 */ #define do_rem(result, n, base) ((result) = \ \ __builtin_constant_p (base) ? (n) % (unsigned) (base) : \ @@ -95,6 +102,10 @@ extern unsigned __udivmodsi4(unsigned, unsigned) attribute_hidden; r1; \ }) \ ) +#elif defined(__HS__) +/* ARCv2 has hardware assisted divide/mod */ +#define do_rem(result, n, base) ((result) = (n) % (unsigned) (base)) +#endif /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or TLS variable so PLT entries should not be allowed to define the value. diff --git a/ldso/ldso/arc/elfinterp.c b/ldso/ldso/arc/elfinterp.c index d26c94705..7c31d3ac7 100644 --- a/ldso/ldso/arc/elfinterp.c +++ b/ldso/ldso/arc/elfinterp.c @@ -11,7 +11,11 @@ */ #include "ldso.h" +#ifdef __A7__ #define ARC_PLT_SIZE 12 +#else +#define ARC_PLT_SIZE 16 +#endif unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, unsigned int plt_pc) -- cgit v1.2.3 From 409f14d9b5e47513d5c939120a33965997c8ceb2 Mon Sep 17 00:00:00 2001 From: Steve Ellcey Date: Thu, 19 Feb 2015 16:03:26 -0800 Subject: Allow use of executable RUNPATH/RPATH when finding libraries. This option will modify ldso so that it will use the executables RUNPATH/RPATH to find to find libraries even though this behavour is not standard. Setting this option causes the uclibc dynamic linker behavour to match the glibc dynamic linker. Signed-off-by: Steve Ellcey Signed-off-by: Bernhard Reutner-Fischer --- ldso/ldso/dl-elf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'ldso') diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 54501d143..56319056d 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -308,6 +308,38 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp if (tpnt1 != NULL) return tpnt1; +#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__ + /* Very last resort, try the executable's DT_RUNPATH and DT_RPATH */ + /* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#shobj_dependencies + * The set of directories specified by a given DT_RUNPATH entry is + * used to find only the immediate dependencies of the executable or + * shared object containing the DT_RUNPATH entry. That is, it is + * used only for those dependencies contained in the DT_NEEDED + * entries of the dynamic structure containing the DT_RUNPATH entry, + * itself. One object's DT_RUNPATH entry does not affect the search + * for any other object's dependencies. + * + * glibc (around 2.19) violates this and the usual suspects are + * abusing this bug^Wrelaxed, user-friendly behaviour. + */ + + pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RUNPATH]; + if (pnt) { + pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB]; + _dl_if_debug_dprint("\tsearching exe's RUNPATH='%s'\n", pnt); + if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) + return tpnt1; + } + pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH]; + if (pnt) { + pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB]; + _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt); + if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) + return tpnt1; + } +#endif + + goof: /* Well, we shot our wad on that one. All we can do now is punt */ if (_dl_internal_error_number) -- cgit v1.2.3