Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13556196rwd; Sat, 24 Jun 2023 02:24:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mxhdvjRn9g4hr5Q2Nl8JFQwECAC6C81X0o2nfxbuOXJLxaSLzCEz3D/k0/gljHg7OdhOQ X-Received: by 2002:a17:902:ab05:b0:1b6:6751:95f5 with SMTP id ik5-20020a170902ab0500b001b6675195f5mr1603214plb.25.1687598641593; Sat, 24 Jun 2023 02:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687598641; cv=none; d=google.com; s=arc-20160816; b=i4Mb6uentWX2qGTXK9xKoIdR1XfSs9Tj5nqERoBrcwPAKPWxHFaPYX47tTqIY8S+t2 RDgR/yM69h/4zfZk3+O5q7XMfLyOsaNUSfeFP8nkcFfet116saOigTPTkqI0GCxWUFEF br+BbO3Iv/ZrkbYOha7xOMen5eU+/BRVkdTs0S4m9kq7QTbIZq4ErMYACyMdZKGe6MNz DM6yAmoiASKq7U7uGOIn1XM47OKvIQJqjKJTM/26TMbgTHxEpSmfv/CnDetU5RJdz2kx m90yq1keSXopismWfj7YsxVSp8a0DZECMXdW4hEzElHD0yt+HWfu+lyZBCbbWeLSk5Q+ 39kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=j1m+vcm8smOOGJELnckrBfCYz7BlVNg4D3OF4uo6xqk=; fh=m6x/6LN+jStJhjVltSQCrMZn00nrQmxPRqcJuj9CWeA=; b=AQWS6ofA9+DrkC0xGeAdW/CMQqi4GKovVbBgPFuHQwYdxR2E5FPDjJHEbJ7LWUBgD7 7mZ2zcCs/jOnkeUo9luHEyC64MPWWzge3AyRSAPSPKpw3BoTTa7p5HfpCyx/3vIDemhQ qptGGI+SLf2O3j7ca9Qc7iL28abiP/qIs0YUdDhUCVi+rf4ovbwe0UoMhQXeJeT/u8Dk JtblhSYTo0APN7kFjqLjDv8FDTdlVjNq4nWH+TWUIKm9eSWJU8wEHhfSxJMCW06VEfmP fS6YExGWQg2IIWCH9O+x+JkpOHRqLGO9Pl9R7/mrooVM13JnakEMIGityU8wW/sMo1wP Tr0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ps5kDxng; 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 u20-20020a170902a61400b001b66b4a946fsi964487plq.133.2023.06.24.02.23.46; Sat, 24 Jun 2023 02:24:01 -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=Ps5kDxng; 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 S232866AbjFXI4b (ORCPT + 99 others); Sat, 24 Jun 2023 04:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbjFXI4a (ORCPT ); Sat, 24 Jun 2023 04:56:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E4A01B4; Sat, 24 Jun 2023 01:56: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 EAA8760C26; Sat, 24 Jun 2023 08:56:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57210C433C8; Sat, 24 Jun 2023 08:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687596988; bh=fkL6o9zl3IO9B+Poh7aiIAOqjv3N+PZZFjiW5ZLnhtM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ps5kDxngVdR9s+/DY7KzB2Ino2c8W6L10uc3gr+bDRH5tbAtbtqBdr4NHdVrYRj99 tw2yHZEx7VXa/pMgEU8W+oFyKG9G40aDbPzjAQvGOsQPoihZPcVd5WyCDOsKydSJQd sRAMf8K+mWKMQ+u3B5FvA4GOIdaVlXuZtwHa7Z/SXaMVTsJ9ticRS20Q1nYvK4INBj tw9ktIJ+fGSCv/dYqr57B/TGEfDB7ULN+DqSf4n3B6vkZhFUWANNxll+HH/BZmqB2I hriHPrjhcAF8vr1q4+wPbym9AAN+95X9MkuQZ5PT5CkwwRNtivNlFojLRJk43eZUWv dXtnMa/NiKU6g== Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-560b56b638eso1073976eaf.0; Sat, 24 Jun 2023 01:56:28 -0700 (PDT) X-Gm-Message-State: AC+VfDzQ121anAxmAznt36Z83DRkfcki9wt9BRtlwnceFhec7oChkMli XB797cAY6HTEtromoKE0KfkZAS3Gd8kxt+2OEro= X-Received: by 2002:a4a:b6c2:0:b0:560:cb1c:1534 with SMTP id w2-20020a4ab6c2000000b00560cb1c1534mr4274616ooo.2.1687596987662; Sat, 24 Jun 2023 01:56:27 -0700 (PDT) MIME-Version: 1.0 References: <20230620120521.688124-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Sat, 24 Jun 2023 17:55:51 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/3] modpost: factor out inst location calculation to section_rel() To: Nick Desaulniers Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Sat, Jun 24, 2023 at 2:01=E2=80=AFAM Nick Desaulniers wrote: > > On Thu, Jun 22, 2023 at 10:38=E2=80=AFPM Masahiro Yamada wrote: > > > > On Fri, Jun 23, 2023 at 3:25=E2=80=AFAM Nick Desaulniers > > wrote: > > > > > > On Tue, Jun 20, 2023 at 5:05=E2=80=AFAM Masahiro Yamada wrote: > > > > > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > > > index 6e0b8be32648..2551ac9d5bd3 100644 > > > > --- a/scripts/mod/modpost.c > > > > +++ b/scripts/mod/modpost.c > > > > @@ -1519,17 +1512,20 @@ static void section_rel(struct module *mod,= struct elf_info *elf, > > > > r_sym =3D ELF_R_SYM(r.r_info); > > > > #endif > > > > r.r_addend =3D 0; > > > > + > > > > + loc =3D sym_get_data_by_offset(elf, fsecndx, r.r_of= fset); > > > > > > Can we compute `loc` only for the three machine types? > > > > > > > > I believe you can compute the location in the same way for any architec= ture > > because it is mentioned in ELF spec. > > Sure, but perhaps it's wasted work for other machine types? I guess you missed the following code: switch (elf->hdr->e_machine) { case EM_386: ... break; case EM_ARM: ... break; case EM_MIPS: ... break; default: fatal("Please add code to calculate addend for this architecture\n"= ); } I believe other machines never call this function. If it occurred, fatal() would immediately errors out, but I have not heard such a breakage for far. I believe only i386, mips and arm use REL. The other architectures are RELA. --=20 Best Regards Masahiro Yamada