Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp724556ybk; Fri, 15 May 2020 11:53:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY/XpQ28VOPKd505mvNlAcyKJt4FHtvhobI9tEMC4fZWGHbVEMYS+QYFgrMOtt0/ZJWlJi X-Received: by 2002:a17:906:dc2:: with SMTP id p2mr4163849eji.212.1589568798361; Fri, 15 May 2020 11:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589568798; cv=none; d=google.com; s=arc-20160816; b=sNl1HFvSuKlY4zjNqO9S5KyMQPBogLyuxO2+Kx59WMRRCbIGBncbR7trtyR+d8CNPX hItrEFktG9M3sjuIlnXeCDEUSnS9v/rilgzY3wm+3S569Z5PxZgg55vzC0ir8ZBph9PU n5ROe3rdKsAlqFmq+ct4t8ssJB9ZrWCPv/FZDxbTeabXKivE6d90wOpF2leyFjhLweXg s+x93PC927gWmnxRQyRkxhaXFsT1A9t1Pvl3ioPxycWEDFtmsLMLA3Ry4oI/SsgZXV2x z0FiZfOfNGkGRHBs5SOMA9E3s9pQ/IwQakVs7A8icAnArdNn0ZTktajPTkDwzedzSM9a Gq+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YP9RZMqjeJZdVRtJI2gZU8UCFpzgV4mlHCpsx0w8oyQ=; b=sIcvW+0XbA9XoL3DQvAlNB7TKauMglJ4joyWzXDBKMysDew25W82OAls/haGFrtpJ/ zoKd70cFgJeNYmikBytEMsCw2AjMisiIVY79SecyulqXP4PIFXAjCPgH3MafvCjHUKhQ Y3kf9/Ixr5RtXMmf92fRINwv+zv70kycxLjF15sffI2WJOZMn+NW+Cyt0rxIwcp6pp2J jm/NgROqwmjGxatCPazqsm/KMcq1dcfkvI80ARpUwyiDi4qhiTTleLonOLb9hbPkYnil fIEWNZhK0NEWvgd7E2TuDL5PcqC8xaJ/yBqgIx4nl2ZlMimKzmtGtzn3qYUH7Ez9N04G zAag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Hup5ZOpB; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si1841743edh.532.2020.05.15.11.52.53; Fri, 15 May 2020 11:53:18 -0700 (PDT) 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=@alien8.de header.s=dkim header.b=Hup5ZOpB; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726278AbgEOSu7 (ORCPT + 99 others); Fri, 15 May 2020 14:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbgEOSu7 (ORCPT ); Fri, 15 May 2020 14:50:59 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B89C061A0C for ; Fri, 15 May 2020 11:50:56 -0700 (PDT) Received: from zn.tnic (p200300ec2f0d67004cd1c8a6a574a4fa.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:6700:4cd1:c8a6:a574:a4fa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 27A941EC02DD; Fri, 15 May 2020 20:50:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1589568655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=YP9RZMqjeJZdVRtJI2gZU8UCFpzgV4mlHCpsx0w8oyQ=; b=Hup5ZOpB1Xg26Fj3NIW+wcvZivoPvwYsr5cO9V6lKmE+EyALZrZuI/JCrQWx9dsN2FGObm XZq9Rpw1QKsBdbI9egp4rs2K11bEJR9iWtYaH8BxR8i6lTx/L0CQyD3bYI4CmxCANmA1kg G3mvDAhosBfq27HSXduiQinmStc7k1c= Date: Fri, 15 May 2020 20:50:51 +0200 From: Borislav Petkov To: Dmitry Golovin Cc: clang-built-linux@googlegroups.com, Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Nick Desaulniers , Ard Biesheuvel , Masahiro Yamada , Daniel Kiper , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/boot: allow a relocatable kernel to be linked with lld Message-ID: <20200515185051.GC19017@zn.tnic> References: <20200501084215.242-1-dima@golovin.in> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200501084215.242-1-dima@golovin.in> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 01, 2020 at 08:42:13AM +0000, Dmitry Golovin wrote: > LLD by default disallows relocations in read-only segments. For a I need more info here about which segment is read-only? Is this something LLD does by default or what's happening? Because my BFD-linked vmlinux has: Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000001000 0x0000000000000000 0x0000000000000000 0x000000000070fa28 0x0000000000726b00 RWE 0x1000 LOAD 0x0000000000000000 0x0000000000727000 0x0000000000727000 0x0000000000000000 0x0000000000007000 RW 0x1000 DYNAMIC 0x00000000007108f8 0x000000000070f8f8 0x000000000070f8f8 0x0000000000000130 0x0000000000000130 RW 0x8 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RWE 0x10 so what's up? > relocatable kernel, we pass -z notext to the linker to explicitly > allow relocations. This behavior is the default for BFD. Or are you saying that ld.bfd makes the text segment by default RW while ld.lld makes it read-only like the elf manpage says: "p_flags This member holds a bit mask of flags relevant to the segment: PF_X An executable segment. PF_W A writable segment. PF_R A readable segment. A text segment commonly has the flags PF_X and PF_R." IOW, don't be afraid to be more verbose in the commit message. :) Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette