diff mbox series

libio: Fix oversized __io_vtables

Message ID 20230908195519.294176-1-ajax@redhat.com
State New
Headers show
Series libio: Fix oversized __io_vtables | expand

Commit Message

Adam Jackson Sept. 8, 2023, 7:55 p.m. UTC
IO_VTABLES_LEN is the size of the struct array in bytes, not the number
of __IO_jump_t's in the array. Drops just under 384kb from .rodata on
LP64 machines.

Fixes: 3020f72618e ("libio: Remove the usage of __libc_IO_vtables")
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 libio/vtables.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Florian Weimer Sept. 8, 2023, 8:59 p.m. UTC | #1
* Adam Jackson:

> IO_VTABLES_LEN is the size of the struct array in bytes, not the number
> of __IO_jump_t's in the array. Drops just under 384kb from .rodata on
> LP64 machines.
>
> Fixes: 3020f72618e ("libio: Remove the usage of __libc_IO_vtables")
> Signed-off-by: Adam Jackson <ajax@redhat.com>

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Tested-by: Florian Weimer <fweimer@redhat.com>

And applied.  Thanks!

Florian
diff mbox series

Patch

diff --git a/libio/vtables.c b/libio/vtables.c
index 1d8ad612e94..34f7e15f1c2 100644
--- a/libio/vtables.c
+++ b/libio/vtables.c
@@ -18,10 +18,11 @@ 
 
 #include <dlfcn.h>
 #include <libioP.h>
 #include <stdio.h>
 #include <ldsodefs.h>
+#include <array_length.h>
 #include <pointer_guard.h>
 #include <libio-macros.h>
 
 /* Both _IO_str_* and _IO_new_file functions are pulled into every link (from
    stdio initialization).  */
@@ -86,11 +87,11 @@ 
 
 # pragma weak __wprintf_buffer_as_file_overflow
 # pragma weak __wprintf_buffer_as_file_xsputn
 #endif
 
-const struct _IO_jump_t __io_vtables[IO_VTABLES_LEN] attribute_relro =
+const struct _IO_jump_t __io_vtables[] attribute_relro =
 {
   /* _IO_str_jumps  */
   [IO_STR_JUMPS] =
   {
     JUMP_INIT_DUMMY,
@@ -483,10 +484,12 @@  const struct _IO_jump_t __io_vtables[IO_VTABLES_LEN] attribute_relro =
     JUMP_INIT (showmanyc, _IO_default_showmanyc),
     JUMP_INIT (imbue, _IO_default_imbue),
   },
 #endif
 };
+_Static_assert (array_length (__io_vtables) == IO_VTABLES_NUM,
+                "initializer count");
 
 #ifdef SHARED
 
 void (*IO_accept_foreign_vtables) (void) attribute_hidden;