public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libio: Fix oversized __io_vtables
@ 2023-09-07 19:38 Adam Jackson
  2023-09-08 11:20 ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Jackson @ 2023-09-07 19:38 UTC (permalink / raw)
  To: libc-alpha

IO_VTABLES_LEN is the expected size of the struct 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libio/vtables.c b/libio/vtables.c
index 1d8ad612e94..7cb894d751d 100644
--- a/libio/vtables.c
+++ b/libio/vtables.c
@@ -86,11 +86,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[IO_VTABLES_NUM] attribute_relro =
 {
   /* _IO_str_jumps  */
   [IO_STR_JUMPS] =
   {
     JUMP_INIT_DUMMY,
-- 
2.41.0


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] libio: Fix oversized __io_vtables
@ 2023-09-08 19:55 Adam Jackson
  2023-09-08 20:59 ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Jackson @ 2023-09-08 19:55 UTC (permalink / raw)
  To: libc-alpha

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(-)

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;
 
-- 
2.41.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-08 20:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07 19:38 [PATCH] libio: Fix oversized __io_vtables Adam Jackson
2023-09-08 11:20 ` Florian Weimer
2023-09-08 19:54   ` Adam Jackson
2023-09-08 19:55 Adam Jackson
2023-09-08 20:59 ` Florian Weimer

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).