From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by sourceware.org (Postfix) with ESMTP id 8537B385BF99 for ; Fri, 2 Apr 2021 11:40:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8537B385BF99 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ldv@altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id B720E72C8B1 for ; Fri, 2 Apr 2021 14:40:49 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id A94C77CC8A3; Fri, 2 Apr 2021 14:40:49 +0300 (MSK) Date: Fri, 2 Apr 2021 08:00:00 +0000 From: "Dmitry V. Levin" To: debugedit@sourceware.org Cc: "Ivan A. Melnikov" Subject: [PATCH] debugedit: add MIPS support Message-ID: <20210402080000.GA13000@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 02 Apr 2021 11:40:52 -0000 From: "Ivan A. Melnikov" Date: Fri, 13 Nov 2020 15:51:08 +0400 According to the specification[1], all MIPS .debug_* sections are marked with ELF type SHT_MIPS_DWARF. The format of the section data stays the same, so we have can handle e.g. .debug_info section as we used to. As SHT_MIPS_DWARF is from processor-specific range, we have to check that we're actually dealing with MIPS ELF file before handling such sections. [1] MIPS Extensions to DWARF Version 2.0. -- Silicon Graphics Computer Systems, rev 1.17, 29 Aug 2001 Refs: https://bugzilla.altlinux.org/39284 Signed-off-by: Ivan A. Melnikov Signed-off-by: Dmitry V. Levin --- tools/debugedit.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/debugedit.c b/tools/debugedit.c index 7c57e16..917c59b 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -3440,6 +3440,16 @@ main (int argc, char *argv[]) switch (dso->shdr[i].sh_type) { + case SHT_MIPS_DWARF: + /* According to the specification, all MIPS .debug_* sections are + marked with ELF type SHT_MIPS_DWARF. As SHT_MIPS_DWARF is from + processor-specific range, we have to check that we're actually + dealing with MIPS ELF file before handling such sections. */ + if (dso->ehdr.e_machine != EM_MIPS + && dso->ehdr.e_machine != EM_MIPS_RS3_LE) { + break; + } + /*@fallthrough@*/ case SHT_PROGBITS: name = strptr (dso, dso->ehdr.e_shstrndx, dso->shdr[i].sh_name); /* TODO: Handle stabs */ -- ldv