public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: yuucyf <yuucyf@163.com>
To: libc-help@sourceware.org
Subject: A question regarding the optimization of string functions in glibc.
Date: Sun, 8 Oct 2023 09:41:36 +0800 (CST)	[thread overview]
Message-ID: <35e2d94d.e6e.18b0cf26dce.Coremail.yuucyf@163.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

Dear all,

I have some questions to ask.
In the glibc source code, there are various string optimization functions for different PowerPC architectures in the sysdeps/powerpc/powerpc64/multiarch directory, such as xxx_power7, xxx_power8, xxx_power9, and so on. When building glibc, I've noticed that these source files generate .o files, and all of them are eventually merged into libc.a. My question is, if I use the strcpy function in my user code, which version of strcpy is actually linked? GCC supports specifying the CPU type using -mcpu, but how does the linker choose which version of strcpy to link? Can you please explain in detail the process of determining which function is linked?
I'm currently writing a test case on a Power8 platform that uses the strcpy string function. However, when I disassemble it after linking, I found that it's not using strcpy-power8.S. Since it's not using the optimized string function for the Power8 platform, I'm curious why there are assembly implementations of optimized string functions for multiple platforms like PowerPC, ARM, MIPS, and others. How does it determine which platform-specific optimized string function to use on a particular platform? Could someone kindly provide a detailed explanation? Thank you!

             reply	other threads:[~2023-10-08  1:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-08  1:41 yuucyf [this message]
2023-10-10 14:49 ` Adhemerval Zanella Netto

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

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

  git send-email \
    --in-reply-to=35e2d94d.e6e.18b0cf26dce.Coremail.yuucyf@163.com \
    --to=yuucyf@163.com \
    --cc=libc-help@sourceware.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).