Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7453365rwd; Tue, 20 Jun 2023 01:11:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mNroFdnenRUd0pLcOH/XVdQO69/InbGqZSCiweHx01/GrfPF6wy2aUbprbS4qNe6FmOSa X-Received: by 2002:a05:6a20:4391:b0:117:c3f8:2f39 with SMTP id i17-20020a056a20439100b00117c3f82f39mr7736330pzl.19.1687248708461; Tue, 20 Jun 2023 01:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687248708; cv=none; d=google.com; s=arc-20160816; b=QhXq0mD8RDrnwu+Uj6ouLY8sCKdhUvE0xCOLhPJedvZgm1E7ye7Frj+FsZ0Zljr5z4 ntlmfrL/gDBMk4yM+p8Mu6Otfrmi2Zhf7I2j/OimFE/SBanROL4kuWI1obaDZELQL9Do q0FPxn/s9K/vs1qpnEhvkhmduhjgBE5UxCgpi8f5UKSiXAfouEFtRv+r78XxnBeIRVLi OolAm2DBm+/UtJY8cKI6oDaxzOuC2qdFnEwGAnoefs7383/pno7r7G5OjNqtT17S/MK7 rE2vV1xMrGfYzqa/w7/jzyaXJf7oxe/bhOoaLGHmMmE4vZH32bjDXZwaRuAOHG5MnQjk 2IHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=hZmXjJPOy72ZGV2IEobJN0p/Fz+DfJxhEGUnW7dRYVs=; b=zUJZxZCfpZhwemNsqFRSt2pcOAbmNFnu/A0KOj9Z3h9PANiphINvShSdg2Y657r4Nr XD6e3hKlR/p15HTlN+4q5M7+uLyUu+EuowjTHjSmKsOtf49BLpdvMl2+Je6eMRfay/Wo PtulYl6TrEE3HrRwkbGHUXbShdiwxnoRD2BF1nAkfWGF3+YSlx7rAAOQ1NhuFHBXfeTF DvM80dnVQ2OY11dGYTeHYOf/JuyNdTQaFl8rRtmXhh6Sawp7yUlh+KDJZe9Z33ZuKRqs 2HllCg1l4n3ul11uskg66LzN3Sshdb3sM9L+L5V+D1zbP7y5gF0LFObBGQIKJTfsl/nU hBXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g28-20020aa79f1c000000b0066688e57cf7si1141082pfr.366.2023.06.20.01.11.36; Tue, 20 Jun 2023 01:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbjFTHvS (ORCPT + 99 others); Tue, 20 Jun 2023 03:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbjFTHut (ORCPT ); Tue, 20 Jun 2023 03:50:49 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 57EF11981; Tue, 20 Jun 2023 00:50:30 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Cx8OhEWpFkuRsHAA--.12665S3; Tue, 20 Jun 2023 15:50:28 +0800 (CST) Received: from bogon.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxPMo+WpFkp2chAA--.19067S6; Tue, 20 Jun 2023 15:50:28 +0800 (CST) From: Youling Tang To: Josh Poimboeuf , Peter Zijlstra , Huacai Chen , madvenka@linux.microsoft.com Cc: chenzhongjin@huawei.com, WANG Xuerui , Xi Ruoyao , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, tangyouling00@gmail.com, youling.tang@outlook.com Subject: [RFC PATCH v1 14/23] objtool: Add orc_print_dump() package Date: Tue, 20 Jun 2023 15:50:10 +0800 Message-Id: <1687247415-32057-5-git-send-email-tangyouling@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1687247415-32057-1-git-send-email-tangyouling@loongson.cn> References: <1687247415-32057-1-git-send-email-tangyouling@loongson.cn> X-CM-TRANSID: AQAAf8AxPMo+WpFkp2chAA--.19067S6 X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZw4DGw17Kw47Zw4UWr4xXwc_yoW5Zw48pr nxGas7KrWUuF9xAw1kJanrC3y5Ganru34IkrnxC34Iyw1IqwnrXa1SyF1j9Fn5W3s5uasx ZFZIqr1UKFs7tFXCm3ZEXasCq-sJn29KB7ZKAUJUUUU3529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUmIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E 14v26r4UJVWxJr1ln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6x kI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v2 6r45tVCq3wAv7VC2z280aVAFwI0_Gr1j6F4UJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2 IYc2Ij64vIr41lF7xvrVCFI7AF6II2Y40_Zr0_Gr1UMxkF7I0En4kS14v26r126r1DMxAI w28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v26r126r1DMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26w1j6s0DMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E 87Iv67AKxVW8Jr0_Cr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa 73UjIFyTuYvjxU9zpBDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no functional change, only operations such as orc_print_{sp,fp} are encapsulated into orc_print_dump(). It is convenient to add LoongArch support later (because it needs to add orc_print_ra()). Signed-off-by: Youling Tang --- tools/objtool/arch/x86/orc.c | 23 ++++++++++++++++++----- tools/objtool/include/objtool/orc.h | 5 +---- tools/objtool/orc_dump.c | 12 +----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/objtool/arch/x86/orc.c b/tools/objtool/arch/x86/orc.c index a0c00e136089..cf546b274a79 100644 --- a/tools/objtool/arch/x86/orc.c +++ b/tools/objtool/arch/x86/orc.c @@ -114,7 +114,7 @@ static const char *reg_name(unsigned int reg) } } -const char *orc_type_name(unsigned int type) +static const char *orc_type_name(unsigned int type) { switch (type) { case UNWIND_HINT_TYPE_CALL: @@ -128,7 +128,7 @@ const char *orc_type_name(unsigned int type) } } -void orc_print_reg(unsigned int reg, int offset) +static void orc_print_reg(unsigned int reg, int offset) { if (reg == ORC_REG_BP_INDIRECT) printf("(bp%+d)", offset); @@ -140,12 +140,25 @@ void orc_print_reg(unsigned int reg, int offset) printf("%s%+d", reg_name(reg), offset); } -void orc_print_sp(void) +static void orc_print_sp(void) { printf(" sp:"); } - -void orc_print_fp(void) +static void orc_print_fp(void) { printf(" bp:"); } + +void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i) +{ + orc_print_sp(); + + orc_print_reg(orc[i].sp_reg, bswap_if_needed(dummy_elf, orc[i].sp_offset)); + + orc_print_fp(); + + orc_print_reg(orc[i].bp_reg, bswap_if_needed(dummy_elf, orc[i].bp_offset)); + + printf(" type:%s signal:%d end:%d\n", + orc_type_name(orc[i].type), orc[i].signal, orc[i].end); +} diff --git a/tools/objtool/include/objtool/orc.h b/tools/objtool/include/objtool/orc.h index bf141134c56f..53a037bdfc35 100644 --- a/tools/objtool/include/objtool/orc.h +++ b/tools/objtool/include/objtool/orc.h @@ -10,9 +10,6 @@ int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, struct instruction *insn); -const char *orc_type_name(unsigned int type); -void orc_print_reg(unsigned int reg, int offset); -void orc_print_sp(void); -void orc_print_fp(void); +void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i); #endif /* _OBJTOOL_ORC_H */ diff --git a/tools/objtool/orc_dump.c b/tools/objtool/orc_dump.c index 82bdd33dbc39..c274c0577427 100644 --- a/tools/objtool/orc_dump.c +++ b/tools/objtool/orc_dump.c @@ -151,17 +151,7 @@ int orc_dump(const char *_objname) printf("%llx:", (unsigned long long)(orc_ip_addr + (i * sizeof(int)) + orc_ip[i])); } - - orc_print_sp(); - - orc_print_reg(orc[i].sp_reg, bswap_if_needed(&dummy_elf, orc[i].sp_offset)); - - orc_print_fp(); - - orc_print_reg(orc[i].bp_reg, bswap_if_needed(&dummy_elf, orc[i].bp_offset)); - - printf(" type:%s signal:%d end:%d\n", - orc_type_name(orc[i].type), orc[i].signal, orc[i].end); + orc_print_dump(&dummy_elf, orc, i); } elf_end(elf); -- 2.39.2