From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id C4B3B3877408 for ; Thu, 1 Jul 2021 10:05:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4B3B3877408 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 reform (deer0x00.wildebeest.org [172.31.17.130]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 9E2A03000252; Thu, 1 Jul 2021 12:05:32 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 2FFF82E80F3E; Thu, 1 Jul 2021 12:05:32 +0200 (CEST) From: Mark Wielaard To: debugedit@sourceware.org Cc: Tom Stellard , Mark Wielaard Subject: [PATCH] debugedit: Skip relocations with missing symbol/section offset. Date: Thu, 1 Jul 2021 12:05:19 +0200 Message-Id: <20210701100519.321801-1-mark@klomp.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: debugedit@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: debugedit development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2021 10:05:35 -0000 We tried to handle relocations that didn't have a symbol associated with any section. The would cause a message like: "Unhandled relocation 1 in .debug_info section". Which wasn't that helpful either. So skip relocations without an associated symbol section index and improve the error message a little. * debugedit.c (setup_relbuf): Continue when sym.st_shndx == 0. Add relocation index to error message. Signed-off-by: Mark Wielaard --- tools/debugedit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/debugedit.c b/tools/debugedit.c index c6975b2..d0c6371 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -561,10 +561,11 @@ setup_relbuf (DSO *dso, debug_section *sec, int *reltype) continue; /* Only consider relocations against .debug_str, .debug_line, .debug_line_str, and .debug_abbrev. */ - if (sym.st_shndx != debug_sections[DEBUG_STR].sec - && sym.st_shndx != debug_sections[DEBUG_LINE].sec - && sym.st_shndx != debug_sections[DEBUG_LINE_STR].sec - && sym.st_shndx != debug_sections[DEBUG_ABBREV].sec) + if (sym.st_shndx == 0 || + (sym.st_shndx != debug_sections[DEBUG_STR].sec + && sym.st_shndx != debug_sections[DEBUG_LINE].sec + && sym.st_shndx != debug_sections[DEBUG_LINE_STR].sec + && sym.st_shndx != debug_sections[DEBUG_ABBREV].sec)) continue; rela.r_addend += sym.st_value; rtype = ELF64_R_TYPE (rela.r_info); @@ -625,8 +626,8 @@ setup_relbuf (DSO *dso, debug_section *sec, int *reltype) #endif default: fail: - error (1, 0, "%s: Unhandled relocation %d in %s section", - dso->filename, rtype, sec->name); + error (1, 0, "%s: Unhandled relocation %d at [%d] for %s section", + dso->filename, rtype, ndx, sec->name); } relend->ptr = sec->data + (rela.r_offset - base); -- 2.32.0