From patchwork Tue May 14 10:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 90109 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 13FEB3875423 for ; Tue, 14 May 2024 10:55:15 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 441B5384AB58 for ; Tue, 14 May 2024 10:54:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 441B5384AB58 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 441B5384AB58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715684072; cv=none; b=fL/SQkPUHrXiAfC73CycJraTkq9vTMTQ/5z2gX5PKyBIhR6lmuUnL7j6jCBixZeYQ98pE99GaGAhbmznZJkplxfOF7KEJkI7UerV+rr47ls0I/sg9EDKHesOWD68+c9NJvai4cUKRK/IsQm0rmlq1IkJNjg3carUVqAVNbZMl+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715684072; c=relaxed/simple; bh=1upgqyUe5Z2Xyn/RLqY5pbhGpYgJOBp6WDUJSH6Bhk8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=a2vl4HV/Otj5TlWNJ1k9OTY/dDZD0kwCFBk9TILILr3M+6WxAOBZkVFf47fjeHfhTwL8JTgNpL3PnrqaVDc/AROO8fZEQ3J+9vhdVlTM3jjl96G969D9/ByRoPwvnSrQJOYhraXhBZuZCPuF20NRpuYrO1kr5Vxfdw9Ftge46iA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1046B6091F for ; Tue, 14 May 2024 10:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715684068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EYfcbcx2oiXQr666pYxvH3O4yyIADJQKRrgJTmkSAH0=; b=xJogMDAdpyD0cztVOClW+60yapfrOnuJyAmzHqtLdhNMp3H/l3By9tDnfp2VSknGDOXMr9 Syb4DR4dluK4j2PyICoL/yEXajeuJWFzlkUbGnIsGyJ7frMAX2PTpCnXdidJXH+c4M/0fd ahF6bCELUsLRExwZfICkW29VPv5z26I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715684068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EYfcbcx2oiXQr666pYxvH3O4yyIADJQKRrgJTmkSAH0=; b=pN5wVTopbtmHJpvqtx59ezUA7t4ShRkWbn3xhmSEDtbhxW9xk0QO0Ly/uj3bYwufEDY6Hj h17aXTrzC7w2PKBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xJogMDAd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pN5wVTop DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715684068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EYfcbcx2oiXQr666pYxvH3O4yyIADJQKRrgJTmkSAH0=; b=xJogMDAdpyD0cztVOClW+60yapfrOnuJyAmzHqtLdhNMp3H/l3By9tDnfp2VSknGDOXMr9 Syb4DR4dluK4j2PyICoL/yEXajeuJWFzlkUbGnIsGyJ7frMAX2PTpCnXdidJXH+c4M/0fd ahF6bCELUsLRExwZfICkW29VPv5z26I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715684068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EYfcbcx2oiXQr666pYxvH3O4yyIADJQKRrgJTmkSAH0=; b=pN5wVTopbtmHJpvqtx59ezUA7t4ShRkWbn3xhmSEDtbhxW9xk0QO0Ly/uj3bYwufEDY6Hj h17aXTrzC7w2PKBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EDC561372E for ; Tue, 14 May 2024 10:54:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yKKxOONCQ2YOewAAD6G6ig (envelope-from ) for ; Tue, 14 May 2024 10:54:27 +0000 From: Tom de Vries To: binutils@sourceware.org Subject: [PATCH 1/3] [binutils/readelf] Fix printing of dwarf4 .debug_str_offsets.dwo Date: Tue, 14 May 2024 12:55:20 +0200 Message-Id: <20240514105522.10107-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Score: -5.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 1046B6091F X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[binutils@sourceware.org]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim] X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org When compiling a hello world with dwarf4 split dwarf: ... $ gcc -gdwarf-4 -gsplit-dwarf hello.c -save-temps -dA ... we have in a-hello.s these three initial entries in .debug_str_offsets: ... .section .debug_str_offsets.dwo,"e",@progbits .4byte 0 // indexed string 0x0: short int .4byte 0xa // indexed string 0x1: /home/vries/binutils .4byte 0x1f // indexed string 0x2: main ... but "readelf -ws a.out" starts at the third entry: ... Contents of the .debug_str_offsets.dwo section (loaded from a-hello.dwo): Length: 0x30 Index Offset [String] 0 00000000 main ... This is a regression since commit 407115429b3 ("Modified changes for split-dwarf and dwarf-5."), which introduced a variable debug_str_offsets_hdr_len in display_debug_str_offsets. Fix this by setting display_debug_str_offsets to 0 for the dwarf4 case. PR 31734 --- binutils/dwarf.c | 1 + .../binutils-all/readelf-debug-str-offsets-dw4.d | 14 ++++++++++++++ .../binutils-all/readelf-debug-str-offsets-dw4.s | 6 ++++++ binutils/testsuite/binutils-all/readelf.exp | 1 + 4 files changed, 22 insertions(+) create mode 100644 binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d create mode 100644 binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s base-commit: 414aa6987f21a814851e5f3113388a3616993fa3 diff --git a/binutils/dwarf.c b/binutils/dwarf.c index c5ccc50dae7..8125c64e1b6 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7969,6 +7969,7 @@ display_debug_str_offsets (struct dwarf_section *section, length = section->size; curr = section->start; entries_end = end; + debug_str_offsets_hdr_len = 0; printf (_(" Length: %#" PRIx64 "\n"), length); printf (_(" Index Offset [String]\n")); diff --git a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d new file mode 100644 index 00000000000..23581e70f3e --- /dev/null +++ b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d @@ -0,0 +1,14 @@ +#name: readelf -ws readelf-debug-str-offsets-dw4 +#source: readelf-debug-str-offsets-dw4.s +#readelf: -ws + +Contents of the .debug_str.dwo section: + + 0x00000000 46495253 54005345 434f4e44 00 FIRST.SECOND. + +Contents of the .debug_str_offsets.dwo section: + + Length: 0x8 + Index Offset \[String\] + 0 00000000 FIRST + 1 00000006 SECOND diff --git a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s new file mode 100644 index 00000000000..68f64dde234 --- /dev/null +++ b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s @@ -0,0 +1,6 @@ + .section .debug_str.dwo,"MS",@progbits,1 + .string "FIRST" + .string "SECOND" + .section .debug_str_offsets.dwo,"MS",@progbits,1 + .4byte 0 + .4byte 6 diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp index 09ed75f8761..9f20cb42812 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -402,6 +402,7 @@ if {[which $AS] != 0} then { run_dump_test "retain1b" run_dump_test "readelf-maskos-1a" run_dump_test "readelf-maskos-1b" + run_dump_test "readelf-debug-str-offsets-dw4" if {![istarget *-*-hpux*]} then { run_dump_test pr26548 if {![binutils_assemble_flags $srcdir/$subdir/pr26548.s tmpdir/pr26548e.o {--defsym ERROR=1}]} then {