Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7733427rwd; Tue, 20 Jun 2023 05:39:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XAHA+kZ1Zqtpjm3IBBMWBvoRxTb9pAcPL8wzu0rPsE7SbmcApWvgFHm6nSZa0SzRCAfs/ X-Received: by 2002:a05:6a00:1799:b0:668:7292:b2c6 with SMTP id s25-20020a056a00179900b006687292b2c6mr4762766pfg.14.1687264754781; Tue, 20 Jun 2023 05:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687264754; cv=none; d=google.com; s=arc-20160816; b=ISnEIEFT1WTZLASG7ci6fYs4UPHXcE9ZtcQKByrbUS6UN1iw4q/D6ivTgZscB1a/G8 bnUiMNBQGm/PBvLRTTMA86yKeWk14cvPSRYGZ23ofAEgdSJfAv+vyaNFssIBryMvdCAm C/x4P7coG38VNBCr6+XpY+DwZSDTWoiNNZy1Mrh7sKY9gT9nHlHBlMlmJuKXZPno/7Ph +B/PzQUCy1ZNWijr5p+iDxP35Ojdh9kZ+tTujUEUCKF2co7zYmRzg9i7+A/jXeW+ouDM PUSwyGegbZ+P37GY9q56PxddYTaF51qgK5gofJZnWyJAFsLf/CkBdrrVxRRwCQvIOYOo VjIQ== 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 :dkim-signature; bh=p++hghqg9V7UsTbGfGu6j64cdEMjKzvFEbWTgsgTaGc=; b=X/ZjOYo2uYjHvKHe3di4HfS5QgYcNc4jSIlKX4xTj1MdqpY1DDX/wIyggtp6J0G/mA lvLuLj+CqTINEqqbH+EfaOXh0Rvl6Ku39PUWtGFTxR62jbk9RDFTt+lyKOcKaV3XlGwg NlevuK74ulMIAb9UmK5T4pxM9KZFin5nH6Gli1KuUQdrIBXR5sDqPzpr1DFcREplhG01 AQf1Ys11HCVoQHlfGxttRq1/g0XD7tzPRmKEEjq8vMxOKkxdrUzIXl1zlbuzkubsBs4s RPF3rAmqrEQfVRzmqjeGJ/wu8iFgIvhe6Jav5dwXuAmrtKfpZyct+5TczKyughhGbxIf sFNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AgueyVrt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b29-20020a63715d000000b00553867efc1bsi1709502pgn.636.2023.06.20.05.39.02; Tue, 20 Jun 2023 05:39:14 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AgueyVrt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232736AbjFTMFp (ORCPT + 99 others); Tue, 20 Jun 2023 08:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232618AbjFTMFb (ORCPT ); Tue, 20 Jun 2023 08:05:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C951010F3; Tue, 20 Jun 2023 05:05:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B9D5611FB; Tue, 20 Jun 2023 12:05:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C0CEC433CA; Tue, 20 Jun 2023 12:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687262728; bh=2ReNXn5QKyfmsIaf+RPx+AKwwDkxRAR+rcyRaaWC81Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgueyVrtoivd4awbdEnSIoa4Jbw+JcNKE+wbISLopEeSRnV96cql5isRbTSgBJbzQ 25YKqrFH+ofdk+3xOhIXEWAr1sIpkrC6NXYhiT8O7G4awRamuhivH9umAUmhN7Jdfm sA/VauSD3Pn097KlGDesTcvIrqZNn81ZiOKfnmXHl71sqO1v3xPoC6To8wMZvrrQvP Ovv/8b7THfmlLF1Q+RX2oU/mlDJVxWUt/ZPOG5b6FczqIPF+6m29sOE0Hs79Ml1+RR MUkP7sZDDZGyF3Ymm6oZsJbV79gaNaP0vkv2I/1rR2ZqI9CFSzfiixmpHSmdl2x6ft aHDygN0MS8ueQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 2/3] modpost: factor out Elf_Sym pointer calculation to section_rel() Date: Tue, 20 Jun 2023 21:05:20 +0900 Message-Id: <20230620120521.688124-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230620120521.688124-1-masahiroy@kernel.org> References: <20230620120521.688124-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Pass the Elf_Sym pointer to addend_arm_rel() as well as to check_section_mismatch(). Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2551ac9d5bd3..ffe45c54f024 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1295,10 +1295,9 @@ static int32_t sign_extend32(int32_t value, int index) return (int32_t)(value << shift) >> shift; } -static int addend_arm_rel(void *loc, struct elf_info *elf, Elf_Rela *r) +static int addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r) { unsigned int r_typ = ELF_R_TYPE(r->r_info); - Elf_Sym *sym = elf->symtab_start + ELF_R_SYM(r->r_info); uint32_t inst, upper, lower, sign, j1, j2; int32_t offset; @@ -1493,6 +1492,7 @@ static void section_rel(struct module *mod, struct elf_info *elf, return; for (rel = start; rel < stop; rel++) { + Elf_Sym *tsym; void *loc; r.r_offset = TO_NATIVE(rel->r_offset); @@ -1514,6 +1514,7 @@ static void section_rel(struct module *mod, struct elf_info *elf, r.r_addend = 0; loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset); + tsym = elf->symtab_start + ELF_R_SYM(r.r_info); switch (elf->hdr->e_machine) { case EM_386: @@ -1521,7 +1522,7 @@ static void section_rel(struct module *mod, struct elf_info *elf, continue; break; case EM_ARM: - if (addend_arm_rel(loc, elf, &r)) + if (addend_arm_rel(loc, tsym, &r)) continue; break; case EM_MIPS: @@ -1532,7 +1533,7 @@ static void section_rel(struct module *mod, struct elf_info *elf, fatal("Please add code to calculate addend for this architecture\n"); } - check_section_mismatch(mod, elf, elf->symtab_start + r_sym, + check_section_mismatch(mod, elf, tsym, fsecndx, fromsec, r.r_offset, r.r_addend); } } -- 2.39.2