public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [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

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

* 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


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

* Re: [PATCH] libio: Fix oversized __io_vtables
  2023-09-08 11:20 ` Florian Weimer
@ 2023-09-08 19:54   ` Adam Jackson
  0 siblings, 0 replies; 5+ messages in thread
From: Adam Jackson @ 2023-09-08 19:54 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

On Fri, Sep 8, 2023 at 7:20 AM Florian Weimer <fweimer@redhat.com> wrote:

Maybe use [] and
>
> _Static_assert (array_length (__io_vtables) == IO_VTABLES_NUM,
>                 "initializer count);
>
> after the definition?
>
> Let me know if you want to make this change.  I've got a machine
> checkout that can build glibc on all supported architectures fairly
> quickly.
>

Sure. I'll send a new patch, I spotted a grammar-o in the commit message.

- ajax

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

* Re: [PATCH] libio: Fix oversized __io_vtables
  2023-09-07 19:38 Adam Jackson
@ 2023-09-08 11:20 ` Florian Weimer
  2023-09-08 19:54   ` Adam Jackson
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2023-09-08 11:20 UTC (permalink / raw)
  To: Adam Jackson; +Cc: libc-alpha

* Adam Jackson:

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

Ouch, thanks for spotting this.

I think it's this Debian and Ubuntu bug:

  djbdns: Fix for tests with new glibc 2.38
  <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050371>

  tinydns: allocation failures with glibc 2.38/s390x
  <https://bugs.launchpad.net/ubuntu/+source/djbdns/+bug/2031909>

> 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,

Maybe use [] and

_Static_assert (array_length (__io_vtables) == IO_VTABLES_NUM,
                "initializer count);

after the definition?

Let me know if you want to make this change.  I've got a machine
checkout that can build glibc on all supported architectures fairly
quickly.

Thanks,
Florian


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

* [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

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-08 19:55 [PATCH] libio: Fix oversized __io_vtables Adam Jackson
2023-09-08 20:59 ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2023-09-07 19:38 Adam Jackson
2023-09-08 11:20 ` Florian Weimer
2023-09-08 19:54   ` Adam Jackson

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