Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4384727ybb; Tue, 14 Apr 2020 06:20:04 -0700 (PDT) X-Google-Smtp-Source: APiQypK/zYlxg03iWHTf+FFdhy1thJ5xI/3qJjdSNS2gBsvoqCbcZIY66e+azgTgJ8gyoOYdI3z2 X-Received: by 2002:a17:906:2284:: with SMTP id p4mr38956eja.69.1586870403972; Tue, 14 Apr 2020 06:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586870403; cv=none; d=google.com; s=arc-20160816; b=PvdHlRKx3VR5hpgQw5pRs/Ek4vi3Vdj37gGDobHlgRgiomRJa6CwIqC6uFgP5cn6eV XrZMQ6NuoHR3bAbniCmH6LXovHTb72MffFgnNqvX5iasKW+is0pMQophHfexQXnV6zvW p9F18UyFpiSI72dR7yn1xKKvijI7syP+dcmlOF3lXgMf8QJWwM2Y0D3qf7wewGGZekwn EmRkvnmjWf7BIweFVz9tE6r8riB1tbM4TMIkouPkffWlWVYoyaPZA3UHFySzGcH4AgRL 3WJTgxxpDJR6YSPncbCwXDP8kjZ9iZBc9fPKf5rZYsIT89DdpyhuWI9l1oX8GmUZdwlj LbRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ghs4l4nI57la7hO/6EnhN56epQlSYo2HQcGuqn9At3E=; b=T9DT2e22lVhM+F6xt6/9TcyXfOjeuf05yRGvcxsrkHTCewoPDvtGE49Jh8VSO8d5MU XFT+TPM8zmVa1tR0tgiqaotNS3PSM/MbTui1Tz3KPloWxtXN6QQyyasufwTZaIhclGln MdtPQwEizLejVYb77hWpNfu9gl8yVhVnwHhawrIGRW9OcsmG6Sbh3MIJ7NQ07UJmyL6r +gOF2nUH2fmdnTBJq2Ttam0mXoKv2nWyQJA/7Ya6jSruYAHrWN1LXTx8oLpdonhXVicj r3ml/xS15rjkaHr75HTfxveMcnESgsWz4DUfru9l+2J9fiaHy1q9q3JQOjxWWFet1zaL 4Buw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=o8Ku15Vy; spf=pass (google.com: best guess record for 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 l12si8376371edn.414.2020.04.14.06.19.39; Tue, 14 Apr 2020 06:20:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=o8Ku15Vy; spf=pass (google.com: best guess record for 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 S1730515AbgDMPe7 (ORCPT + 99 others); Mon, 13 Apr 2020 11:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730504AbgDMPe5 (ORCPT ); Mon, 13 Apr 2020 11:34:57 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5828C0A3BE2 for ; Mon, 13 Apr 2020 08:34:57 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h11so3499019plk.7 for ; Mon, 13 Apr 2020 08:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ghs4l4nI57la7hO/6EnhN56epQlSYo2HQcGuqn9At3E=; b=o8Ku15VylZmW9RmUdw3LqYItOHWR5uR+BhCzrC4IOozU56RYAeexGHQrmUeAjY0cUB oqwdCBwanWaSy1xBLCk53ZHMr0WWy/+2ket481Z6niFhhrc1+dWnLe5NB0+Nn1LJ6biM pe8iK7TQ1s0nB7ksBzQ942wAKyrtwrXKLYFgYaIvevq/AR/mS2kBX0vDrjFGK53Lf7p7 c7GfBtx0lCLZqVjnntovV3+Cf4/aC7VzdGF04fTeHCWdsbTI9HSsEVToZFo+vKm/F9Gx IpT1KUmj0ARujnTGKsn2qx/2/EzWBZVSaTzIWz6v5uatfnpEq/LCceAV5vOou0azpcxt 5mWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ghs4l4nI57la7hO/6EnhN56epQlSYo2HQcGuqn9At3E=; b=KDBnudZrv108q/ffeM8bYv1rCqBGRo1WJpJw2VaaO3xkMdkAZmWtPgIduA7fStlIeD DXVlaXXYUtDRuqg70UcLlopHo4tDbBPi1D+msk9TrBNEDKRJiEaOeXQh9tXp8gt0yD/o eFQNSI8SMI2B7kMCxCjzMl7xlzwSKCGu0/BYnynxj/YGov4ULCSzvVntkmCuupQssqu4 fFM9EUyUHn2BqmmMC08sP2CSLDMb1BZKlVthFGnL5bkUjJ2T7dX1yLUVJd5+a5x5nUua Likd4/UNF5KmlHDsoakKdYL3z1o4grFMPkbCrnF0tNYsv9CPlg9/4PM12U0bj2atVCWQ pnsQ== X-Gm-Message-State: AGi0PuaaxnEafjBHywEg9i90eJHfsiU5I7P+ipYaCy5NoGM8W6qB1GRO zzqm2yBb0bSGVRHwfoQBcitoiA== X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr17038570plr.76.1586792096747; Mon, 13 Apr 2020 08:34:56 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id q12sm8205213pgi.86.2020.04.13.08.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 08:34:56 -0700 (PDT) Date: Mon, 13 Apr 2020 08:34:53 -0700 From: Fangrui Song To: Jiaxun Yang Cc: "Maciej W. Rozycki" , linux-mips@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Thomas Bogendoerfer , Borislav Petkov , Kees Cook , Heiko Carstens , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] MIPS: Truncate link address into 32bit for 32bit kernel Message-ID: <20200413153453.zi4jvu3c4ul23e23@google.com> References: <20200413062651.3992652-1-jiaxun.yang@flygoat.com> <20200413153205.4ee52239@flygoat-x1e> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200413153205.4ee52239@flygoat-x1e> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-13, Jiaxun Yang wrote: >On Mon, 13 Apr 2020 07:59:29 +0100 (BST) >"Maciej W. Rozycki" wrote: > >> On Mon, 13 Apr 2020, Jiaxun Yang wrote: >> >> > LLD failed to link vmlinux with 64bit load address for 32bit ELF >> > while bfd will strip 64bit address into 32bit silently. >> > To fix LLD build, we should truncate load address provided by >> > platform into 32bit for 32bit kernel. >> >> Reviewed-by: Maciej W. Rozycki >> >> > diff --git a/arch/mips/kernel/vmlinux.lds.S >> > b/arch/mips/kernel/vmlinux.lds.S index a5f00ec73ea6..5226cd8e4bee >> > 100644 --- a/arch/mips/kernel/vmlinux.lds.S >> > +++ b/arch/mips/kernel/vmlinux.lds.S >> > @@ -55,7 +55,7 @@ SECTIONS >> > /* . = 0xa800000000300000; */ >> > . = 0xffffffff80300000; >> > #endif >> > - . = VMLINUX_LOAD_ADDRESS; >> > + . = VMLINUX_LINK_ADDRESS; >> >> The CONFIG_BOOT_ELF64 cruft right above it looks interesting to me, >> never have ever been used. We have had the current arrangement since: > >It confused me either. >It's only used by SGI so probably it's time to rename it as >BOOT_SEG_ELF64. > >Wish someone could clarify what is it. > >Thanks. Agreed that -Ttext in arch/mips/boot/compressed/Makefile 100: cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ and a few other places are brittle. They need to be replaced with Output Section Address: (https://sourceware.org/binutils/docs/ld/Output-Section-Address.html https://github.com/llvm/llvm-project/blob/master/lld/docs/ELF/linker_script.rst#output-section-address) -Ttext changes the address of .text . This can lead to the change of the address of the text segment (RX), but this is not guaranteed (many sections can be placed before .text and they are not affected). See https://reviews.llvm.org/D70468 "[ELF] Error if -Ttext-segment is specified" Reviewed-by: Fangrui Song >> >> commit 923ec3d20eef9e36456868b590873ce39f17fe71 >> Author: Ralf Baechle >> Date: Wed Nov 6 22:16:38 2002 +0000 >> >> Define load address in linker script instead of relying on the >> deprecated and notoriously unreliable option -Ttext. >> >> and previously `-Ttext' was used with this script anyway, though not >> very long, as the script was entirely ignored until: >> >> commit 7a782968041ffc4c2d89816238e2f8ea5cceddba >> Author: Ralf Baechle >> Date: Thu Oct 31 23:54:21 2002 +0000 >> >> Merge with Linux 2.5.36. >> >> Maciej > >-- >Jiaxun Yang