powerpc32/nofpu: Add internal soft-fp symbols to avoid PLT in libc.so

Message ID CAMe9rOq1yzPcH+rLc2WJUBC7Db7RhiSbC=rXNS46+4U=nJuGvQ@mail.gmail.com (mailing list archive)
State New
Headers
Series powerpc32/nofpu: Add internal soft-fp symbols to avoid PLT in libc.so |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686

Commit Message

H.J. Lu May 4, 2026, 12:38 a.m. UTC
  Since powerpc-linux-gnu-soft libc.so calls __fixunssfsi, __gesf2, __lesf2
and __ltsf2 internally, add internal symbols to avoid calling them via
PLT.

This fixes BZ #34122.
  

Comments

Adhemerval Zanella Netto May 4, 2026, 11:49 a.m. UTC | #1
> Em 3 de mai. de 2026, à(s) 21:40, H.J. Lu <hjl.tools@gmail.com> escreveu:
> 
> Since powerpc-linux-gnu-soft libc.so calls __fixunssfsi, __gesf2, __lesf2
> and __ltsf2 internally, add internal symbols to avoid calling them via
> PLT.
> 
> This fixes BZ #34122.
> 
> --
> H.J.
> <0001-powerpc32-nofpu-Add-internal-soft-fp-symbols-to-avoi.patch>

Maybe https://sourceware.org/pipermail/libc-alpha/2026-April/177019.html ?
  

Patch

From 4c1b3965ee2cdecbb23c48189cee5a9bc3650a1e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 4 May 2026 08:30:50 +0800
Subject: [PATCH] powerpc32/nofpu: Add internal soft-fp symbols to avoid PLT in
 libc.so

Since powerpc-linux-gnu-soft libc.so calls __fixunssfsi, __gesf2, __lesf2
and __ltsf2 internally, add internal symbols to avoid calling them via
PLT.

This fixes BZ #34122.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 .../linux/powerpc/powerpc32/nofpu/Makefile    |  7 ++++
 .../powerpc/powerpc32/nofpu/fixunssfsi.c      |  5 +++
 .../linux/powerpc/powerpc32/nofpu/gesf2.c     |  5 +++
 .../linux/powerpc/powerpc32/nofpu/lesf2.c     |  6 +++
 .../powerpc/powerpc32/nofpu/symbol-hacks.h    | 38 +++++++++++++++++++
 5 files changed, 61 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/fixunssfsi.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/gesf2.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/lesf2.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/symbol-hacks.h

diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/Makefile b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/Makefile
new file mode 100644
index 0000000000..86c4b4dc26
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/Makefile
@@ -0,0 +1,7 @@ 
+ifeq (yes,$(build-shared))
+ifeq ($(subdir),soft-fp)
+CPPFLAGS-fixunssfsi.c = -Din_fixunssfsi_c
+CPPFLAGS-gesf2.c = -Din_gesf2_c
+CPPFLAGS-lesf2.c = -Din_lesf2_c
+endif
+endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/fixunssfsi.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/fixunssfsi.c
new file mode 100644
index 0000000000..352379949d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/fixunssfsi.c
@@ -0,0 +1,5 @@ 
+#include <soft-fp/fixunssfsi.c>
+
+#ifdef SHARED
+strong_alias (__fixunssfsi, __fixunssfsi_internal)
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/gesf2.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/gesf2.c
new file mode 100644
index 0000000000..a0a8b6db37
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/gesf2.c
@@ -0,0 +1,5 @@ 
+#include <soft-fp/gesf2.c>
+
+#ifdef SHARED
+strong_alias (__gesf2, __gesf2_internal)
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/lesf2.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/lesf2.c
new file mode 100644
index 0000000000..3dee21aff6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/lesf2.c
@@ -0,0 +1,6 @@ 
+#include <soft-fp/lesf2.c>
+
+#ifdef SHARED
+strong_alias (__lesf2, __lesf2_internal)
+strong_alias (__ltsf2, __ltsf2_internal)
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/symbol-hacks.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/symbol-hacks.h
new file mode 100644
index 0000000000..ff371e8376
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/symbol-hacks.h
@@ -0,0 +1,38 @@ 
+/* Hacks needed for soft-fp symbol manipulation.
+   Copyright (C) 2026 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* A very dirty trick: gcc emits references to __fixunssfsi, __gesf2,
+   __lesf2 and __ltsf2.  These functions are exported and therefore we
+   get PLTs.  Unnecessarily so.  Changing gcc is a big task which might
+   not be worth it so we play tricks with the assembler.  */
+#if !defined __ASSEMBLER__ && IS_IN (libc) \
+    && defined SHARED && !defined LIBC_NONSHARED
+/* Note: Avoid symbol alias on function definitions themself.  */
+# ifndef in_fixunssfsi_c
+asm ("__fixunssfsi = __fixunssfsi_internal");
+# endif
+# ifndef in_gesf2_c
+asm ("__gesf2 = __gesf2_internal");
+# endif
+# ifndef in_lesf2_c
+asm ("__lesf2 = __lesf2_internal");
+asm ("__ltsf2 = __ltsf2_internal");
+# endif
+#endif
+
+#include_next "symbol-hacks.h"
-- 
2.54.0