This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 7/7] RFC: ldbl-128ibm-compat: PLT redirects for using ldbl redirects internally




On 2/14/20 10:10 AM, Paul E. Murphy wrote:
Tweak the PLT bypass magic when building glibc with long double
redirects.  This is made more difficult by the fact we only get
one chance to redirect functions.  This happens via the public
headers.

There are roughly three classes of redirect we need to attend to
today:

  1. Simple redirects, redirected via cdef macro overrides and
     and new libc_hidden_ldbl_proto macro.
  2. Internal usage of internal API, e.g __snprintf, which has
     no direct analogue.  This is bypassed directly on case-by-
     case basis.
  3. Double redirects, e.g sscanf and related.  These require
     a heavier handed approach of macro renaming to existing
     symbols.

Most simple redirects are handled via 1.  Ideally, the libc_*
macro would live in libc-symbols.h, but in practice the macros
needed for it to do anything useful live in cdefs.h, so they
are defined in the local override.

Notably, the internal name of asprintf is renamed to work with
internal prefixed usage.

This resolves the local plt usage introduced when building glibc
with ldbl == ieee128 on ppc64le.
---
  include/err.h                                 | 12 ++---
  include/stdio.h                               | 51 +++++++++++++------
  include/sys/cdefs.h                           | 23 +++++++++
  include/sys/syslog.h                          |  2 +-
  include/wchar.h                               |  2 +-
  .../ldbl-128ibm-compat/ieee128-asprintf.c     |  5 +-
  .../ldbl-128ibm-compat/ieee128-dprintf.c      |  1 +
  .../ieee754/ldbl-128ibm-compat/ieee128-err.c  |  7 +++
  .../ldbl-128ibm-compat/ieee128-fprintf.c      |  1 +
  .../ieee128-isoc99_sscanf.c                   |  1 +
  .../ieee128-isoc99_vfscanf.c                  |  2 +
  .../ieee128-isoc99_vsscanf.c                  |  1 +
  .../ldbl-128ibm-compat/ieee128-sprintf.c      |  1 +
  .../ldbl-128ibm-compat/ieee128-syslog.c       |  1 +
  .../ldbl-128ibm-compat/ieee128-vfprintf.c     |  1 +
  .../ldbl-128ibm/include/bits/iscanonical.h    |  2 +-
  16 files changed, 87 insertions(+), 26 deletions(-)


diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 524fe57a25..ae5802e744 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -15,4 +15,27 @@ rtld_hidden_proto (__chk_fail)

  #endif

+/* If we are using redirects internally to support long double,
+   we need to tweak some macros to ensure the PLT bypass tricks
+   continue to work in libc. */
+#if __LONG_DOUBLE_USES_FLOAT128 == 1 && IS_IN (libc) && defined SHARED
+
+# undef __LDBL_REDIR_DECL
+# define __LDBL_REDIR_DECL(name)
+
+# undef __LDBL_REDIR2_DECL
+# define __LDBL_REDIR2_DECL(name)
+
+# undef __LDBL_REDIR1_DECL
+# define __LDBL_REDIR1_DECL(name, to)
+
+# define libc_hidden_ldbl_proto(func) \
+   extern __typeof(func) func __asm (__ASMNAME ("__GI____ieee128_" #func)); \
+   extern __typeof(func) ___ieee128_ ## func; \
+   libc_hidden_proto (___ieee128_ ## func);
+
+#else
+# define libc_hidden_ldbl_proto(func) libc_hidden_proto (func)
+#endif
+

I think libc_hidden_ldbl_proto(func) should be moved into libc-symbols.h consistent with the other libc_hidden* macros. Similarly, these macros need protected against _ISOMAC. I will post an updated patch.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]