[2/2] ARC: Add new compiler define to indicate @pcl relocation support

Submitted by Waldemar Brodkorb on July 28, 2016, 10:26 p.m.

Details

Message ID 20160728222634.GH22524@waldemar-brodkorb.de
State New
Headers show

Commit Message

Waldemar Brodkorb July 28, 2016, 10:26 p.m.
Hi Andrew,
Andrew Burgess wrote,

> 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

I tried the patch, but get this with arc 2016.03 (ARC700, LE):

/home/wbx/embedded-test/openadk/toolchain_nsim-arcv1_uclibc-ng_arc700/usr/bin/arc-openadk-linux-uclibc-gcc
-c libc/sysdeps/linux/common/pause.c -o
libc/sysdeps/linux/common/pause.os -Wall -Wstrict-prototypes
-Wstrict-aliasing -funsigned-char -fno-builtin -fno-asm
-fmerge-all-constants -std=gnu99 -mlock -mswape -mA7
-fno-stack-protector -nostdinc -I./include -I./include -include
libc-symbols.h -I./libc/sysdeps/linux/arc -I./libc/sysdeps/linux
-I./ldso/ldso/arc -I./ldso/include -I. -Os -fstrict-aliasing -fwrapv
-fno-ident -mcpu=arc700 -Os -pipe -fomit-frame-pointer
-fno-unwind-tables -fno-asynchronous-unwind-tables
-D__USE_STDIO_FUTEXES__ -DHAVE_FORCED_UNWIND -D_LIBC_REENTRANT
-I./libpthread/nptl -I./libpthread/nptl
-I./libpthread/nptl/sysdeps/unix/sysv/linux/arc
-I./libpthread/nptl/sysdeps/arc -I./libpthread/nptl/sysdeps/arc
-I./libpthread/nptl/sysdeps/unix/sysv/linux
-I./libpthread/nptl/sysdeps/unix/sysv/linux
-I./libpthread/nptl/sysdeps/pthread
-I./libpthread/nptl/sysdeps/pthread/bits
-I./libpthread/nptl/sysdeps/generic -I./libc/sysdeps/linux/common
-isystem
/home/wbx/embedded-test/openadk/toolchain_nsim-arcv1_uclibc-ng_arc700/usr/lib/gcc/arc-openadk-linux-uclibc/4.8.5/include-fixed
-isystem
/home/wbx/embedded-test/openadk/toolchain_nsim-arcv1_uclibc-ng_arc700/usr/lib/gcc/arc-openadk-linux-uclibc/4.8.5/include
-I/home/wbx/embedded-test/openadk/target_nsim-arcv1_uclibc-ng_arc700/usr/include/
-DNDEBUG -DIN_LIB=libc -fPIC -fexceptions
-fasynchronous-unwind-tables -MT libc/sysdeps/linux/common/pause.os
-MD -MP -MF libc/sysdeps/linux/common/.pause.os.dep
{standard input}: Assembler messages:
{standard input}:15: Error: invalid operands (.bss and .text
sections) for `-'
{standard input}:15: Error: invalid operands (.text and *ABS*
sections) for `&'
{standard input}:17: Error: invalid operands (.text.exit and .text
sections) for `-'
{standard input}:17: Error: invalid operands (.text and *ABS*
sections) for `&'
Makerules:385: recipe for target 'ldso/ldso/ldso.oS' failed
make[6]: *** [ldso/ldso/ldso.oS] Error 1

It seems ARC_HAS_AT_PCL_RELOC isn't set. I tracked it down, it seems
a combination of my shell and echo -e usage. I know there is another
echo -e usage in Rules.mak and I will fix it later. Can you please
resend the patch with printf instead of echo -e, if the Synopsis ARC
developers agree on this patch?
I added the trailing "\n" to avoid a unnecessary warning when trying
just the command in a shell, sth like that:

/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

Otherwise looks good to me and fixes my problem with a nothread
build :)

thanks
 Waldemar

Patch hide | download patch | download mbox

diff --git a/Rules.mak b/Rules.mak
index 04ff02f..8b962b4 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -507,7 +507,7 @@  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)
+       ARC_HAS_AT_PCL_RELOC:=$(shell printf "\t.text\n\tadd
r0,pcl,_symbol@pcl\n" | $(CC) -c -x assembler -o /dev/null - 2>