From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 90CED386DC7D for ; Thu, 30 Jun 2022 11:35:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 90CED386DC7D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id D12A630146AC; Thu, 30 Jun 2022 13:35:10 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id D796E407903B; Thu, 30 Jun 2022 13:35:09 +0200 (CEST) From: Mark Wielaard To: dwz@sourceware.org Cc: Mark Wielaard Subject: [PATCH] Mark and init shstrtab[_len] and const in optimize_multifile Date: Thu, 30 Jun 2022 13:34:55 +0200 Message-Id: <20220630113455.30700-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 11:35:15 -0000 Old gcc (4.8.5) warn that shstrtab and shstrtab_len can be clobbered by the longjump. Work around that by marking shstrtab_gnu and shstrtab_dwarf5 as static and shstrtab and shstrtab_len as const. Init shstrtab and shstrtab_len at declaration. * dwz.c (optimize_multifile): Make shstrtab_[gnu|dwarf5], shstrtab[_len] static. shstrtab[_len] init and make const. --- https://code.wildebeest.org/git/user/mjw/dwz/commit/?h=static-const-shstrtab dwz.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/dwz.c b/dwz.c index a3b289f..266d7e7 100644 --- a/dwz.c +++ b/dwz.c @@ -15589,15 +15589,17 @@ optimize_multifile (unsigned int *die_count) Elf_Scn *scn; Elf_Data *data; char *e_ident; - const char shstrtab_gnu[] + static const char shstrtab_gnu[] = "\0.shstrtab\0.note.gnu.build-id\0.gdb_index\0" ".debug_info\0.debug_abbrev\0.debug_line\0.debug_str\0.debug_macro"; - const char shstrtab_dwarf5[] + static const char shstrtab_dwarf5[] = "\0.shstrtab\0.gdb_index\0" ".debug_info\0.debug_abbrev\0.debug_line\0.debug_str\0.debug_macro\0" ".debug_sup"; - const char *shstrtab; - size_t shstrtab_len; + const char *shstrtab = dwarf_5 ? shstrtab_dwarf5 : shstrtab_gnu; + const size_t shstrtab_len = (dwarf_5 + ? sizeof shstrtab_dwarf5 + : sizeof shstrtab_gnu); const char *p; unsigned char note[0x24], *np, *supp; struct sha1_ctx ctx; @@ -15623,16 +15625,6 @@ optimize_multifile (unsigned int *die_count) fprintf (stderr, "optimize_multifile\n"); } - if (dwarf_5) - { - shstrtab = shstrtab_dwarf5; - shstrtab_len = sizeof shstrtab_dwarf5; - } - else - { - shstrtab = shstrtab_gnu; - shstrtab_len = sizeof shstrtab_gnu; - } debug_sections[DEBUG_INFO].size = multi_info_off; debug_sections[DEBUG_INFO].data = (multi_info_off -- 2.18.4