From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 2/2] sparc: Fix .udiv plt on libc
Date: Thu, 16 Mar 2017 13:43:00 -0000 [thread overview]
Message-ID: <1489671790-7611-2-git-send-email-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <1489671790-7611-1-git-send-email-adhemerval.zanella@linaro.org>
With the removal of divdi3 object from sparcv9-linux-gnu build, its
definition came from libgcc and its functions internall calls .udiv.
Since glibc also exports these symbols for compatibility reasons, it
will end up creating PLT calls internally in libc.so.
To avoid it, this patch uses the linker option --wrap to replace all
the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along
with strong alias in the udiv implementations, it makes linker do
local calls.
Checked on sparcv9-linux-gnu.
* sysdeps/sparc/sparc32/Makefile (libc.so-gnulib): New rule.
* sysdeps/sparc/sparc32/sparcv8/udiv.S (.udiv): Make a strong_alias
to __wrap_.udiv.
* sysdeps/sparc/sparc32/sparcv9/udiv.S (.udiv): Likewise.
* sysdeps/sparc/sparc32/udiv.S (.udiv): Likewise.
---
ChangeLog | 6 ++++++
sysdeps/sparc/sparc32/Makefile | 6 ++++++
sysdeps/sparc/sparc32/sparcv8/udiv.S | 1 +
sysdeps/sparc/sparc32/sparcv9/udiv.S | 1 +
sysdeps/sparc/sparc32/udiv.S | 1 +
5 files changed, 15 insertions(+)
diff --git a/sysdeps/sparc/sparc32/Makefile b/sysdeps/sparc/sparc32/Makefile
index da20589..6d2a196 100644
--- a/sysdeps/sparc/sparc32/Makefile
+++ b/sysdeps/sparc/sparc32/Makefile
@@ -47,3 +47,9 @@ $(divrem:%=$(sysdep_dir)/sparc/sparc32/%.S): $(sysdep_dir)/sparc/sparc32/divrem.
mv -f $@-tmp $@
sysdep-realclean := $(sysdep-realclean) $(divrem:%=sysdeps/sparc/sparc32/%.S)
+
+# libgcc __divdi3 and __moddi3 use .udiv and since it is also exported by
+# libc.so linker will create PLTs for the symbol. To avoid it we strong alias
+# the exported libc one to __wrap_.udiv and use linker option --wrap to make any
+# call to .udiv to call the wrapper symbol.
+libc.so-gnulib += -Wl,--wrap=.udiv
diff --git a/sysdeps/sparc/sparc32/sparcv8/udiv.S b/sysdeps/sparc/sparc32/sparcv8/udiv.S
index d719543..e9cab4e 100644
--- a/sysdeps/sparc/sparc32/sparcv8/udiv.S
+++ b/sysdeps/sparc/sparc32/sparcv8/udiv.S
@@ -13,3 +13,4 @@ ENTRY(.udiv)
udiv %o0, %o1, %o0
END(.udiv)
+strong_alias (.udiv, __wrap_.udiv)
diff --git a/sysdeps/sparc/sparc32/sparcv9/udiv.S b/sysdeps/sparc/sparc32/sparcv9/udiv.S
index de79899..368f85e 100644
--- a/sysdeps/sparc/sparc32/sparcv9/udiv.S
+++ b/sysdeps/sparc/sparc32/sparcv9/udiv.S
@@ -15,3 +15,4 @@ ENTRY(.udiv)
udiv %o0, %o1, %o0
END(.udiv)
+strong_alias (.udiv, __wrap_.udiv)
diff --git a/sysdeps/sparc/sparc32/udiv.S b/sysdeps/sparc/sparc32/udiv.S
index 8dfff66..ade0afd 100644
--- a/sysdeps/sparc/sparc32/udiv.S
+++ b/sysdeps/sparc/sparc32/udiv.S
@@ -344,3 +344,4 @@ LOC(got_result):
mov %o2, %o0
END(.udiv)
+strong_alias (.udiv, __wrap_.udiv)
--
2.7.4
next prev parent reply other threads:[~2017-03-16 13:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 13:43 [PATCH 1/2] Build divdi3 only for architecture that required it Adhemerval Zanella
2017-03-16 13:43 ` Adhemerval Zanella [this message]
2017-03-16 14:45 ` [PATCH 2/2] sparc: Fix .udiv plt on libc Florian Weimer
2017-03-16 16:59 ` Adhemerval Zanella
2017-03-27 15:33 ` Adhemerval Zanella
2017-03-16 13:58 ` [PATCH 1/2] Build divdi3 only for architecture that required it Andreas Schwab
2017-03-16 17:00 ` Adhemerval Zanella
[not found] ` <af83ffde-83d3-d7d1-d45e-7c379b7e7123@linaro.org>
2017-04-06 16:11 ` Adhemerval Zanella
2017-04-18 21:21 ` Joseph Myers
2017-04-18 22:29 ` Adhemerval Zanella
2017-04-19 21:01 ` Adhemerval Zanella
2017-05-10 13:24 ` Joseph Myers
2017-05-10 20:24 ` Adhemerval Zanella
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=1489671790-7611-2-git-send-email-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@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).