Some old versions of binutils did not support @pcl relocations. This commit adds a new flag to the uClibc configuration system that detects if the toolchain supports @pcl relocations or not.
If this relocation is supported then the define ARC_HAS_AT_PCL_RELOC will be passed to the compiler, which is then used in the arc ldso to choose between generating old or new style code.
This commit addresses and issue that was worked around in commit 181d410ad00cddd1d6c9f4835e129136b74c5187 (ARC: Conditionalise certain relocations as provided by TLS tools only). In this commit the choice between old or new style relocations was made based on whether uClibc was configured with native threads or not. The problem is that a user of a new toolchain might choose to configure without native threads. --- Rules.mak | 2 ++ ldso/ldso/arc/dl-startup.h | 2 +- ldso/ldso/arc/dl-sysdep.h | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Rules.mak b/Rules.mak index 3c80016..04ff02f 100644 --- a/Rules.mak +++ b/Rules.mak @@ -507,9 +507,11 @@ ifeq ($(TARGET_ARCH),c6x) endif
ifeq ($(TARGET_ARCH),arc) + ARC_HAS_AT_PCL_RELOC:=$(shell echo -e "\t.text\n\tadd r0,pcl,_symbol@pcl" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n) CPU_CFLAGS-y += -mlock -mswape CPU_CFLAGS-$(CONFIG_ARC_CPU_700) += -mA7 CPU_CFLAGS-$(CONFIG_ARC_CPU_HS) += -mcpu=archs + CPU_CFLAGS-$(ARC_HAS_AT_PCL_RELOC) += -DARC_HAS_AT_PCL_RELOC CPU_LDFLAGS-y += $(CPU_CFLAGS) -marclinux endif
diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h index ef89b53..80ffd79 100644 --- a/ldso/ldso/arc/dl-startup.h +++ b/ldso/ldso/arc/dl-startup.h @@ -34,7 +34,7 @@ __asm__( " ; 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__ +#ifdef ARC_HAS_AT_PCL_RELOC " ld r12, [pcl, _dl_skip_args@pcl] \n"
" add r2, pcl, _dl_fini@pcl ; finalizer \n" diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index caece99..27463f0 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -154,7 +154,11 @@ static __always_inline Elf32_Addr elf_machine_load_address(void) Elf32_Addr addr, tmp; __asm__ ( "ld %1, [pcl, _dl_start@gotpc] ;build addr of _dl_start \n" +#ifdef ARC_HAS_AT_PCL_RELOC + "add %0, pcl, _dl_start@pcl ;runtime addr of _dl_start \n" +#else "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n" +#endif /* ARC_HAS_AT_PCL_RELOC */ "sub %0, %0, %1 ;delta \n" : "=&r" (addr), "=r"(tmp) );