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 { From patchwork Tue May 14 10:55:21 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: 90108 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 987AB387540F for ; Tue, 14 May 2024 10:55:08 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 27652385842A for ; Tue, 14 May 2024 10:54:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27652385842A 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 27652385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715684072; cv=none; b=iAIzETBlAzdKTKKakbOGThkHm40ICjX23DHv4OonyyvCCJ56l9okSr7QJi4rvNQNc3RBHI/OPZnKL4cBveCd9b4XzuDu6OrSceGoDqGvTF3k5mzVmOt/10EkQfnOcNltnvmUYjzs6RFOYVcWpzc8ddkyOq8fGEFsn/gbi+9giN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715684072; c=relaxed/simple; bh=WvGDK+f/a4GU+lmpR/dRI0pyfbgE4RZBOl3p8gFkMcc=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=uuiBp6/q6iPXtFwlL9tCXWLdnyLVgVmAgi0JgbelTwpQHhqylsVgO7rlFRIVhItjmu5HWJor1fRInfUOBfUIc7FfdhpVGfWk3/PAwIgUwLvbOt3oWBW4sunccwW3lqXfNJHx9pqCn2Oh0xviSG+Wft3YqCSj7N7ZWomEkx41jgU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [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 2D8E760921 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: in-reply-to:in-reply-to:references:references; bh=Sy4pBNdZSv+g+msZe5qhKnzV0XzBhbFRDL5UOQqBiTk=; b=TGZn2ppACBRP8n6KEf9yF5+U6eDBBvxeAbs6tvtmYybwZz/5EfJoa+8s0wP4+rW+SJ8rd7 vW9q5piZvAtVNqJ8bSl75nnhBVkzgtWedN5nimpr4xTTf5y6LFl/8phzvt1lymL3C4a1nU cox1ZneWdO4y8fhGbpaaaL4jtZcNXK8= 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: in-reply-to:in-reply-to:references:references; bh=Sy4pBNdZSv+g+msZe5qhKnzV0XzBhbFRDL5UOQqBiTk=; b=TXshkJgHC0dOdoOKFM5xZUXwEcnRcpidwAbImoeXEON+qIAd4YLwrO4bV9PustsPf6dj0x KGJYwHaKcoyDRzCw== Authentication-Results: smtp-out2.suse.de; none 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: in-reply-to:in-reply-to:references:references; bh=Sy4pBNdZSv+g+msZe5qhKnzV0XzBhbFRDL5UOQqBiTk=; b=TGZn2ppACBRP8n6KEf9yF5+U6eDBBvxeAbs6tvtmYybwZz/5EfJoa+8s0wP4+rW+SJ8rd7 vW9q5piZvAtVNqJ8bSl75nnhBVkzgtWedN5nimpr4xTTf5y6LFl/8phzvt1lymL3C4a1nU cox1ZneWdO4y8fhGbpaaaL4jtZcNXK8= 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: in-reply-to:in-reply-to:references:references; bh=Sy4pBNdZSv+g+msZe5qhKnzV0XzBhbFRDL5UOQqBiTk=; b=TXshkJgHC0dOdoOKFM5xZUXwEcnRcpidwAbImoeXEON+qIAd4YLwrO4bV9PustsPf6dj0x KGJYwHaKcoyDRzCw== 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 1668A13A61 for ; Tue, 14 May 2024 10:54:28 +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 OEY8BORCQ2YOewAAD6G6ig (envelope-from ) for ; Tue, 14 May 2024 10:54:28 +0000 From: Tom de Vries To: binutils@sourceware.org Subject: [PATCH 2/3] [binutils/readelf] Add fixme in display_debug_str_offsets Date: Tue, 14 May 2024 12:55:21 +0200 Message-Id: <20240514105522.10107-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240514105522.10107-1-tdevries@suse.de> References: <20240514105522.10107-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.41 / 50.00]; BAYES_HAM(-2.61)[98.27%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnu.org:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[binutils@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.41 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, KAM_SHORT, 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 While reading display_debug_str_offsets, I realized that the v4 split dwarf handling bit doesn't assign entry_length, so it can be either 4 (32-bit dwarf) or 8 (64-bit dwarf). However, I think the cases for which it'll be 8 are rare and odd enough to conclude that in practise we default to 32-bit dwarf. As mentioned in the fission documentation [1], whether a .debug_str_offsets section is 32-bit or 64-bit dwarf depends on the compilation unit header in the .debug_info.dwo section, which is currently not inspected. For now: - make an explicit choice for 32-bit dwarf by assiging 4 to entry_length, and - add a fixme comment. [1] https://gcc.gnu.org/wiki/DebugFission --- binutils/dwarf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 8125c64e1b6..f49989dc536 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7971,6 +7971,14 @@ display_debug_str_offsets (struct dwarf_section *section, entries_end = end; debug_str_offsets_hdr_len = 0; + /* FIXME: We assume 32-bit dwarf here. According to + https://gcc.gnu.org/wiki/DebugFission: + The size of each entry is 4 bytes for DWARF-32 compilation units, + or 8 bytes for DWARF-64 compilation units, as determined by the + unit_length field of the compilation unit header in the + .debug_info.dwo section. */ + entry_length = 4; + printf (_(" Length: %#" PRIx64 "\n"), length); printf (_(" Index Offset [String]\n")); } From patchwork Tue May 14 10:55:22 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: 90107 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 39FE23875431 for ; Tue, 14 May 2024 10:55:08 +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 30750385E83A for ; Tue, 14 May 2024 10:54:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30750385E83A 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 30750385E83A 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=EzSSbffXqHPSr0ipGq2ywZHsnjQzj1DPAv4788CTyGS8Jm6MWZ9T2eyMQdhbxK7YMsdwo9y5wt4CE661vbkFReL15oy/wCfuppIhm+Hc9xuiFwUkUYXvOfl3d/4PL3+EI40jUiz3q05PMG8+DOdPoXf4Rm/tf5GrU7V+MQKmNjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715684072; c=relaxed/simple; bh=cIN6rXRegYVkiFiGc9fNSe9QWRJtySXbsBgKyP8aP/A=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=kkI9PoJmOybYg5PFKoSYK0F8qdrYyhBCmKiBqdx2hZOfQUZLNcRBnadkQB0SM1H5KEccPb3+6ZTnXY7Cz17pZeQGaeICQSoZRFVLBBD556jdPkG1Oe7NYP3jI5gbAcltaAlYkmFNWmkZO3WFirkpaBYRtykscSj/XT/HSg6HFvM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [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 4DD1160922 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: in-reply-to:in-reply-to:references:references; bh=ugCaSpO3g/+cpR603iW6rlXUtbsL6L+9hWipCzdIbXI=; b=s0YcZXB7G/fYj8w5ktwDxExqhuut3Ly5bm66sfBibd5KsyXYQbVWfutpHT0ipylOUle2t8 FaBdvW/lz0addaIHO6Vuav9o8FNsUvqzahh1yU7dLRIXLpPqjzwnNrTbTwHKqhgweuqJp/ oMtBa97m5BylQa9UmzPrbqdGmvWzgpw= 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: in-reply-to:in-reply-to:references:references; bh=ugCaSpO3g/+cpR603iW6rlXUtbsL6L+9hWipCzdIbXI=; b=stUaKr0MRUL/6txKNm4Q1kDLrVToyjQkl/u7dJnx42xzCxMwdKOc3Hbyv/kk1vmjZsrgoA 4dDlW7kAC+XGqMDA== Authentication-Results: smtp-out2.suse.de; none 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: in-reply-to:in-reply-to:references:references; bh=ugCaSpO3g/+cpR603iW6rlXUtbsL6L+9hWipCzdIbXI=; b=s0YcZXB7G/fYj8w5ktwDxExqhuut3Ly5bm66sfBibd5KsyXYQbVWfutpHT0ipylOUle2t8 FaBdvW/lz0addaIHO6Vuav9o8FNsUvqzahh1yU7dLRIXLpPqjzwnNrTbTwHKqhgweuqJp/ oMtBa97m5BylQa9UmzPrbqdGmvWzgpw= 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: in-reply-to:in-reply-to:references:references; bh=ugCaSpO3g/+cpR603iW6rlXUtbsL6L+9hWipCzdIbXI=; b=stUaKr0MRUL/6txKNm4Q1kDLrVToyjQkl/u7dJnx42xzCxMwdKOc3Hbyv/kk1vmjZsrgoA 4dDlW7kAC+XGqMDA== 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 33F8913A62 for ; Tue, 14 May 2024 10:54:28 +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 eFVoC+RCQ2YOewAAD6G6ig (envelope-from ) for ; Tue, 14 May 2024 10:54:28 +0000 From: Tom de Vries To: binutils@sourceware.org Subject: [PATCH 3/3] [binutils/readelf] Fix handling of DW_MACRO_define_strx in dwo file Date: Tue, 14 May 2024 12:55:22 +0200 Message-Id: <20240514105522.10107-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240514105522.10107-1-tdevries@suse.de> References: <20240514105522.10107-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[binutils@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_ALL(0.00)[] 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 printing a DW_MACRO_define_strx entry in a .debug_macro.dwo section, we run into: ... DW_MACRO_define_strx lineno : 0 macro : ... Fix this in display_debug_macro by passing the correct dwo argument to a fetch_indexed_string call. That works fine for readelf -w, with with readelf -wm we have: ... DW_MACRO_define_strx lineno : 0 macro : ... Fix this in display_debug_macro by doing load_debug_section_with_follow for str_dwo / str_index_dwo sections instead of str / str_index sections when handling .debug_macro.dwo. PR 31735 --- binutils/dwarf.c | 14 +++++++++++--- .../binutils-all/readelf-debug-str-offsets-dw4.d | 11 +++++++++-- .../binutils-all/readelf-debug-str-offsets-dw4.s | 7 +++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f49989dc536..cdf73a7bc50 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -6293,9 +6293,17 @@ display_debug_macro (struct dwarf_section *section, if (suffix && strcmp (suffix, ".dwo") == 0) is_dwo = true; - load_debug_section_with_follow (str, file); + if (is_dwo) + { + load_debug_section_with_follow (str_dwo, file); + load_debug_section_with_follow (str_index_dwo, file); + } + else + { + load_debug_section_with_follow (str, file); + load_debug_section_with_follow (str_index, file); + } load_debug_section_with_follow (line, file); - load_debug_section_with_follow (str_index, file); introduce (section, false); @@ -6504,7 +6512,7 @@ display_debug_macro (struct dwarf_section *section, READ_ULEB (lineno, curr, end); READ_ULEB (offset, curr, end); string = (const unsigned char *) - fetch_indexed_string (offset, NULL, offset_size, false, 0); + fetch_indexed_string (offset, NULL, offset_size, is_dwo, 0); if (op == DW_MACRO_define_strx) printf (" DW_MACRO_define_strx "); else diff --git a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d index 23581e70f3e..2f41f2331f2 100644 --- a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d +++ b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.d @@ -1,6 +1,6 @@ -#name: readelf -ws readelf-debug-str-offsets-dw4 +#name: readelf -wsm readelf-debug-str-offsets-dw4 #source: readelf-debug-str-offsets-dw4.s -#readelf: -ws +#readelf: -wsm Contents of the .debug_str.dwo section: @@ -12,3 +12,10 @@ Contents of the .debug_str_offsets.dwo section: Index Offset \[String\] 0 00000000 FIRST 1 00000006 SECOND +Contents of the .debug_macro.dwo section: + + Offset: 0 + Version: 4 + Offset size: 4 + + DW_MACRO_define_strx lineno : 0 macro : FIRST diff --git a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s index 68f64dde234..c28750bbe24 100644 --- a/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s +++ b/binutils/testsuite/binutils-all/readelf-debug-str-offsets-dw4.s @@ -4,3 +4,10 @@ .section .debug_str_offsets.dwo,"MS",@progbits,1 .4byte 0 .4byte 6 + .section .debug_macro.dwo,"e",@progbits + .2byte 0x4 /* DWARF macro version number. */ + .byte 0x0 /* Flags: 32-bit dwarf. */ + .byte 0xb /* Define macro strx. */ + .uleb128 0 /* At line number 0. */ + .uleb128 0x0 /* .debug_str_offsets.dwo entry 0. */ + .byte 0 /* End compilation unit. */