[PATCH v6 10/13] ARC: ABI lists

Vineet Gupta Vineet.Gupta1@synopsys.com
Fri Jun 5 21:14:38 GMT 2020


On 6/5/20 11:02 AM, Adhemerval Zanella via Libc-alpha wrote:

>>> and we handle this issue with an
>>> assembly hack to redirect the autogenerate memcpy/memmove calls
>>> to internal definitions (sysdeps/generic/symbol-hacks.h).
>>>
>>> I am not sure exactly if this would be avoided in ARC configuration,
>>> maybe it could adapt the sparc32 hack for the libgcc .udiv symbol
>>> (sysdeps/sparc/sparc32/Makefile).
>>
>> I looked at the code and this seems different than our issue.
>>
> 
> I think it is similar: for sparc32 the divdi3 is pulled from libgcc
> and it in turns calls an libgcc provided symbol (.udiv) which is
> also provided by glibc.
> 
> What I am not sure is if we can use the the same hack to force
> the linker bind the memcpy libgcc internal usage to glibc provided 
> symbol.
> 
> I would try to do something like:
> 
> diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
> index 8d2fbe00c5..ed2f43d2a6 100644
> --- a/sysdeps/arc/Makefile
> +++ b/sysdeps/arc/Makefile
> @@ -20,6 +20,8 @@
>  # this variable; it's here mostly for documentational purposes.
>  long-double-fcts = no
>  
> +libc.so-gnulib += -Wl,--wrap=memcpy
> +
>  ifeq ($(subdir),debug)
>  CFLAGS-backtrace.c += -funwind-tables
>  endif
> 
> And add a sysdeps/arc/symbol-hacks.h with something like:
> 
> #if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED
> asm ("memcpy = __wrap_memcpy");
> #endif

Thx I'm testing this now. Funny with gcc10 + hf we get a different symbol from
libgcc now which needs to be handled similarly:
   __GI___printf_fp_l -> __mpn_mul -> memset

> 
> I also tried to build a soft-float BE with -Os

I don't recall the issue with BE but indeed it should happen too.

How exactly are you building for -Os. Please note that gcc/libgcc itself needs to
be built with -Os to trigger the issue.

> using the latest
> tools at the link you added in cover-letter [1] but I couldn't
> trigger the issue.  Is is triggering some more recent gcc only?
> 
> [1] https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases

Actually for glibc upstreaming I'm only using vanilla upstream gcc/binutils. Also
for me the issue only happens with a buildroot build (which certainly propagates
the build flag -Os, -O2 etc to gcc/libgcc build too)

-Vineet


More information about the Libc-alpha mailing list