Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4623528ybb; Tue, 7 Apr 2020 11:05:05 -0700 (PDT) X-Google-Smtp-Source: APiQypIpOrwoYEd0VZ8bzZax614Rc63npTmx8+LF8snqDtVKwBYpg/p1al/m+n+D2IMQ9AXj1u7i X-Received: by 2002:aca:3386:: with SMTP id z128mr92867oiz.40.1586282705260; Tue, 07 Apr 2020 11:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586282705; cv=none; d=google.com; s=arc-20160816; b=Qxwq8fpl4hlRzQNPqZR+RTWFC5rVUNF6l+vmpJnC240CrYF3Sibb2YftV4fw1KNQNg sy+lE6czcE5af5c+5NBuw/8SodnOJqPm4h0iQ106TJZoY33grsT+8j6GJU3+t91flKoH 9D2hKDoH7OVH1+j6CUTCiD8RqqgwGKbDSn3lQHjREAXKDT2vTmKGrmhLHWS2QI1Lyu+n tsOf5tvB6phXypDMuBQ7gX4xaUHGCtWeGaoVCQMuOuivFRG9eIGMGS310brPqfZRJJ4O Cho429pMTV7vlrR3VP+8apTDyOe4Nv9wpEFDl6f3jRN5bbSnbpK3tWWS1Ep32V+ud31h g1WQ== 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=lL9PIYFwO5H6pFnjqwU20khB08jFZDfwSO7ZNczzL60=; b=02f74vRav/Q77K88fcDuL3dkCgkHdHWgW89NsoF/4WHHu3NgZMyVzQTXIskO/dZGfO Ab3rCoekfJt0r12a9VI8iCaJJpWh/WCwpd3vC+f33tMVKGMY95sgO64jyPeaNVQppnU4 +VINd36aG/oJVtXyUCLldrCfoDXZHinCVHPdUugII0MXL0FamwhlYzcIdusRi9MVpVt9 5W5PfMXM7lDgwJY7ZNm79ZcGMLi2+eGPPG/qzQODszaamP+5tv0NQ4Ne4cRZguoRKtWJ rdHRGc4BG2IHc1LCaoBoVFgEB09M6gHmGOmgyTsCp7ruZ0U1YpoLlhRH5A3wH26rhBy7 aniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Q/OfXybI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p14si1510542ota.96.2020.04.07.11.04.34; Tue, 07 Apr 2020 11:05:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Q/OfXybI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726683AbgDGSAc (ORCPT + 99 others); Tue, 7 Apr 2020 14:00:32 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35923 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgDGSAb (ORCPT ); Tue, 7 Apr 2020 14:00:31 -0400 Received: by mail-pf1-f193.google.com with SMTP id n10so1155446pff.3 for ; Tue, 07 Apr 2020 11:00:27 -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=lL9PIYFwO5H6pFnjqwU20khB08jFZDfwSO7ZNczzL60=; b=Q/OfXybIX8XlBl388UsB11QYwnOCa77KIKk/PH2qaCLJ0tvBd2Dw/XQfo5DA/0q5eU 5Pz9U+Dabp+E29nomZdI8TCjGZbnxVwkEmJffIc3mGlnqjfgGbNixLmi56NjfVPKmM4k ceiMJ3AjBIB7lOHBJ8MH3rvgSniG1nSLjEyEVsCkU3INp01/OCa1XolRbiJd3STSkisO /ohkM1yAal9IN0b5N2vDDxbpYK8+HeqsvxDsH20mN5tpz/feTewAtsa7gWBv+uNkFhKv a5cDtTsMDv6ZDSqZSAPg464bqGFlqT3LBqOaXCXHnD3Uh1M6Db34nMS+FxWZFVTGW4OQ kI+w== 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=lL9PIYFwO5H6pFnjqwU20khB08jFZDfwSO7ZNczzL60=; b=QIhMvGpcynKH7lIn5NjE/iX711EB0YBOf5NNPRt5rDruaa/memB95Lz/3Bs9ROUvwl euVYgldA+2+Xo9J0Dovsj5w8VDzHUcpva/V7SUUeTvPo5Z+KlbeDe//3u6IHVZeOzRgf yYu2qpS+waVFZLgZ587jSyy8loAGJ0QRcjzlxFZAOSnI+QNdG105YgR62O64AjsBRWx+ O0lxvNCWynLzm/Irhx/Ay6CfgI9KlD1WT56Vm/41yhnE7TF453g0/V8Qswm+vEtUquG9 5onmha4H3/Qoa15M+W6HkRp+uaGBP+L9rYrdP6Wp95ilc/G1f2P2GHC1Gxe90x9vIssX m98A== X-Gm-Message-State: AGi0PuZXQSo33kpyiKoy9K/9xYYNO8G1Fh/e2Ss7gP3gRQRviIE2nNlG gbzauae/TOYR76czExD2+SaG5A== X-Received: by 2002:a62:5f06:: with SMTP id t6mr3817977pfb.192.1586282427135; Tue, 07 Apr 2020 11:00:27 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id 66sm14769704pfb.150.2020.04.07.11.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 11:00:26 -0700 (PDT) Date: Tue, 7 Apr 2020 11:00:23 -0700 From: Fangrui Song To: Nick Desaulniers Cc: Jiaxun Yang , linux-mips@vger.kernel.org, clang-built-linux , Nathan Chancellor , Thomas Bogendoerfer , LKML Subject: Re: [PATCH v2] MIPS: Truncate load-y into 32bit for 32bit kernel Message-ID: <20200407180023.vpwkhtrg3v6inqtt@google.com> References: <20200405082451.694910-1-jiaxun.yang@flygoat.com> <20200407080611.859256-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-07, Nick Desaulniers wrote: >On Tue, Apr 7, 2020 at 1:07 AM 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. >> >> Signed-off-by: Jiaxun Yang >> Reviewed-by: Fangrui Song >> Tested-by: Nathan Chancellor >> >> -- >> V2: Take MaskRay's shell magic. > >V2 is way too clever, V1 was much more readable. This is difficult:/ https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04 The POSIX shell is only required to do signed long integer arithmetic. "signed long" can be 32-bit. awk may not provide precision more than a double ("... decimal-floating-constant token as specified by the ISO C standard") % gawk 'BEGIN {printf("%x", (0xffffffff80101234 % 0x100000000))}' /dev/null 80101000 >Can this tag be added to the commit to help us track when and where it lands? >Link: https://github.com/ClangBuiltLinux/linux/issues/786 And this tag for GNU ld enhancement: Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25784 >> --- >> arch/mips/Makefile | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/arch/mips/Makefile b/arch/mips/Makefile >> index e1c44aed8156..f8fd3c39fb55 100644 >> --- a/arch/mips/Makefile >> +++ b/arch/mips/Makefile >> @@ -286,6 +286,9 @@ ifdef CONFIG_64BIT >> $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32) >> endif >> endif >> +else >> + # Truncate address into 32-bit >> + load-y := 0x$(shell echo "$(load-y)" | rev | head -c 8 | rev) >> endif >> >> KBUILD_AFLAGS += $(cflags-y) >> -- > >-- >Thanks, >~Nick Desaulniers