Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp753972imw; Fri, 8 Jul 2022 11:04:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9hd+o+OFcX2SC56ukLQSQoLO6Le74oEGHZupX4tVA6u66e72NAYDi5VG2XwcPFUXVhP9q X-Received: by 2002:a05:6402:4446:b0:43a:3f52:4172 with SMTP id o6-20020a056402444600b0043a3f524172mr6241493edb.417.1657303494321; Fri, 08 Jul 2022 11:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657303494; cv=none; d=google.com; s=arc-20160816; b=gp5iU5UKQ+96XW0sN6gbIWRbz0bkSeClLyQeXY3y6Vid4RYN+eIU0QQpyfEGwqZ45V UKGJsncAIerm2UC7HALt9Ew3tjODON2GK9nX/2nmvPL2INY1r2MWcX++0L+UrbeIPUfp 1fbjyPUbEjBR9tc0UdMrl2zRFJRx0ju1FMTH5Uh2AWfFEQlqlpT5s5AYVEEfLZZw99TT 0P+2zqZvoctBRyj2s5u3UjRyk89L+PpkAT8kSlbbFxgRIPsFOSKfecYAtd7CAG2YKGtx yAM7G5UcG2J3muL7OA8+2atPrvj9mv96c5+Mq3/jHEr72gXXi40kGXJ14mUKDyJoclIj gHVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W44mwL2pZMRtHQRj7hbe23ur0Ixn3Po2MrWKsQjzMUI=; b=gCZyK7LMP+DaLGqxWa4tbDriRoatDruwM1uGY6AT759nZFsd757MSUkFy2HYZbhpwk s3eb+hBQe6TATjdGp7dZg186DRwxjSFGrRS2uaMUQHji5ITz1T1KHknnaAx5JNZ9MQNm bLxf111RreNylqUAmpJ4B7/GMG+hXTJXcbUn/Vr05UTyykFPg6bykbnLzpZIkgz8nPP4 3mhLkkqf5LY0ZVrz27nBuBUBBD00YLzZJWXB2LR3cgWnRrMqRIrGP746T52POeFiJZ20 dH/syzwuVmhuz52KWMJ7LnsEH+MxFnCvG2CXvDYLkfpsazZ3vU8zej1J3eY8Lq87fxcH dzEg== 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 fr29-20020a170906891d00b00708f4d9dbdbsi47520803ejc.79.2022.07.08.11.04.28; Fri, 08 Jul 2022 11:04:54 -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 S239038AbiGHRcv (ORCPT + 99 others); Fri, 8 Jul 2022 13:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238929AbiGHRce (ORCPT ); Fri, 8 Jul 2022 13:32:34 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABDC13F2F for ; Fri, 8 Jul 2022 10:32:33 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4LfgMM1wDHz9tK2; Fri, 8 Jul 2022 19:32:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DYBvPg-FllTN; Fri, 8 Jul 2022 19:32:15 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4LfgMF3Zqkz9tMK; Fri, 8 Jul 2022 19:32:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 646008B7A0; Fri, 8 Jul 2022 19:32:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 87xHo-gisBWW; Fri, 8 Jul 2022 19:32:09 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.233.202]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C84D28B79F; Fri, 8 Jul 2022 19:32:08 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 268HW43V1000736 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 8 Jul 2022 19:32:04 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 268HW48o1000734; Fri, 8 Jul 2022 19:32:04 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , sv@linux.ibm.com, agust@denx.de, jpoimboe@kernel.org, peterz@infradead.org, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, chenzhongjin@huawei.com Subject: [PATCH v2 3/7] objtool: Add architecture specific R_REL32 macro Date: Fri, 8 Jul 2022 19:31:22 +0200 Message-Id: <44a10adfc8a343416115456d09e234e2e0bca757.1657301423.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1657301483; l=3463; s=20211009; h=from:subject:message-id; bh=XFZ/nZNDunnD1Hp5+OJHS9YxS2TlTFL6V6h3uWnUhgY=; b=KkCuwHdJGeCBLD3QcBlnRdxLWmPwRIKuUR+KY8tpcRUF6Dd2faB2gkNco8ppL4oVDmfXQ8ZvUJ5L 78V4RklkDSyZvZn5AuN1kv9txPwQNB1Qah/eNpDCOISkd6vtktUs X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit 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 In order to allow other architectures than x86 to use 32 bits PC relative relocations (S+A-P), define a R_REL32 macro that each architecture will define, in the same way as already done for R_NONE, R_ABS32 and R_ABS64. For x86 that corresponds to R_X86_64_PC32. For powerpc it will be R_PPC_REL32/R_PPC64_REL32. Signed-off-by: Christophe Leroy --- v2: Improved commit message based on feedback from Segher --- tools/objtool/arch/x86/include/arch/elf.h | 1 + tools/objtool/check.c | 10 +++++----- tools/objtool/orc_gen.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h index ac14987cf687..e7d228c686db 100644 --- a/tools/objtool/arch/x86/include/arch/elf.h +++ b/tools/objtool/arch/x86/include/arch/elf.h @@ -4,5 +4,6 @@ #define R_NONE R_X86_64_NONE #define R_ABS64 R_X86_64_64 #define R_ABS32 R_X86_64_32 +#define R_REL32 R_X86_64_PC32 #endif /* _OBJTOOL_ARCH_ELF */ diff --git a/tools/objtool/check.c b/tools/objtool/check.c index dec42a226048..ba8fd313372c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -652,7 +652,7 @@ static int create_static_call_sections(struct objtool_file *file) /* populate reloc for 'addr' */ if (elf_add_reloc_to_insn(file->elf, sec, idx * sizeof(struct static_call_site), - R_X86_64_PC32, + R_REL32, insn->sec, insn->offset)) return -1; @@ -693,7 +693,7 @@ static int create_static_call_sections(struct objtool_file *file) /* populate reloc for 'key' */ if (elf_add_reloc(file->elf, sec, idx * sizeof(struct static_call_site) + 4, - R_X86_64_PC32, key_sym, + R_REL32, key_sym, is_sibling_call(insn) * STATIC_CALL_SITE_TAIL)) return -1; @@ -737,7 +737,7 @@ static int create_retpoline_sites_sections(struct objtool_file *file) if (elf_add_reloc_to_insn(file->elf, sec, idx * sizeof(int), - R_X86_64_PC32, + R_REL32, insn->sec, insn->offset)) { WARN("elf_add_reloc_to_insn: .retpoline_sites"); return -1; @@ -789,7 +789,7 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file) if (elf_add_reloc_to_insn(file->elf, sec, idx * sizeof(int), - R_X86_64_PC32, + R_REL32, insn->sec, insn->offset)) { WARN("elf_add_reloc_to_insn: .ibt_endbr_seal"); return -1; @@ -3718,7 +3718,7 @@ static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn continue; off = reloc->sym->offset; - if (reloc->type == R_X86_64_PC32 || reloc->type == R_X86_64_PLT32) + if (reloc->type == R_REL32 || reloc->type == R_X86_64_PLT32) off += arch_dest_reloc_offset(reloc->addend); else off += reloc->addend; diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 1f22b7ebae58..49a877b9c879 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -101,7 +101,7 @@ static int write_orc_entry(struct elf *elf, struct section *orc_sec, orc->bp_offset = bswap_if_needed(elf, orc->bp_offset); /* populate reloc for ip */ - if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int), R_X86_64_PC32, + if (elf_add_reloc_to_insn(elf, ip_sec, idx * sizeof(int), R_REL32, insn_sec, insn_off)) return -1; -- 2.36.1