Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1594757ybv; Thu, 20 Feb 2020 23:58:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzwNWEglHIQtK9yUcixnqYdTI5NNBKAT6sX2j0ZWsTTkJswfu6CKxsXSIh+ZgYn7ySlEswc X-Received: by 2002:a9d:2264:: with SMTP id o91mr15752731ota.328.1582271888502; Thu, 20 Feb 2020 23:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271888; cv=none; d=google.com; s=arc-20160816; b=DRxpG8U42tc6CB5+RTuF3j9FUGfMZQKQIIRsQv9G/VNUF29dxO/xKaOQ+eer5Epfar WjFtEZ8Ar0Vs2+GO/xjyb869S3PESdVMAcng6Ul0zzK0RGEbOGeNEIk3brxCFROoyKDf +YZtSd8beorqztlCv7loTsk2b3f9LJxDLkbPHD8PCeT5CO7isHZRyZKmSp2wjSbfGYqW KepRLVvkitMImVb6IhV71j6xjurLePLrOZsRkMwIf6qiCxoS5E8RMsQrq+VV6yIwz1Ay 3WqW8kDUedbk815ODgHtcCuFQxDgvOAvRE5Kwalli9mrNdIKwbcy7K2B1CAYRHsRzCju 3OiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5lY3Wt7tnJu0w8MCvlWRosZJtdKPr3DIHja6Ox6Is44=; b=1IWYpXwKJPHwbP4UwjZ1oFudrLG5hYa8iYSmFPf21gw/+b4PuVyv+w78LvPh5BF1Qj FeKf+FqpLKFSkasAcOIGnYELb3RAbwft0Nia7o434Q+45hnjz6ZmyfgZ1ETLZWYUYdP6 QFVsikUPjyjP2wY3yPhTYPZ02os5XMGuvhBZRND7XxysoZZPXgXYsRhqHyTlHyMKuqhP Ppup5zc4feoDYvbUoH82Ug2JNklE98nLnCaHO+1Wm/41fUl8V/A2KWQq9sHvr19aIZwf oslCb24hwWCN58wdEi61RYpEGej5y3xpytVhoN8pCZrXvFaE8Hq80I+wLXxOIY2/mTRP wyfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZRtdFSNb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i19si438246oik.272.2020.02.20.23.57.56; Thu, 20 Feb 2020 23:58:08 -0800 (PST) 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=@kernel.org header.s=default header.b=ZRtdFSNb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730510AbgBUH4n (ORCPT + 99 others); Fri, 21 Feb 2020 02:56:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:56066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730139AbgBUH4i (ORCPT ); Fri, 21 Feb 2020 02:56:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34F5D20578; Fri, 21 Feb 2020 07:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271797; bh=HYuxXEHOswdXA1U7g6qCOuKe8dawVBoP8iksu7Ddq5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZRtdFSNb3bbBKIIVVzizJmc1/u4gjpbYzGnODWGc2+CsbTs2UYHF8OX9a7S4LZwFc V90534Jw6fbLEu2LQD3/yoPuH0kTkJa2MaeM2XeY+enOPheMktJs+cWyl1PzmMcd+G UL0U5WeFKYv5GkexCA6Y89PDNNlz2AzsuKv3f4+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Ingo Molnar , Nathan Chancellor , Sasha Levin Subject: [PATCH 5.5 302/399] x86/boot/compressed: Relax sed symbol type regex for LLVM ld.lld Date: Fri, 21 Feb 2020 08:40:27 +0100 Message-Id: <20200221072431.053041429@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel [ Upstream commit bc310baf2ba381c648983c7f4748327f17324562 ] The final build stage of the x86 kernel captures some symbol addresses from the decompressor binary and copies them into zoffset.h. It uses sed with a regular expression that matches the address, symbol type and symbol name, and mangles the captured addresses and the names of symbols of interest into #define directives that are added to zoffset.h The symbol type is indicated by a single letter, which we match strictly: only letters in the set 'ABCDGRSTVW' are matched, even though the actual symbol type is relevant and therefore ignored. Commit bc7c9d620 ("efi/libstub/x86: Force 'hidden' visibility for extern declarations") made a change to the way external symbol references are classified, resulting in 'startup_32' now being emitted as a hidden symbol. This prevents the use of GOT entries to refer to this symbol via its absolute address, which recent toolchains (including Clang based ones) already avoid by default, making this change a no-op in the majority of cases. However, as it turns out, the LLVM linker classifies such hidden symbols as symbols with static linkage in fully linked ELF binaries, causing tools such as NM to output a lowercase 't' rather than an upper case 'T' for the type of such symbols. Since our sed expression only matches upper case letters for the symbol type, the line describing startup_32 is disregarded, resulting in a build error like the following arch/x86/boot/header.S:568:18: error: symbol 'ZO_startup_32' can not be undefined in a subtraction expression init_size: .long (0x00000000008fd000 - ZO_startup_32 + (((0x0000000001f6361c + ((0x0000000001f6361c >> 8) + 65536) - 0x00000000008c32e5) + 4095) & ~4095)) # kernel initialization size Given that we are only interested in the value of the symbol, let's match any character in the set 'a-zA-Z' instead. Signed-off-by: Ard Biesheuvel Signed-off-by: Ingo Molnar Tested-by: Nathan Chancellor Signed-off-by: Sasha Levin --- arch/x86/boot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 95410d6ee2ff8..748b6d28a91de 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile @@ -88,7 +88,7 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE SETUP_OBJS = $(addprefix $(obj)/,$(setup-y)) -sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p' +sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p' quiet_cmd_zoffset = ZOFFSET $@ cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@ -- 2.20.1