diff options
Diffstat (limited to 'libio')
-rw-r--r-- | libio/Makefile | 9 | ||||
-rw-r--r-- | libio/filedoalloc.c | 12 | ||||
-rw-r--r-- | libio/libioP.h | 3 | ||||
-rw-r--r-- | libio/tst-stdio-static.c | 28 |
4 files changed, 40 insertions, 12 deletions
diff --git a/libio/Makefile b/libio/Makefile index f020f8e..6ce669e 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -130,6 +130,7 @@ tests = \ tst-sprintf-chk-ub \ tst-sprintf-ub \ tst-sscanf \ + tst-stdio-static \ tst-swscanf \ tst-ungetwc1 \ tst-ungetwc2 \ @@ -149,6 +150,8 @@ tests = \ tst_wscanf \ # tests +tests-static += tst-stdio-static + $(objpfx)tst-popen-fork: $(shared-thread-library) tests-internal = tst-vtables tst-vtables-interposed @@ -445,3 +448,9 @@ $(objpfx)tst-bz22415-mem.out: $(objpfx)tst-bz22415.out $(objpfx)tst-bz24228-mem.out: $(objpfx)tst-bz24228.out $(common-objpfx)malloc/mtrace $(objpfx)tst-bz24228.mtrace > $@; \ $(evaluate-test) + +# Test stdio.o with "strip --strip-unneeded". +$(objpfx)tst-stdio-static: $(objpfx)stdio-stripped.o + +$(objpfx)stdio-stripped.o: $(objpfx)stdio.o + $(STRIP) --strip-unneeded -o $@ $< diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index 9ddd75b..f360d96 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -61,16 +61,6 @@ #include <stdlib.h> #include <unistd.h> -/* Return the result of isatty, without changing errno. */ -static int -local_isatty (int fd) -{ - int save_errno = errno; - int res = __isatty (fd); - __set_errno (save_errno); - return res; -} - /* Allocate a file buffer, or switch to unbuffered I/O. Streams for TTY devices default to line buffered. */ int @@ -90,7 +80,7 @@ _IO_file_doallocate (FILE *fp) #ifdef DEV_TTY_P DEV_TTY_P (&st) || #endif - local_isatty (fp->_fileno)) + __isatty_nostatus (fp->_fileno)) fp->_flags |= _IO_LINE_BUF; } #if defined _STATBUF_ST_BLKSIZE diff --git a/libio/libioP.h b/libio/libioP.h index 1e3d28b..6508e46 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -535,7 +535,8 @@ extern const struct _IO_jump_t __io_vtables[] attribute_hidden; #ifdef SHARED # define libio_static_fn_required(name) #else -# define libio_static_fn_required(name) __asm (".globl " #name); +# define libio_static_fn_required(name) \ + static __typeof (name) *const name##_p __attribute__((used)) = name; #endif extern int _IO_do_write (FILE *, const char *, size_t); diff --git a/libio/tst-stdio-static.c b/libio/tst-stdio-static.c new file mode 100644 index 0000000..48c7f76 --- /dev/null +++ b/libio/tst-stdio-static.c @@ -0,0 +1,28 @@ +/* Test static stdio.o with "strip --strip-unneeded". + Copyright (C) 2025 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <stdio.h> + +/* NB: Call main directly to trigger BZ #33300. */ + +int +main (void) +{ + printf ("OK\n"); + return 0; +} |