From patchwork Fri Sep 8 19:55:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Jackson X-Patchwork-Id: 75583 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D3513858416 for ; Fri, 8 Sep 2023 19:55:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 55FF63858D1E for ; Fri, 8 Sep 2023 19:55:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55FF63858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694202922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xl2yrwWlYT0/pWb0ggKuz3+zPWjqfmLPLBYGpPtEIHA=; b=TnpTCu/n9oZA9J3la9vkyIjEdjxap7eQbcVAGoecLnbAAOHtFHdV2bQblyEbejw84fQHV1 /T52Hh6Q7KJXr7/MYNFtCTZDiW/01bngXWwyXKJsuZyr/U5bSsNmHdyfGDjHe9Cun3lWD0 Jed84ZxYW+3HXRQMDhtXncqCMtnl7IQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-qVqvXFaoNoCJLGHYHTYe_g-1; Fri, 08 Sep 2023 15:55:20 -0400 X-MC-Unique: qVqvXFaoNoCJLGHYHTYe_g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20EC5816527 for ; Fri, 8 Sep 2023 19:55:20 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.22.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2648140E963 for ; Fri, 8 Sep 2023 19:55:19 +0000 (UTC) From: Adam Jackson To: libc-alpha@sourceware.org Subject: [PATCH] libio: Fix oversized __io_vtables Date: Fri, 8 Sep 2023 15:55:19 -0400 Message-ID: <20230908195519.294176-1-ajax@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org 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 Reviewed-by: Florian Weimer Tested-by: Florian Weimer --- 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 #include #include #include +#include #include #include /* 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;