Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4176032rwo; Tue, 25 Jul 2023 01:38:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhwcmPCOjlk3Q3MCeYgJRGbe+Yl/OxS/WwKl2uL3cvS+y/Jx+Wy1Hg9TIFlafF9vNrB6dj X-Received: by 2002:a05:6358:8810:b0:134:e964:134c with SMTP id hv16-20020a056358881000b00134e964134cmr13310605rwb.11.1690274339465; Tue, 25 Jul 2023 01:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690274339; cv=none; d=google.com; s=arc-20160816; b=I6QcdPbIIhlFOLITPOpenBr0+eIPPQjCtaIyfcv7s77Kz3mblPu72neLxG/5237bf9 78EhuMNUlDr29hwMZxzQzn/O/TWpb+dAueyeEqDbhTlIYJeP9gQxClsumyaUdej/1u5/ U1IOyHmoHssHPO0WG6A3SCqOqjnzgMswN/7kiJBP14jjP7vZVvR8/40rTi8dUxh0AOY8 YIobX6CJGAGvcTMksOmLH9ARl/N76qABChz+XauR0c4v+tBbx0mvaLvZz+TxGG5ku3Eu POL7zGW9HYo/EvOVxmkF6TTUDvIWJVZHj2/Z7NlegLvr260YmAVhmBSnziRwvp0FO1k3 YxuQ== 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=tcHZSfnon6BZHZmIDA9Z/nNQt1dpMGiKTgJ+XfRWF2k=; fh=a5ne5UNHSDZvaC0Fm5AysJvQzzZAFHmDWPoVULHE1Sk=; b=pBGij7G1hRLMNc1Ao/4ljZc28SFhlqfyTn45FK5fxxWQth02N5dTFytz09vhdFm1nC nTyR8shmzVlReFl4Y9frjciuLRj/Pr0iSobnWI91dOSs6unl5oSVrxnNR2hB5PQk2D1V lsPW6k4ts31znWLv/nfY8ty1M9FoJwq5gxVSzhVYFlKVxEhETDKN1QGJLDxg9t7/XnVx erAXT5sun5AcEe2Xha3m5jfTLaGfUxUVAVFlyHmqGeq6Iv0tG09B1Aa248GQ1N6/kmOE JCoxdj80eNPmTi8cHZmsHcB6Z/1BW5rSVw+rMm61Janc50W/lgeNnLaaae2dPDbP63/A FI0Q== 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 t70-20020a638149000000b0055be45c42d4si11161388pgd.810.2023.07.25.01.38.47; Tue, 25 Jul 2023 01:38:59 -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 S232667AbjGYIPe (ORCPT + 99 others); Tue, 25 Jul 2023 04:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbjGYIPW (ORCPT ); Tue, 25 Jul 2023 04:15:22 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 827DAE57 for ; Tue, 25 Jul 2023 01:15:20 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxueqUhL9kCqQJAA--.14527S3; Tue, 25 Jul 2023 16:15:16 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxLCOOhL9kAFg6AA--.7611S7; Tue, 25 Jul 2023 16:15:15 +0800 (CST) From: Tiezhu Yang To: Josh Poimboeuf , Peter Zijlstra , Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v1 5/6] objtool: Add skipped member in struct reloc Date: Tue, 25 Jul 2023 16:15:09 +0800 Message-Id: <1690272910-11869-6-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1690272910-11869-1-git-send-email-yangtiezhu@loongson.cn> References: <1690272910-11869-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8CxLCOOhL9kAFg6AA--.7611S7 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxCFWxZFy3tw13Aw1rXrW3twc_yoW5tr4kpF 4DG3y7KFW8Xr17Gw12qF4UC3y5W3sruFyxJrWUAry0krnrXrn8Jw4ayr1jyFyUWr4YgFW5 XFyYg34Utr1qvwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU7529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxkF7I0En4kS14v26r126r1DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY 6r1j6r4UMxCIbckI1I0E14v26r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7 xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xII jxv20xvE14v26ryj6F1UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw2 0EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x02 67AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0epB3UUUUU== 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 exist multiple relocation types in one location, such as a pair of R_LARCH_ADD32 and R_LARCH_SUB32 in section .rela.discard.unreachable and .rela.discard.reachable on LoongArch. Here is an example: $ readelf -rW init/main.o Relocation section '.rela.discard.unreachable' at offset 0x3e20 contains 2 entries: Offset Info Type Symbol's Value Symbol's Name + Addend 0000000000000000 0000000a00000032 R_LARCH_ADD32 0000000000000000 .init.text + 230 0000000000000000 0000001a00000037 R_LARCH_SUB32 0000000000000000 L0^A + 0 Relocation section '.rela.discard.reachable' at offset 0x4a00 contains 6 entries: Offset Info Type Symbol's Value Symbol's Name + Addend 0000000000000000 0000000a00000032 R_LARCH_ADD32 0000000000000000 .init.text + ae0 0000000000000000 0000002800000037 R_LARCH_SUB32 0000000000000000 L0^A + 0 0000000000000004 0000000a00000032 R_LARCH_ADD32 0000000000000000 .init.text + b88 0000000000000004 0000002b00000037 R_LARCH_SUB32 0000000000000004 L0^A + 0 0000000000000008 0000000200000032 R_LARCH_ADD32 0000000000000000 .text + 23c 0000000000000008 0000002e00000037 R_LARCH_SUB32 0000000000000008 L0^A + 0 In order to silence the related objtool warnings, add skipped member in struct reloc to record and skip the latter relocation. Co-developed-by: Jinyang He Signed-off-by: Jinyang He Co-developed-by: Youling Tang Signed-off-by: Youling Tang Signed-off-by: Tiezhu Yang --- tools/objtool/check.c | 4 ++++ tools/objtool/elf.c | 6 ++++++ tools/objtool/include/objtool/elf.h | 1 + 3 files changed, 11 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 9e5e462..602318e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -594,6 +594,8 @@ static int add_dead_ends(struct objtool_file *file) goto reachable; for_each_reloc(rsec, reloc) { + if (reloc->skipped) + continue; if (reloc->sym->type != STT_SECTION) { WARN("unexpected relocation symbol type in %s", rsec->name); @@ -633,6 +635,8 @@ static int add_dead_ends(struct objtool_file *file) return 0; for_each_reloc(rsec, reloc) { + if (reloc->skipped) + continue; if (reloc->sym->type != STT_SECTION) { WARN("unexpected relocation symbol type in %s", rsec->name); diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index d420b5d..bd950d4 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -975,6 +975,12 @@ static int read_relocs(struct elf *elf) return -1; } + if (!(strcmp(rsec->name, ".rela.discard.unreachable")) || + !(strcmp(rsec->name, ".rela.discard.reachable"))) { + if (reloc->sym->type != STT_SECTION) + reloc->skipped = true; + } + elf_hash_add(reloc, &reloc->hash, reloc_hash(reloc)); reloc->sym_next_reloc = sym->relocs; sym->relocs = reloc; diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h index c532d70..4141837 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -75,6 +75,7 @@ struct reloc { struct section *sec; struct symbol *sym; struct reloc *sym_next_reloc; + bool skipped; }; struct elf { -- 2.1.0