unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: Re: [PATCH v6 10/13] ARC: ABI lists
Date: Fri, 5 Jun 2020 15:02:11 -0300	[thread overview]
Message-ID: <7564dbd4-0b8c-502d-ef4a-d317ca348e09@linaro.org> (raw)
In-Reply-To: <cf5dd5de-3b4d-4e7d-03f8-4e011f36f92a@synopsys.com>



On 04/06/2020 23:22, Vineet Gupta wrote:
> On 6/3/20 12:29 PM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
>>
>> LGTM with a just isseu regarding the pulled memcpy from libgcc.
> 
> Just to be clear
> 
> This is libgcc routine calling memcpy from gcc and libgcc-static linked into libc
> pulling in this PLT. And this is only for soft float + Os.  And there's just this
> one instance in libc which uses PLT, all other internal memcpy calls are direct.
> 
> $ arc-linux-objdump -d lib/libc-2.31.9000.so
> 
> 0001b014 <.plt>:
> ...
>    1b0e4:	ld	r12,[pcl,0xe6f50] ;102034 <memcpy@@GLIBC_2.32+0x9b020>
>    1b0ec:	j.d	[r12]
>    1b0f0:	mov	r12,pcl
> 
> 000d0fd8 <_fpadd_parts>:
> ...
>    d17ba:	bl	1b0e4 <.plt+0xd0>	<-- memcpy via PLT
> 
> 
> 000655a4 <__libc_alloc_buffer_copy_bytes>:
> ...
>    655c4:	bl.d	6736	;67014 <memcpy>
> ...
> 
> 00067014 <memcpy>:
>    67014:	push_s	blink
> ...
> 

Yes, I understood the issue.

>>> diff --git a/sysdeps/unix/sysv/linux/arc/localplt.data b/sysdeps/unix/sysv/linux/arc/localplt.data
>>> new file mode 100644
>>> index 000000000000..4479e8ee8a26
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/arc/localplt.data
>>> @@ -0,0 +1,12 @@
>>> +libc.so: realloc
>>> +libc.so: malloc
>>> +libc.so: memalign
>>> +libc.so: calloc
>>> +libc.so: free
>>> +# At -Os, a struct assignment in libgcc-static pulls this in
>>> +libc.so: memcpy ?
> 
>> This is mosty likely an issue 
> 
> Care to elaborate what the issue is exactly: that memcpy being local to libc dso
> is still routed via PLT ? Or that the entry is only present sometimes ?

Besides the interposition and performance issue I think the main
drawback by whitelisting memcpy is potentially hides other possible
intra PLT memcpy in localplt.data future testing (although glibc does
some effort to avoid the issue of compiler generate memcpy/memmove).

> 
> 
>> 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


I also tried to build a soft-float BE with -Os 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

  reply	other threads:[~2020-06-05 18:02 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  1:41 [PATCH v6 00/13] glibc port to ARC processors Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 01/13] ARC: ABI Implementation Vineet Gupta via Libc-alpha
