Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2180989ybk; Sun, 17 May 2020 12:46:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3lzJ7lz7dpVfRdmnKeZX9nAeMbQsYRpSn08quQjDUkV5RQwRd2uoxmR3Ab+feVvIyEUBM X-Received: by 2002:a50:9547:: with SMTP id v7mr11516204eda.78.1589744803297; Sun, 17 May 2020 12:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589744803; cv=none; d=google.com; s=arc-20160816; b=zaj0MkOenur6RFjrgrHdP7Jod2wXx2bfB9f8LfwQVrIZZFC4kQKC0HpL5GkqtD6Q3j VKRXOADfaxDonkcZMrcgHuK7ezSECQCL3KMh4od1mwmr35uIdYSZ35GZMB/Qx+0JKsOv OzdACrym1vwnBxhOVVO/QME/ss+B2D1D+pRB+gw4rGwJA9/P3sO2uY73XvPrOgKx1LpP gTMigdymd6eF23g3ZJOsO0JoQe8xRaTSggA+TQbpwA7tlNhLO9rnArg5LqCD+umeOoMg uSOkAG2m8Ajv7qdltwa67HDLlsIkNW29FmOVF9xbudnsAzeDpFCej/UxP+QAnZ6HEBHR m+KQ== 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=rw0Ndp5myB1Bal+4CE0r9ds1UFnKxD+e83Qnd9thPnk=; b=xS8u+mXA9smU1Xu7fQUVBCHPwx1NdZb4ec9wXwoKPl9Mf9z1L+JWrptwf2NTH5FzmG eRCL5f9AmbpBRff6eApA1S2Nc4L0GIj+WKn8d8jrPiamNzaVRFHuEQALX4qNXZlvmY23 9fpCTfH3cc5whqi41StkpujMxu28lBatfhavkBtgIjmElfefwlp3KMKCq5Eq4R/SVjw+ Yd9CVHn0x6eGsqV6HU3I+mGFC4IZ/lR8x00K1/c2dUbmGIcGU7bgmCTUsc3093tu4IdT KhSD+P9DXnMCKPc/edIFNpQOjleVS13QG+YcbL3xPe8EZ/jk8ClzgtiyiauO4vFuhc2R zEJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QHWK6PzJ; 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 o3si5166954edb.156.2020.05.17.12.46.18; Sun, 17 May 2020 12:46:43 -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=@google.com header.s=20161025 header.b=QHWK6PzJ; 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 S1726557AbgEQToe (ORCPT + 99 others); Sun, 17 May 2020 15:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbgEQToe (ORCPT ); Sun, 17 May 2020 15:44:34 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFC7C061A0C for ; Sun, 17 May 2020 12:44:34 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id x10so3293458plr.4 for ; Sun, 17 May 2020 12:44:34 -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=rw0Ndp5myB1Bal+4CE0r9ds1UFnKxD+e83Qnd9thPnk=; b=QHWK6PzJdVPz0KmIlJJX4OWjlMiwz4IWqykFFE2pzYfO4QmMR8AsntikrP2YKf/QfL l+XW9WPR+ygSdwWIV+7KxE4ESG+a4YkoCmeOc+gK34Fui3OcLWfb1ND5FoAnuwc0IZ77 MULqVr2QyTgXVjntml+MZd7xkIUutd/15IrwLX16ItCysckS+ckMYOvYG+MFVshxn2PR StnMhQEHjZX77tm5vsGmTNGySXtDE/6z6/5tCbIg2GA/V8NE+fX2syRtICAG8Nzo0Pwp ECBERfYXwbQ7oW51xi53lNMy6N/Ub/0e+jBXsTmoQUqI38ri39WnS5L+Exr5fuhwWpo3 9/ig== 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=rw0Ndp5myB1Bal+4CE0r9ds1UFnKxD+e83Qnd9thPnk=; b=k89NKa/I0OGUTA1Z1I8oEB91RGX0jq+lqWMLkJJuU/GJB37V+reeMataRDrnqL20r7 H2d/7IYDd8KjiysEiY0OuYrd9vVxn+AZ5AwCg2ck5Trc/lDvG2n6Yk+ZeysNmp0FaX84 KmUoYdOb0GbQ4qV5ucoIP9eO9rw19Ca7gfi/GGyFqopOtHPlrutstrUOSL/gFJo3Ez5i dMHp5/NcMLA7UoPFVWKDEgVgTXIKbZJ5VBzgwAS8EJyOjGKv6K0f17tIYPIivWoBhidS CyGXgZyO96RVGVWyQ5Gzx+UxqDNrGoXmiygxvmAJx8YN6mj6JXBrYzrCkupRUnSnWGor DmSQ== X-Gm-Message-State: AOAM533N0Ly5wIiTwmBIS7I4kBKHIERMiWkv7qWQwcKuSq6Ef9sFKZkI byt+H1u4c1n9OCHhOCnU4JN1mw== X-Received: by 2002:a17:90b:1004:: with SMTP id gm4mr16090867pjb.35.1589744673401; Sun, 17 May 2020 12:44:33 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id s102sm6669508pjb.57.2020.05.17.12.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 12:44:32 -0700 (PDT) Date: Sun, 17 May 2020 12:44:29 -0700 From: Fangrui Song To: Dmitry Golovin Cc: Borislav Petkov , "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: <20200517194429.scwhfr4l4bv4h3ux@google.com> References: <20200501084215.242-1-dima@golovin.in> <20200515185051.GC19017@zn.tnic> <602331589572661@mail.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <602331589572661@mail.yandex.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-16, Dmitry Golovin wrote: >15.05.2020, 21:50, "Borislav Petkov" : >> >> I need more info here about which segment is read-only? >> >> Is this something LLD does by default or what's happening? >> > >Probably should have quoted the original error message: > > ld.lld: error: can't create dynamic relocation R_386_32 against > symbol: _bss in readonly segment; recompile object files with -fPIC > or pass '-Wl,-z,notext' to allow text relocations in the output Do we know where do these R_386_32 come from? When linking in -shared mode, the linker assumes the image is a shared object and has undetermined image base at runtime. An absolute relocation needs a text relocation (a relocation against a readonly segment). When neither -z notext nor -z text is specified, GNU ld is in an indefinite state where it will enable text relocations (DT_TEXTREL DF_TEXTREL) on demand. It is not considered a good practice for userspace applications to do this. Of course the kernel is different....... I know little about the kernel, but if there is a way to make the sections containing R_386_32 relocations writable (SHF_WRITE), that will be a better solution to me. In LLD, -z notext is like making every section SHF_WRITE. >> >> IOW, don't be afraid to be more verbose in the commit message. :) >> > >Tried both BFD and LLD for linking to understand the difference more and >rewrite the commit message, and came to the conclusion that the patch is >wrong. I will submit v2 when I figure out the correct solution. > >Regards, >Dmitry > >-- >You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. >To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. >To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/602331589572661%40mail.yandex.ru.