public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Use libc_hidden_* for fputs (bug 15105).
@ 2021-11-15 22:40 Fangrui Song
0 siblings, 0 replies; 2+ messages 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=b8365ac9056e572ef9cbf1e40a2691b7e06f1f2e
commit b8365ac9056e572ef9cbf1e40a2691b7e06f1f2e
Author: Joseph Myers <joseph@codesourcery.com>
Date: Thu Feb 15 20:58:16 2018 +0000
Use libc_hidden_* for fputs (bug 15105).
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.
(cherry picked from commit 499b315324519f8deb5b42a143a76319934a3ab0)
Diff:
---
include/stdio.h | 4 ++++
libio/iofputs.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/include/stdio.h b/include/stdio.h
index 602434509f..820ba5491f 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -135,6 +135,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)
diff --git a/libio/iofputs.c b/libio/iofputs.c
index b4fbeb5e60..176e9ed281 100644
--- a/libio/iofputs.c
+++ b/libio/iofputs.c
@@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/google/grte/v5-2.27/master] Use libc_hidden_* for fputs (bug 15105).
@ 2021-11-19 21:21 Fangrui Song
0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-11-19 21:21 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d7c1214f4d417119c4cca5c36c2adfc4d83be8fc
commit d7c1214f4d417119c4cca5c36c2adfc4d83be8fc
Author: Joseph Myers <joseph@codesourcery.com>
Date: Thu Feb 15 20:58:16 2018 +0000
Use libc_hidden_* for fputs (bug 15105).
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.
(cherry picked from commit 499b315324519f8deb5b42a143a76319934a3ab0)
Diff:
---
include/stdio.h | 4 ++++
libio/iofputs.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/include/stdio.h b/include/stdio.h
index f1e987ae5e..6759ed3fb1 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -135,6 +135,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)
diff --git a/libio/iofputs.c b/libio/iofputs.c
index b4fbeb5e60..176e9ed281 100644
--- a/libio/iofputs.c
+++ b/libio/iofputs.c
@@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-19 21:21 UTC | newest]
Thread overview: 2+ messages (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] Use libc_hidden_* for fputs (bug 15105) Fangrui Song
2021-11-19 21:21 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).