]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use libc_hidden_* for fputs (bug 15105).
authorJoseph Myers <joseph@codesourcery.com>
Thu, 15 Feb 2018 20:58:16 +0000 (20:58 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 15 Feb 2018 20:58:16 +0000 (20:58 +0000)
Among other localplt test failures when building with -Os, there are
libc.so PLT references for fputs.  fputs calls normally get redirected
to _IO_fputs by a macro in include/stdio.h (and _IO_fputs in turn uses
libc_hidden_proto), but GCC can convert an fprintf call with a
constant string argument into an fputs call, which of course is then
unaffected by the macro redirection.  (I don't know why this issue
only appears with -Os.)

This patch duly adds a use of libc_hidden_proto for fputs.  I see no
obvious reason why the fputs macro redirection is needed at all, but
this patch does not change it.

Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).

[BZ #15105]
* include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use
libc_hidden_proto.
* libio/iofputs.c (fputs): Use libc_hidden_weak.

ChangeLog
include/stdio.h
libio/iofputs.c

index 3571a464df2f6cde1136c9649504edd832e234a4..36ee49336afc93f0ba5590c797e919431d434996 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-02-15  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #15105]
+       * include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use
+       libc_hidden_proto.
+       * libio/iofputs.c (fputs): Use libc_hidden_weak.
+
        [BZ #15105]
        [BZ #19463]
        * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
index 7ab3ddd942dc4340c6d59ab39ceb02e0cbe4ec24..7871000071956419686d56dcafa7e50c76b18f0c 100644 (file)
@@ -140,6 +140,10 @@ extern int _IO_new_fclose (_IO_FILE*);
 #   define fclose(fp) _IO_new_fclose (fp)
 extern int _IO_fputs (const char*, _IO_FILE*);
 libc_hidden_proto (_IO_fputs)
+/* The compiler may optimize calls to fprintf into calls to fputs.
+   Use libc_hidden_proto to ensure that those calls, not redirected by
+   the fputs macro, also do not go through the PLT.  */
+libc_hidden_proto (fputs)
 #   define fputs(str, fp) _IO_fputs (str, fp)
 extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
 #   define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp)
index b4fbeb5e6092f9015622f8258250e085459acd4c..176e9ed28139d78822844e209225cc54a76ef90d 100644 (file)
@@ -43,6 +43,7 @@ _IO_fputs (const char *str, _IO_FILE *fp)
 libc_hidden_def (_IO_fputs)
 
 weak_alias (_IO_fputs, fputs)
+libc_hidden_weak (fputs)
 
 # ifndef _IO_MTSAFE_IO
 strong_alias (_IO_fputs, __fputs_unlocked)