1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-10-27 12:15:39 +03:00

libio: Properly link in libio functions in static binaries

commit 3020f72618
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date:   Tue Dec 27 18:11:43 2022 -0300

    libio: Remove the usage of __libc_IO_vtables

added

 #define libio_static_fn_required(name) __asm (".globl " #name);

to link in libio functions in static binaries.  But there is no relocation
in
	.globl	_IO_file_open

and "strip --strip-unneeded" will remove such unreferenced symbols which
breaks static binaries.  Redefine libio_static_fn_required to create a
reference to the required function with

static __typeof (name) *const name##_p __attribute__((used)) = name;

This fixes BZ #33300.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Tested-by: Xi Ruoyao <xry111@xry111.site>
This commit is contained in:
H.J. Lu
2025-08-21 16:57:22 -07:00
parent 3997c50f0b
commit b4ab549ae5
3 changed files with 39 additions and 1 deletions

View File

@@ -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);