public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
@ 2021-11-15 22:40 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-11-15 22:40 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9c29d1a12316038c4586334e6d5e7a9cef12b25e

commit 9c29d1a12316038c4586334e6d5e7a9cef12b25e
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Feb 15 20:57:15 2018 +0000

    Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
    
    Continuing the fixes for linknamespace and localplt test failures with
    -Os that arise from functions not being inlined in that case, this
    patch fixes such failures for feof_unlocked.
    
    The usual approach is followed of adding __feof_unlocked (inlined when
    feof_unlocked is), making calls use it when required for namespace
    reasons, and using libc_hidden_proto / libc_hidden_weak for the
    feof_unlocked weak alias when only localplt but not namespace issues
    are involved.  In the case of getaddrinfo.c, use of __feof_unlocked
    needs to be conditional since that code is also used in nscd (where
    __feof_unlocked is not available).
    
    Tested for x86_64 (both without -Os to make sure that case continues
    to work, and with -Os to make sure all the relevant linknamespace and
    localplt test failures are resolved).  Because of other such failures
    that remain after this patch, neither of the bugs can yet be closed.
    
            [BZ #15105]
            [BZ #19463]
            * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
            define as weak alias of __feof_unlocked.  Use libc_hidden_weak.
            * include/stdio.h (feof_unlocked): Use libc_hidden_proto.
            (__feof_unlocked): New declaration, and inline function if
            [__USE_EXTERN_INLINES].
            * iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked
            instead of feof_unlocked.
            * intl/localealias.c [_LIBC] (FEOF): Likewise.
            * nss/nsswitch.c (nss_parse_file): Likewise.
            * sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area):
            Likewise.
            * time/getdate.c (__getdate_r): Likewise.
            * sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked):
            Define as macro to call __feof_unlocked.
    
    (cherry picked from commit 7fc03cf320f9ed0178babbb33de0550d393b8886)

Diff:
---
 iconv/gconv_conf.c                      |  2 +-
 include/stdio.h                         | 10 ++++++++++
 intl/localealias.c                      |  2 +-
 libio/feof_u.c                          |  4 +++-
 nss/nsswitch.c                          |  2 +-
 sysdeps/posix/getaddrinfo.c             |  4 ++++
 sysdeps/unix/sysv/linux/readonly-area.c |  2 +-
 time/getdate.c                          |  2 +-
 8 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index d6cf9d2a3e..f173cde71b 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -374,7 +374,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
 
   /* Process the known entries of the file.  Comments start with `#' and
      end with the end of the line.  Empty lines are ignored.  */
-  while (!feof_unlocked (fp))
+  while (!__feof_unlocked (fp))
     {
       char *rp, *endp, *word;
       ssize_t n = __getdelim (&line, &line_len, '\n', fp);
diff --git a/include/stdio.h b/include/stdio.h
index f1e987ae5e..602434509f 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -174,6 +174,8 @@ libc_hidden_proto (__fgets_unlocked)
 libc_hidden_proto (fputs_unlocked)
 extern __typeof (fputs_unlocked) __fputs_unlocked;
 libc_hidden_proto (__fputs_unlocked)
+libc_hidden_proto (feof_unlocked)
+extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden;
 libc_hidden_proto (fmemopen)
 /* The prototype needs repeating instead of using __typeof to use
    __THROW in C++ tests.  */
@@ -194,5 +196,13 @@ libc_hidden_proto (__fmemopen)
 extern int __gen_tempfd (int flags);
 libc_hidden_proto (__gen_tempfd)
 
+#  ifdef __USE_EXTERN_INLINES
+__extern_inline int
+__NTH (__feof_unlocked (FILE *__stream))
+{
+  return __feof_unlocked_body (__stream);
+}
+#  endif
+
 # endif /* not _ISOMAC */
 #endif /* stdio.h */
diff --git a/intl/localealias.c b/intl/localealias.c
index f0fefe456c..09e7894002 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -90,7 +90,7 @@ char *alloca ();
 
 /* Some optimizations for glibc.  */
 #ifdef _LIBC
-# define FEOF(fp)		feof_unlocked (fp)
+# define FEOF(fp)		__feof_unlocked (fp)
 # define FGETS(buf, n, fp)	__fgets_unlocked (buf, n, fp)
 #else
 # define FEOF(fp)		feof (fp)
diff --git a/libio/feof_u.c b/libio/feof_u.c
index 581808e09c..9239144a71 100644
--- a/libio/feof_u.c
+++ b/libio/feof_u.c
@@ -30,8 +30,10 @@
 #undef feof_unlocked
 
 int
-feof_unlocked (_IO_FILE *fp)
+__feof_unlocked (_IO_FILE *fp)
 {
   CHECK_FILE (fp, EOF);
   return _IO_feof_unlocked (fp);
 }
+weak_alias (__feof_unlocked, feof_unlocked)
+libc_hidden_weak (feof_unlocked)
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index b0f0c11a3e..ee46f24424 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -599,7 +599,7 @@ nss_parse_file (const char *fname)
 	  last = this;
 	}
     }
-  while (!feof_unlocked (fp));
+  while (!__feof_unlocked (fp));
 
   /* Free the buffer.  */
   free (line);
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index c15f76e547..740bdd1ed7 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -89,6 +89,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 # include <idna.h>
 #endif
 
+#if IS_IN (libc)
+# define feof_unlocked(fp) __feof_unlocked (fp)
+#endif
+
 struct gaih_service
   {
     const char *name;
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index 9cbb6e9d4d..5546bf7e82 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -53,7 +53,7 @@ __readonly_area (const char *ptr, size_t size)
   char *line = NULL;
   size_t linelen = 0;
 
-  while (! feof_unlocked (fp))
+  while (! __feof_unlocked (fp))
     {
       if (_IO_getdelim (&line, &linelen, '\n', fp) <= 0)
 	break;
diff --git a/time/getdate.c b/time/getdate.c
index cde93f7c28..29ad760c29 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -198,7 +198,7 @@ __getdate_r (const char *string, struct tm *tp)
       if (result && *result == '\0')
 	break;
     }
-  while (!feof_unlocked (fp));
+  while (!__feof_unlocked (fp));
 
   free (instr);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-15 22:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 22:40 [glibc/google/grte/v5-2.27/master] Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463) Fangrui Song

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).