Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp891252pxb; Sat, 6 Mar 2021 22:36:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJydtIOS/HY3CgOCFIx5CZPpbRgha7TD+5NN/On5vF9DD/r9BeJr85geTtGERLakZXAzw5eF X-Received: by 2002:a05:6402:31b7:: with SMTP id dj23mr16940540edb.245.1615098995236; Sat, 06 Mar 2021 22:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615098995; cv=none; d=google.com; s=arc-20160816; b=QhAdNpZmX/3T74xiUFBWapOaUDvF0uOJxXpFFNHduWSTj4I047VJwazLBtoIq7/Yg/ NkAIWmNtsX/tbpg4q7J9OMdCN7TIz8T7ldmK8QJ2UdH7T7X5CIa0tgqS9zGoxLX1LHcT S/IpIsdkIHQhnIjGzjg4u0u57ZdPlkoC0FVYSHmWQCscYM61e7fpEdO829+gcYTpPpSa FgGhgjV8wuAJRhc7qKoS1jBczVl2odotvw6+kSF8ZMFXo7EEFfddWHVMjhVLz8c/zLYc wANjYEio0I18gQhjOJyyTvqSgqMwO00FL9hdKzVwkJz82nEDYzp2Cb6++tpzl9fZSZXF QjcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lgTVaBNy62FaQXG4T7xAtsLpQb7SJOUo67w7wxLxPEA=; b=0ltMLswearIfeXtFCTH7LW4oHHakwxyulmSQgbx+X7/7TBHJfXuPo7e6Xzi+Q6klCu qkIXQ1AA3c0upcTJzKFB142GK3PAI/koXKGl8bjHnKXVc1LH7N1pQ87BXuMMfHBEn97J s4FaCGSm1nNvGdhzaUaPE/ElSgTvEDkaj9TLcKF1j0qK1a1Mvl9b0+WphE5TvLGIJzVE 3S5q0ATnhUrzvKkwVlzBGFIPWAWH1H5zNSctXWIEBPQsT/U00sb493BjQvieuN1Ehjvt sv0HTimSKrRbkL2WAEipSul8i3J+d7KghY3vQ45fquASV4/W7KLaYUJZ+okb8SXgLGyd taTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B8lJWYRs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si5370938edf.287.2021.03.06.22.36.12; Sat, 06 Mar 2021 22:36:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B8lJWYRs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbhCGGbo (ORCPT + 99 others); Sun, 7 Mar 2021 01:31:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbhCGGb2 (ORCPT ); Sun, 7 Mar 2021 01:31:28 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B49C06174A for ; Sat, 6 Mar 2021 22:31:27 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id j14-20020a17090a588eb02900cefe2daa2cso538823pji.0 for ; Sat, 06 Mar 2021 22:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lgTVaBNy62FaQXG4T7xAtsLpQb7SJOUo67w7wxLxPEA=; b=B8lJWYRslFfmnZRMNrhVfkxmfp4MFiFQw1YP0x5TKFi1oeC7TCND4+2D3S910wYBj1 xkftjqHwg81TT5F7Eu7d8F5vUWc7vvBVZTyEM2EQKq6aNnmWGQw9Xv/LkIPIUACgpzR3 3OOhXNQEkTopGcMFBGmwA+5Q5kQkQ4VXn4GaxdOlsPDqRwx7yFZfaG6e0cuV1rJTFVcD i/6PcrGH7p+CCdxEGRFAIkmgfA6n4WMBgTorYalHPtmJJuRnCUePdFpHJXcQlENclB9p jkv1+FcUnY1e/HMpqaY7hEuAPm85tKM7jUitwDEvoLhh+06R2lBttlPQd14lM4l9gM1L iZkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lgTVaBNy62FaQXG4T7xAtsLpQb7SJOUo67w7wxLxPEA=; b=Aewj6fDhht8fu6V6VM6eDttFHf31UHGEF2twSmuebgwdkTMQ48ZSn07w5jJOWLBbv9 b+WEACDmMKhadwVdu3dNZVOPF2q0hfAjvSNOSsugj9dCdsIxaG/hqydz2TN23+qxTbw7 LO9E8QBuiSS87nh85YEw8JhveV/cAZtEWYMm25TNNz8IbWye/6Qp2eB/k3uDxitAWOR6 hlHYtjpGOXGTNHVqawVZ6XHMjm9P+xeQNaXyQ3SvAhwwXio3CAR2OKPbBIQs/BxMCC4p /pDDbcnD5L+AdLzCnTgqSd42TYR/YdK0PTiaLz7rbga8zjmVJ4Fh3z73WoUQaozf4uEz uZug== X-Gm-Message-State: AOAM530Aykk5HfKj4DDZI5W/bm+Zf9AWibvSImrCrqLZX2uC3VaXJElU 0Upd/undZyLfCIljU2KOjHVkiagAWCeAREReeoDfHg== X-Received: by 2002:a17:902:ead5:b029:e5:bd04:bf48 with SMTP id p21-20020a170902ead5b02900e5bd04bf48mr16013637pld.38.1615098686849; Sat, 06 Mar 2021 22:31:26 -0800 (PST) MIME-Version: 1.0 References: <20210307051433.2756645-1-maskray@google.com> <20210307062336.GD29191@gate.crashing.org> In-Reply-To: <20210307062336.GD29191@gate.crashing.org> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Sat, 6 Mar 2021 22:31:15 -0800 Message-ID: Subject: Re: [PATCH] Replace __toc_start + 0x8000 with .TOC. To: Segher Boessenkool Cc: Michael Ellerman , linuxppc-dev , LKML , clang-built-linux , Alexey Kardashevskiy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 6, 2021 at 10:25 PM Segher Boessenkool wrote: > > Hi! > > On Sat, Mar 06, 2021 at 09:14:33PM -0800, Fangrui Song wrote: > > TOC relocations are like GOT relocations on other architectures. > > However, unlike other architectures, GNU ld's ppc64 port defines .TOC. > > relative to the .got output section instead of the linker synthesized > > .got input section. LLD defines .TOC. as the .got input section plus > > 0x8000. When CONFIG_PPC_OF_BOOT_TRAMPOLINE=y, > > arch/powerpc/kernel/prom_init.o is built, and LLD computed .TOC. can be > > different from __toc_start defined by the linker script. > > > > Simplify kernel_toc_addr with asm label .TOC. so that we can get rid of > > __toc_start. > > > > With this change, powernv_defconfig with CONFIG_PPC_OF_BOOT_TRAMPOLINE=y > > is bootable with LLD. There is still an untriaged issue with Alexey's > > configuration. > > Do you have any explanation why this *does* work, while the original > doesn't? Some explanation that says *what* is wrong. To me it doesn't > look like the kernel script is. > > > Segher The kernel code probably wants to access .TOC. (the TOC base symbol) via __toc_start+0x8000. If the kernel understood TOC base is different from the linker understood TOC base (.TOC.), there should be a problem. By using .TOC. in the kernel code, the two concepts are guaranteed to match.