public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Multiple symbols at the same location
@ 2018-08-25 21:51 Derrick McKee
  2018-08-27 13:09 ` Adhemerval Zanella
  0 siblings, 1 reply; 2+ messages in thread
From: Derrick McKee @ 2018-08-25 21:51 UTC (permalink / raw)
  To: libc-help

Hi,

I am a PhD. student, and in my research I noticed that there are
several versions of memmove and memcpy that are included in statically
compiled binaries.  I understand that this is done for optimization
purposes (and if that is not the case, let me know!).  However, some
versions of memmove and memcpy are located in different places in
.text, while others have their symbols located at the same location in
.text.  For example, __memcpy_avx512_unaligned and
__memmove_avx512_unaligned have the same address, however
__memcpy_ssse3 and __memmove_ssse3 are placed at different addresses.
I assume that this is also done for optimization purposes.

Can someone give me an explanation as to why it makes sense to
separate one group of memory copying functions into two symbols, while
for others the same code is used?  Thanks!


-- 
Derrick McKee
Phone: (703) 957-9362
Email: derrick.mckee@gmail.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Multiple symbols at the same location
  2018-08-25 21:51 Multiple symbols at the same location Derrick McKee
@ 2018-08-27 13:09 ` Adhemerval Zanella
  0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2018-08-27 13:09 UTC (permalink / raw)
  To: libc-help



On 25/08/2018 18:51, Derrick McKee wrote:
> Hi,
> 
> I am a PhD. student, and in my research I noticed that there are
> several versions of memmove and memcpy that are included in statically
> compiled binaries.  I understand that this is done for optimization
> purposes (and if that is not the case, let me know!).  However, some
> versions of memmove and memcpy are located in different places in
> .text, while others have their symbols located at the same location in
> .text.  For example, __memcpy_avx512_unaligned and
> __memmove_avx512_unaligned have the same address, however
> __memcpy_ssse3 and __memmove_ssse3 are placed at different addresses.
> I assume that this is also done for optimization purposes.
> 
> Can someone give me an explanation as to why it makes sense to
> separate one group of memory copying functions into two symbols, while
> for others the same code is used?  Thanks!

These are ifunc [1] variants selected at runtime depending of the some
criteria.  For x86_64, it builds an intern data structure with current
CPU features obtained from cpuid (sysdeps/x86/cpu-features.c) and then
each selection can use these flags to select the best suitable variation.
(check sysdeps/x86_64/multiarch/memcpy.c for instance).

Now, it is possible to implement memcpy with memmove, although it might
not be as optimized as possible. It is what memmove/memcpy for AVX512
does:

* sysdeps/x86_64/multiarch/memmove-avx512-unaligned-erms.S

 11 # include "memmove-vec-unaligned-erms.S"

* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S

564 strong_alias (MEMMOVE_SYMBOL (__memmove, unaligned),                                     
565               MEMCPY_SYMBOL (__memcpy, unaligned))

[1] https://sourceware.org/glibc/wiki/GNU_IFUNC

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-27 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-25 21:51 Multiple symbols at the same location Derrick McKee
2018-08-27 13:09 ` Adhemerval Zanella

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