2020-05-27 18:26   ` Adhemerval Zanella via Libc-alpha
2020-05-27 22:15     ` Vineet Gupta via Libc-alpha
2020-05-29 13:56       ` Adhemerval Zanella via Libc-alpha
2020-06-03 20:05     ` Vineet Gupta via Libc-alpha
2020-06-04  9:04       ` Florian Weimer via Libc-alpha
2020-06-04 19:01         ` Vineet Gupta via Libc-alpha
2020-06-04 23:56           ` Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 02/13] ARC: startup and dynamic linking code Vineet Gupta via Libc-alpha
2020-05-27 19:05   ` Adhemerval Zanella via Libc-alpha
2020-05-28  1:14     ` Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 03/13] ARC: Thread Local Storage support Vineet Gupta via Libc-alpha
2020-05-27 19:17   ` Adhemerval Zanella via Libc-alpha
2020-05-28  1:36     ` Vineet Gupta via Libc-alpha
2020-06-01 18:53       ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 04/13] ARC: Atomics and Locking primitives Vineet Gupta via Libc-alpha
2020-04-23 17:20   ` Adhemerval Zanella via Libc-alpha
2020-04-24  7:23     ` Vineet Gupta via Libc-alpha
2020-04-27 21:59     ` [PATCH] semaphore: consolidate arch headers into a generic one Vineet Gupta via Libc-alpha
2020-04-27 22:13       ` Vineet Gupta via Libc-alpha
2020-05-05 21:02         ` Adhemerval Zanella via Libc-alpha
2020-05-04 21:21       ` Vineet Gupta via Libc-alpha
2020-05-05 19:05       ` Adhemerval Zanella via Libc-alpha
2020-05-05 19:38         ` Vineet Gupta via Libc-alpha
2020-05-05 21:37           ` Adhemerval Zanella via Libc-alpha
2020-05-05 22:59         ` Vineet Gupta via Libc-alpha
2020-05-08 13:32           ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 05/13] ARC: math soft float support Vineet Gupta via Libc-alpha
2020-05-29 14:02   ` Adhemerval Zanella via Libc-alpha
2020-05-29 23:57     ` Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 06/13] ARC: hardware floating point support Vineet Gupta via Libc-alpha
2020-05-29 14:12   ` Adhemerval Zanella via Libc-alpha
2020-05-29 22:28     ` Vineet Gupta via Libc-alpha
2020-05-29 23:50       ` Vineet Gupta via Libc-alpha
2020-06-02  0:50         ` static inline math functions (was Re: [PATCH v6 06/13] ARC: hardware floating point support) Vineet Gupta via Libc-alpha
2020-06-02 18:13           ` Joseph Myers
2020-06-02 18:35             ` Adhemerval Zanella via Libc-alpha
2020-06-02 17:51         ` [PATCH v6 06/13] ARC: hardware floating point support Joseph Myers
2020-06-05  4:44         ` Vineet Gupta via Libc-alpha
2020-06-05 17:22           ` Adhemerval Zanella via Libc-alpha
2020-06-02 17:48       ` Joseph Myers
2020-04-23  1:41 ` [PATCH v6 07/13] ARC: Linux Syscall Interface Vineet Gupta via Libc-alpha
2020-05-29 16:49   ` Adhemerval Zanella via Libc-alpha
2020-05-30  2:02     ` Vineet Gupta via Libc-alpha
2020-06-03 19:46     ` Vineet Gupta via Libc-alpha
2020-06-03 20:04       ` Adhemerval Zanella via Libc-alpha
2020-06-03 20:17         ` Vineet Gupta via Libc-alpha
2020-06-04 11:06           ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 08/13] ARC: Linux ABI Vineet Gupta via Libc-alpha
2020-05-29 17:05   ` Adhemerval Zanella via Libc-alpha
2020-05-30  0:16     ` Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 09/13] ARC: Linux Startup and Dynamic Loading Vineet Gupta via Libc-alpha
2020-06-03 18:02   ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 10/13] ARC: ABI lists Vineet Gupta via Libc-alpha
2020-06-03 19:29   ` Adhemerval Zanella via Libc-alpha
2020-06-05  2:22     ` Vineet Gupta via Libc-alpha
2020-06-05 18:02       ` Adhemerval Zanella via Libc-alpha [this message]
2020-06-05 21:14         ` Vineet Gupta via Libc-alpha
2020-06-08  4:12           ` Vineet Gupta via Libc-alpha
2020-06-08  8:44         ` Florian Weimer via Libc-alpha
2020-06-08 18:17           ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 11/13] ARC: Build Infrastructure Vineet Gupta via Libc-alpha
2020-06-03 19:58   ` Adhemerval Zanella via Libc-alpha
2020-06-04 15:25     ` Vineet Gupta via Libc-alpha
2020-06-04 17:05       ` Adhemerval Zanella via Libc-alpha
2020-06-08  4:18         ` Vineet Gupta via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 12/13] build-many-glibcs.py: Enable ARC builds Vineet Gupta via Libc-alpha
2020-06-04 12:08   ` Adhemerval Zanella via Libc-alpha
2020-04-23  1:41 ` [PATCH v6 13/13] Documentation for ARC port Vineet Gupta via Libc-alpha
2020-06-04 12:16   ` Adhemerval Zanella via Libc-alpha
2020-06-04 15:36     ` Vineet Gupta via Libc-alpha
2020-05-04 21:21 ` [PATCH v6 00/13] glibc port to ARC processors Vineet Gupta via Libc-alpha
2020-05-15  0:45   ` Vineet Gupta via Libc-alpha
2020-05-27  1:49     ` Vineet Gupta via Libc-alpha
2020-05-27 16:41       ` Adhemerval Zanella via Libc-alpha
2020-05-27 18:38         ` Vineet Gupta via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7564dbd4-0b8c-502d-ef4a-d317ca348e09@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=adhemerval.zanella@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).