aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2012-04-29 15:34:20 +0200
committerMarek Polacek <polacek@redhat.com>2012-04-29 15:34:20 +0200
commit5ac3ea17df811a71fa64aff78ea1b900facd3364 (patch)
tree47a842e0be1ca4d8c98ecc86d18330d61047560a
parentecf0ebfb04f6e31e3ba709521b6955d5f86ff724 (diff)
downloadglibc-5ac3ea17df811a71fa64aff78ea1b900facd3364.tar.xz
glibc-5ac3ea17df811a71fa64aff78ea1b900facd3364.zip
Fix attributes for fortify functions.
-rw-r--r--ChangeLog32
-rw-r--r--debug/tst-chk1.c2
-rw-r--r--include/stdio.h2
-rw-r--r--io/bits/fcntl2.h8
-rw-r--r--io/bits/poll2.h4
-rw-r--r--io/fcntl.h2
-rw-r--r--io/sys/poll.h2
-rw-r--r--libio/bits/stdio-ldbl.h2
-rw-r--r--libio/bits/stdio.h2
-rw-r--r--libio/bits/stdio2.h40
-rw-r--r--misc/bits/syslog-ldbl.h4
-rw-r--r--misc/bits/syslog.h4
-rw-r--r--misc/sys/cdefs.h23
-rw-r--r--misc/sys/syslog.h2
-rw-r--r--posix/bits/unistd.h28
-rw-r--r--posix/unistd.h2
-rw-r--r--rt/bits/mqueue2.h2
-rw-r--r--rt/mqueue.h2
-rw-r--r--socket/bits/socket2.h6
-rw-r--r--socket/sys/socket.h2
-rw-r--r--stdlib/bits/stdlib.h10
-rw-r--r--stdlib/stdlib.h2
-rw-r--r--string/bits/string3.h24
-rw-r--r--string/string.h2
-rw-r--r--wcsmbs/bits/wchar-ldbl.h8
-rw-r--r--wcsmbs/bits/wchar2.h46
-rw-r--r--wcsmbs/wchar.h2
27 files changed, 148 insertions, 117 deletions
diff --git a/ChangeLog b/ChangeLog
index ed5b53363f..2de9a0c72a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2012-04-29 Marek Polacek <polacek@redhat.com>
+
+ * misc/sys/cdefs.h (__attribute_artificial__): New macro.
+ (__fortify_function): New macro.
+ (__extern_always_inline): Don't use __attribute__ ((__artificial__)).
+ * libio/bits/stdio-ldbl.h: Use __fortify_function in place of
+ __extern_always_inline.
+ * libio/bits/stdio2.h: Likewise.
+ * libio/bits/stdio.h: Likewise.
+ * string/string.h: Likewise.
+ * string/bits/string3.h: Likewise.
+ * include/stdio.h: Likewise.
+ * stdlib/bits/stdlib.h: Likewise.
+ * stdlib/stdlib.h: Likewise.
+ * rt/bits/mqueue2.h: Likewise.
+ * rt/mqueue.h: Likewise.
+ * posix/bits/unistd.h: Likewise.
+ * posix/unistd.h: Likewise.
+ * io/bits/poll2.h: Likewise.
+ * io/bits/fcntl2.h: Likewise.
+ * io/fcntl.h: Likewise.
+ * io/sys/poll.h: Likewise.
+ * misc/bits/syslog.h: Likewise.
+ * misc/bits/syslog-ldbl.h: Likewise.
+ * misc/sys/syslog.h: Likewise.
+ * socket/bits/socket2.h: Likewise.
+ * socket/sys/socket.h: Likewise.
+ * debug/tst-chk1.c: Likewise.
+ * wcsmbs/bits/wchar2.h: Likewise.
+ * wcsmbs/bits/wchar-ldbl.h: Likewise.
+ * wcsmbs/wchar.h: Likewise.
+
2012-04-29 Andreas Jaeger <aj@suse.de>
* Makerules (tests): Remove enable-check-abi protection.
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index b8745ee66c..7ffc9fec90 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -148,7 +148,7 @@ do_test (void)
#endif
);
-#if defined __USE_FORTIFY_LEVEL && !defined __extern_always_inline
+#if defined __USE_FORTIFY_LEVEL && !defined __fortify_function
printf ("Test skipped");
if (l0 == 0)
return 0;
diff --git a/include/stdio.h b/include/stdio.h
index bd0209aaac..a2c73a452d 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -176,7 +176,7 @@ extern char *__REDIRECT (__gets_warn, (char *__str), gets)
__wur __warnattr ("please use fgets or getline instead, gets can't "
"specify buffer size");
-__extern_always_inline __wur char *
+__fortify_function __wur char *
gets (char *__str)
{
if (__bos (__str) != (size_t) -1)
diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
index 09b81e6a8a..76df18b1d7 100644
--- a/io/bits/fcntl2.h
+++ b/io/bits/fcntl2.h
@@ -37,7 +37,7 @@ __errordecl (__open_too_many_args,
__errordecl (__open_missing_mode,
"open with O_CREAT in second argument needs 3 arguments");
-__extern_always_inline int
+__fortify_function int
open (const char *__path, int __oflag, ...)
{
if (__va_arg_pack_len () > 1)
@@ -69,7 +69,7 @@ __errordecl (__open64_too_many_args,
__errordecl (__open64_missing_mode,
"open64 with O_CREAT in second argument needs 3 arguments");
-__extern_always_inline int
+__fortify_function int
open64 (const char *__path, int __oflag, ...)
{
if (__va_arg_pack_len () > 1)
@@ -113,7 +113,7 @@ __errordecl (__openat_too_many_args,
__errordecl (__openat_missing_mode,
"openat with O_CREAT in third argument needs 4 arguments");
-__extern_always_inline int
+__fortify_function int
openat (int __fd, const char *__path, int __oflag, ...)
{
if (__va_arg_pack_len () > 1)
@@ -147,7 +147,7 @@ __errordecl (__openat64_too_many_args,
__errordecl (__openat64_missing_mode,
"openat64 with O_CREAT in third argument needs 4 arguments");
-__extern_always_inline int
+__fortify_function int
openat64 (int __fd, const char *__path, int __oflag, ...)
{
if (__va_arg_pack_len () > 1)
diff --git a/io/bits/poll2.h b/io/bits/poll2.h
index 862de2879e..404af1f7d8 100644
--- a/io/bits/poll2.h
+++ b/io/bits/poll2.h
@@ -32,7 +32,7 @@ extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
__poll_chk)
__warnattr ("poll called with fds buffer too small file nfds entries");
-__extern_always_inline int
+__fortify_function int
poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
{
if (__bos (__fds) != (__SIZE_TYPE__) -1)
@@ -61,7 +61,7 @@ extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
__ppoll_chk)
__warnattr ("ppoll called with fds buffer too small file nfds entries");
-__extern_always_inline int
+__fortify_function int
ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
const __sigset_t *__ss)
{
diff --git a/io/fcntl.h b/io/fcntl.h
index 1192cf584c..8b8726a440 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -263,7 +263,7 @@ extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len);
/* Define some inlines helping to catch common problems. */
-#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
&& defined __va_arg_pack_len
# include <bits/fcntl2.h>
#endif
diff --git a/io/sys/poll.h b/io/sys/poll.h
index 6089b618b6..9d78ff8360 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -72,7 +72,7 @@ __END_DECLS
/* Define some inlines helping to catch common problems. */
-#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
# include <bits/poll2.h>
#endif
diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
index 5700dd9d7d..3cc6ec416d 100644
--- a/libio/bits/stdio-ldbl.h
+++ b/libio/bits/stdio-ldbl.h
@@ -75,7 +75,7 @@ __LDBL_REDIR_DECL (obstack_printf)
__LDBL_REDIR_DECL (obstack_vprintf)
#endif
-#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
__LDBL_REDIR_DECL (__sprintf_chk)
__LDBL_REDIR_DECL (__vsprintf_chk)
# if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h
index 81f4c7dd03..4dbfef8254 100644
--- a/libio/bits/stdio.h
+++ b/libio/bits/stdio.h
@@ -30,7 +30,7 @@
#ifdef __USE_EXTERN_INLINES
/* For -D_FORTIFY_SOURCE{,=2} bits/stdio2.h will define a different
inline. */
-# if !(__USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline)
+# if !(__USE_FORTIFY_LEVEL > 0 && defined __fortify_function)
/* Write formatted output to stdout from argument list ARG. */
__STDIO_INLINE int
vprintf (const char *__restrict __fmt, _G_va_list __arg)
diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h
index 7b0bdeb95f..2aca88d029 100644
--- a/libio/bits/stdio2.h
+++ b/libio/bits/stdio2.h
@@ -27,7 +27,7 @@ extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
_G_va_list __ap) __THROW;
#ifdef __va_arg_pack
-__extern_always_inline int
+__fortify_function int
__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
{
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
@@ -39,7 +39,7 @@ __NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
__VA_ARGS__)
#endif
-__extern_always_inline int
+__fortify_function int
__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
_G_va_list __ap))
{
@@ -57,7 +57,7 @@ extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
_G_va_list __ap) __THROW;
# ifdef __va_arg_pack
-__extern_always_inline int
+__fortify_function int
__NTH (snprintf (char *__restrict __s, size_t __n,
const char *__restrict __fmt, ...))
{
@@ -70,7 +70,7 @@ __NTH (snprintf (char *__restrict __s, size_t __n,
__VA_ARGS__)
# endif
-__extern_always_inline int
+__fortify_function int
__NTH (vsnprintf (char *__restrict __s, size_t __n,
const char *__restrict __fmt, _G_va_list __ap))
{
@@ -91,14 +91,14 @@ extern int __vprintf_chk (int __flag, const char *__restrict __format,
_G_va_list __ap);
# ifdef __va_arg_pack
-__extern_always_inline int
+__fortify_function int
fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
{
return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
__va_arg_pack ());
}
-__extern_always_inline int
+__fortify_function int
printf (const char *__restrict __fmt, ...)
{
return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
@@ -110,7 +110,7 @@ printf (const char *__restrict __fmt, ...)
__fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
# endif
-__extern_always_inline int
+__fortify_function int
vprintf (const char *__restrict __fmt, _G_va_list __ap)
{
#ifdef __USE_EXTERN_INLINES
@@ -120,7 +120,7 @@ vprintf (const char *__restrict __fmt, _G_va_list __ap)
#endif
}
-__extern_always_inline int
+__fortify_function int
vfprintf (FILE *__restrict __stream,
const char *__restrict __fmt, _G_va_list __ap)
{
@@ -151,14 +151,14 @@ extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
__THROW __attribute__ ((__format__ (__printf__, 3, 0)));
# ifdef __va_arg_pack
-__extern_always_inline int
+__fortify_function int
__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...))
{
return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
__va_arg_pack ());
}
-__extern_always_inline int
+__fortify_function int
__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
...))
{
@@ -166,14 +166,14 @@ __NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
__va_arg_pack ());
}
-__extern_always_inline int
+__fortify_function int
dprintf (int __fd, const char *__restrict __fmt, ...)
{
return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt,
__va_arg_pack ());
}
-__extern_always_inline int
+__fortify_function int
__NTH (obstack_printf (struct obstack *__restrict __obstack,
const char *__restrict __fmt, ...))
{
@@ -191,20 +191,20 @@ __NTH (obstack_printf (struct obstack *__restrict __obstack,
__obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
# endif
-__extern_always_inline int
+__fortify_function int
__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
_G_va_list __ap))
{
return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
}
-__extern_always_inline int
+__fortify_function int
vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap)
{
return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
}
-__extern_always_inline int
+__fortify_function int
__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
const char *__restrict __fmt, _G_va_list __ap))
{
@@ -223,7 +223,7 @@ extern char *__REDIRECT (__gets_warn, (char *__str), gets)
__wur __warnattr ("please use fgets or getline instead, gets can't "
"specify buffer size");
-__extern_always_inline __wur char *
+__fortify_function __wur char *
gets (char *__str)
{
if (__bos (__str) != (size_t) -1)
@@ -243,7 +243,7 @@ extern char *__REDIRECT (__fgets_chk_warn,
__wur __warnattr ("fgets called with bigger size than length "
"of destination buffer");
-__extern_always_inline __wur char *
+__fortify_function __wur char *
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
{
if (__bos (__s) != (size_t) -1)
@@ -272,7 +272,7 @@ extern size_t __REDIRECT (__fread_chk_warn,
__wur __warnattr ("fread called with bigger size * nmemb than length "
"of destination buffer");
-__extern_always_inline __wur size_t
+__fortify_function __wur size_t
fread (void *__restrict __ptr, size_t __size, size_t __n,
FILE *__restrict __stream)
{
@@ -301,7 +301,7 @@ extern char *__REDIRECT (__fgets_unlocked_chk_warn,
__wur __warnattr ("fgets_unlocked called with bigger size than length "
"of destination buffer");
-__extern_always_inline __wur char *
+__fortify_function __wur char *
fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
{
if (__bos (__s) != (size_t) -1)
@@ -333,7 +333,7 @@ extern size_t __REDIRECT (__fread_unlocked_chk_warn,
__wur __warnattr ("fread_unlocked called with bigger size * nmemb than "
"length of destination buffer");
-__extern_always_inline __wur size_t
+__fortify_function __wur size_t
fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
FILE *__restrict __stream)
{
diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
index f71dbb46fd..bd70a51911 100644
--- a/misc/bits/syslog-ldbl.h
+++ b/misc/bits/syslog-ldbl.h
@@ -1,5 +1,5 @@
/* -mlong-double-64 compatibility mode for syslog functions.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006-2012 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
@@ -26,7 +26,7 @@ __LDBL_REDIR_DECL (syslog)
__LDBL_REDIR_DECL (vsyslog)
#endif
-#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
__LDBL_REDIR_DECL (__syslog_chk)
# ifdef __USE_BSD
diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h
index dc7c75be50..f9af61dce9 100644
--- a/misc/bits/syslog.h
+++ b/misc/bits/syslog.h
@@ -25,7 +25,7 @@ extern void __syslog_chk (int __pri, int __flag, const char *__fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
#ifdef __va_arg_pack
-__extern_always_inline void
+__fortify_function void
syslog (int __pri, const char *__fmt, ...)
{
__syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
@@ -41,7 +41,7 @@ extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt,
__gnuc_va_list __ap)
__attribute__ ((__format__ (__printf__, 3, 0)));
-__extern_always_inline void
+__fortify_function void
vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
{
__vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 724f26e399..f4e96dbe6a 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -140,6 +140,7 @@
/* Fortify support. */
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
+#define __fortify_function __extern_always_inline __attribute_artificial__
#if __GNUC_PREREQ (4,3)
# define __warndecl(name, msg) \
@@ -309,26 +310,24 @@
# define __always_inline __inline
#endif
+/* Associate error messages with the source location of the call site rather
+ than with the source location inside the function. */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
inline semantics, unless -fgnu89-inline is used. */
#if !defined __cplusplus || __GNUC_PREREQ (4,3)
# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
-# if __GNUC_PREREQ (4,3)
-# define __extern_always_inline \
- extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
-# else
-# define __extern_always_inline \
+# define __extern_always_inline \
extern __always_inline __attribute__ ((__gnu_inline__))
-# endif
# else
# define __extern_inline extern __inline
-# if __GNUC_PREREQ (4,3)
-# define __extern_always_inline \
- extern __always_inline __attribute__ ((__artificial__))
-# else
-# define __extern_always_inline extern __always_inline
-# endif
+# define __extern_always_inline extern __always_inline
# endif
#endif
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
index aed419e446..77123ab503 100644
--- a/misc/sys/syslog.h
+++ b/