[PATCH] libio: Properly link in function _IO_wfile_doallocate in static binaries

yunzezhu@linux.alibaba.com yunzezhu@linux.alibaba.com
Fri Mar 6 02:17:15 GMT 2026


From: Yunze Zhu <yunzezhu@linux.alibaba.com>

This patch fixes Bug 33935 - _IO_wfile_doallocate not linked correctly
when linking glibc statically.
https://sourceware.org/bugzilla/show_bug.cgi?id=33935

The function _IO_wfile_doallocate has been added with pragma weak in vtable.c,
while it is the only one symbol contained in wfiledoalloc.c,
and has not been directly called in libio.

In static binaries the true function symbol _IO_wfile_doallocate may not
be correctly linked when linking glibc with cases contains wchar functions,
but the weak symbol in vtable is linked instead,
and cause segmentation fault when running.

This patch fixes this with similar way to symbol _IO_file_doallocate,
that adding libio_static_fn_required(_IO_wfile_doallocate) in wgenops.c
to make _IO_wfile_doallocate always link in static binaries.
---
 libio/wgenops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libio/wgenops.c b/libio/wgenops.c
index 7a8466ea44..064d71266d 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -34,6 +34,8 @@
 
 static int save_for_wbackup (FILE *fp, wchar_t *end_p) __THROW;
 
+libio_static_fn_required (_IO_wfile_doallocate);
+
 /* Return minimum _pos markers
    Assumes the current get area is the main get area. */
 ssize_t
-- 
2.47.1



More information about the Libc-alpha mailing list