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. */