From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hBjoEWWLJ2GeKgAAWB0awg (envelope-from ) for ; Thu, 26 Aug 2021 08:39:01 -0400 Received: by simark.ca (Postfix, from userid 112) id 2EEBD1EE1B; Thu, 26 Aug 2021 08:39:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 60E421EDEE for ; Thu, 26 Aug 2021 08:39:00 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 962F63857C6D for ; Thu, 26 Aug 2021 12:38:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 962F63857C6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629981539; bh=BJkrP9SLy7qjH+P5rjb+BQU8An3qNszWmpcZhkH0kMY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xh2cU4u/1iGwLA6jsTxfMZRmLQDDH3ylgMurtp84u338775nSsblc0Ag0TyLJyZaM 4Igqzsu8sBD6yxDzkbypcpb3fXPMZ6nr7Xx54tZFHmp1yhBIw3+TZNisgPDRvJZr+X hXWAu5rZ6Af3z2RN793IdZvHCcNq7uCXSXH9ADAY= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A64F93858402 for ; Thu, 26 Aug 2021 12:38:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A64F93858402 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BE2C3201A9 for ; Thu, 26 Aug 2021 12:38:30 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A0F85132FD for ; Thu, 26 Aug 2021 12:38:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id /yU/JkaLJ2HtRwAAGKfGzw (envelope-from ) for ; Thu, 26 Aug 2021 12:38:30 +0000 Date: Thu, 26 Aug 2021 14:38:29 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/symtab] Don't write .gdb_index symbol table with empty entries Message-ID: <20210826123827.GA29487@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, When comparing the sizes of the index files generated for shlib outputs/gdb.dwarf2/dw2-zero-range/shr1.sl, I noticed a large difference between .debug_names: ... $ gdb -q -batch $shlib -ex "save gdb-index -dwarf-5 ." $ du -b -h shr1.sl.debug_names shr1.sl.debug_str 61 shr1.sl.debug_names 0 shr1.sl.debug_str ... and .gdb_index: ... $ gdb -q -batch $shlib -ex "save gdb-index ." $ du -b -h shr1.sl.gdb-index 8.2K shr1.sl.gdb-index ... The problem is that the .gdb_index contains a non-empty symbol table with only empty entries. Fix this by making the symbol table empty, such that we have instead: ... $ du -b -h shr1.sl.gdb-index 184 shr1.sl.gdb-index ... Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/symtab] Don't write .gdb_index symbol table with empty entries --- gdb/dwarf2/index-write.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 0fe2bc4dd05..0318b7a81b2 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1385,6 +1385,9 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, uniquify_cu_indices (&symtab); data_buf symtab_vec, constant_pool; + if (symtab.n_elements == 0) + symtab.data.resize (0); + write_hash_table (&symtab, symtab_vec, constant_pool); write_gdbindex_1(out_file, objfile_cu_list, types_cu_list, addr_vec,