about summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/err.h12
-rw-r--r--include/libc-symbols.h2
-rw-r--r--include/stdio.h52
-rw-r--r--include/sys/cdefs.h20
-rw-r--r--include/sys/syslog.h2
-rw-r--r--include/wchar.h2
6 files changed, 67 insertions, 23 deletions
diff --git a/include/err.h b/include/err.h
index 7c05cd1dbb..b9b7516287 100644
--- a/include/err.h
+++ b/include/err.h
@@ -12,12 +12,12 @@ __vwarn_internal (const char *format, __gnuc_va_list ap,
 
 # ifndef _ISOMAC
 
-libc_hidden_proto (warn)
-libc_hidden_proto (warnx)
-libc_hidden_proto (vwarn)
-libc_hidden_proto (vwarnx)
-libc_hidden_proto (verr)
-libc_hidden_proto (verrx)
+libc_hidden_ldbl_proto (warn)
+libc_hidden_ldbl_proto (warnx)
+libc_hidden_ldbl_proto (vwarn)
+libc_hidden_ldbl_proto (vwarnx)
+libc_hidden_ldbl_proto (verr)
+libc_hidden_ldbl_proto (verrx)
 
 # endif /* !_ISOMAC */
 #endif /* err.h */
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index b0b75a087e..3555cb6f3d 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -885,6 +885,8 @@ for linking")
 #define libc_hidden_builtin_def(name) libc_hidden_def (name)
 #define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
 #define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
+
+#define libc_hidden_ldbl_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
 #ifdef __ASSEMBLER__
 # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
 #endif
diff --git a/include/stdio.h b/include/stdio.h
index dffa7765dd..6718af4108 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -9,13 +9,24 @@
 
 /* Now define the internal interfaces.  */
 
+/*  Some libc_hidden_ldbl_proto's do not map to a unique symbol when
+    redirecting ldouble to _Float128 variants.  We can therefore safely
+    directly alias them to their internal name.  */
+# if __LONG_DOUBLE_USES_FLOAT128 == 1 && IS_IN (libc)
+#  define stdio_hidden_ldbl_proto(p, f) \
+  extern __typeof (p ## f) p ## f __asm (__ASMNAME ("___ieee128_" #f));
+# elif __LONG_DOUBLE_USES_FLOAT128 == 1
+#  define stdio_hidden_ldbl_proto(p,f) __LDBL_REDIR1_DECL (p ## f, p ## f ## ieee128)
+# else
+#  define stdio_hidden_ldbl_proto(p,f) libc_hidden_proto (p ## f)
+# endif
+
 extern int __fcloseall (void) attribute_hidden;
 extern int __snprintf (char *__restrict __s, size_t __maxlen,
 		       const char *__restrict __format, ...)
      __attribute__ ((__format__ (__printf__, 3, 4)));
-#  if __LONG_DOUBLE_USES_FLOAT128 == 0
-libc_hidden_proto (__snprintf)
-#  endif
+stdio_hidden_ldbl_proto (__, snprintf)
+
 extern int __vfscanf (FILE *__restrict __s,
 		      const char *__restrict __format,
 		      __gnuc_va_list __arg)
@@ -66,6 +77,7 @@ extern int __isoc99_vscanf (const char *__restrict __format,
 extern int __isoc99_vsscanf (const char *__restrict __s,
 			     const char *__restrict __format,
 			     __gnuc_va_list __arg) __THROW;
+
 libc_hidden_proto (__isoc99_sscanf)
 libc_hidden_proto (__isoc99_vsscanf)
 libc_hidden_proto (__isoc99_vfscanf)
@@ -74,12 +86,25 @@ libc_hidden_proto (__isoc99_vfscanf)
    Unfortunately, symbol redirection is not transitive, so the
    __REDIRECT in the public header does not link up with the above
    libc_hidden_proto.  Bridge the gap with a macro.  */
-#  if !__GLIBC_USE (DEPRECATED_SCANF) \
-      && __LONG_DOUBLE_USES_FLOAT128 == 0
+#  if !__GLIBC_USE (DEPRECATED_SCANF)
 #   undef sscanf
 #   define sscanf __isoc99_sscanf
 #  endif
 
+#  if __LONG_DOUBLE_USES_FLOAT128 == 1  && IS_IN (libc)
+/* These are implemented as redirects to other public API.
+   Therefore, the usual redirection fails to avoid PLT.  */
+extern __typeof (__isoc99_sscanf) ___ieee128_isoc99_sscanf __THROW;
+extern __typeof (__isoc99_vsscanf) ___ieee128_isoc99_vsscanf __THROW;
+extern __typeof (__isoc99_vfscanf) ___ieee128_isoc99_vfscanf __THROW;
+libc_hidden_proto (___ieee128_isoc99_sscanf)
+libc_hidden_proto (___ieee128_isoc99_vsscanf)
+libc_hidden_proto (___ieee128_isoc99_vfscanf)
+#define __isoc99_sscanf ___ieee128_isoc99_sscanf
+#define __isoc99_vsscanf ___ieee128_isoc99_vsscanf
+#define __isoc99_vfscanf ___ieee128_isoc99_vfscanf
+#  endif
+
 /* Prototypes for compatibility functions.  */
 extern FILE *__new_tmpfile (void);
 extern FILE *__old_tmpfile (void);
@@ -153,9 +178,8 @@ libc_hidden_proto (__libc_readline_unlocked);
 extern const char *const _sys_errlist_internal[] attribute_hidden;
 extern int _sys_nerr_internal attribute_hidden;
 
-#if __LONG_DOUBLE_USES_FLOAT128 == 0
-libc_hidden_proto (__asprintf)
-#endif
+libc_hidden_ldbl_proto (__asprintf)
+
 #  if IS_IN (libc)
 extern FILE *_IO_new_fopen (const char*, const char*);
 #   define fopen(fname, mode) _IO_new_fopen (fname, mode)
@@ -178,13 +202,11 @@ extern int _IO_new_fgetpos (FILE *, __fpos_t *);
 
 extern __typeof (dprintf) __dprintf
      __attribute__ ((__format__ (__printf__, 2, 3)));
-libc_hidden_proto (__dprintf)
-#if __LONG_DOUBLE_USES_FLOAT128 == 0
-libc_hidden_proto (dprintf)
-libc_hidden_proto (fprintf)
-libc_hidden_proto (vfprintf)
-libc_hidden_proto (sprintf)
-#endif
+stdio_hidden_ldbl_proto (__, dprintf)
+libc_hidden_ldbl_proto (dprintf)
+libc_hidden_ldbl_proto (fprintf)
+libc_hidden_ldbl_proto (vfprintf)
+libc_hidden_ldbl_proto (sprintf)
 libc_hidden_proto (fwrite)
 libc_hidden_proto (perror)
 libc_hidden_proto (remove)
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 524fe57a25..9f44ac5a0a 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -13,6 +13,26 @@ extern void __chk_fail (void) __attribute__ ((__noreturn__));
 libc_hidden_proto (__chk_fail)
 rtld_hidden_proto (__chk_fail)
 
+/* 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(func) \
+   extern __typeof(func) func __asm (__ASMNAME ("__GI____ieee128_" #func));
+
+# undef libc_hidden_ldbl_proto
+# define libc_hidden_ldbl_proto(func, attrs...) \
+   extern __typeof(func) ___ieee128_ ## func; \
+   libc_hidden_proto (___ieee128_ ## func, ##attrs);
+
+# undef __LDBL_REDIR2_DECL
+# define __LDBL_REDIR2_DECL(func) \
+   extern __typeof(__ ## func) __ ## func __asm (__ASMNAME ("__GI____ieee128___" #func));
+
 #endif
 
+#endif /* !defined _ISOMAC */
+
 #endif
diff --git a/include/sys/syslog.h b/include/sys/syslog.h
index 89d3479ebc..44422eab13 100644
--- a/include/sys/syslog.h
+++ b/include/sys/syslog.h
@@ -3,7 +3,7 @@
 #include <misc/sys/syslog.h>
 #ifndef _ISOMAC
 
-libc_hidden_proto (syslog)
+libc_hidden_ldbl_proto (syslog)
 
 /* __vsyslog_internal uses the same mode_flags bits as
    __v*printf_internal; see libio/libioP.h.  */
diff --git a/include/wchar.h b/include/wchar.h
index c792b38943..617906eb14 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -64,7 +64,7 @@ libc_hidden_proto (__wcstoul_internal)
 libc_hidden_proto (__wcstoull_internal)
 libc_hidden_proto (wcstof)
 libc_hidden_proto (wcstod)
-libc_hidden_proto (wcstold)
+libc_hidden_ldbl_proto (wcstold)
 libc_hidden_proto (wcstol)
 libc_hidden_proto (wcstoll)
 libc_hidden_proto (wcstoul)