Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3477898pxk; Mon, 5 Oct 2020 10:38:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjU4q1pjk93WtQ31q3OjF1seHxskvulBY/pBEXaQ5RGX6KCyPYpnwix98KPJCCIqP84XOb X-Received: by 2002:a17:906:1b11:: with SMTP id o17mr882670ejg.67.1601919513732; Mon, 05 Oct 2020 10:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601919513; cv=none; d=google.com; s=arc-20160816; b=AVB4yFy7kTylriFfX7++20K3buOHI+FubxPxzQLTyqX0yyBv3SPp+xclHPKhufH72h xUXAGuZnjGa7kqTk1gwkCEuo2jmQMqQksAXtMHuY/gvHC6GcoA0PjJW/bUiux6+NRLNw LXiWeBYFLruFrHz9VilEJ/Lom5oHEWy0kaC+SSXEQ5Lcc+T4Jx+/dDrMne4FLJkW+Nsu VM4FYO8BEPqQw3CxZbNXaQPnauQbJ2i8pVTMCcFlSRvOWWFqmjT6eOdYce/l5mmODrI9 Ah94ZbzcDCiIELhmFx1SQ4xuNDyVRU8HOeQol4ApNC8XjjWp/eaVMo55CjHHruRKr8XF o15g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tGneaUPSfmwmZclVabdMQtlpK5P/Q67PdE+cZq4zgcM=; b=hrQdulPOSarQUK/gCmagmzFw1leAj6uVrgJnn0Op9VARPfRkn1ciGu7hAcG9CzCSiq aFn2ME+02sZc7tnIA70saZfVm7FNEbf5pB8GwCj2SJTkc+JPqfhuey0UE1O0vC0hvf/Q GiOb0z5kqrNAGjFeMsByrBlFuI+7Halbw90i3KX0o7q//ppHy7rG2XoNYoLUzj9JeqNU VSj/C+Y5E0FbSRh3HhiZH70cvPbWhEQ3nKEQ0SJjn5TbommmKxcUeJxHOdkCc/ZK13it ll/r0KTS4cwioUUGlpkh9Mc27HmxWKVLzncPt+6R+8POopPzsYaUWrf+HWnqJ+jduNld EmsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GBwOGDWD; 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 w18si470606edt.399.2020.10.05.10.38.09; Mon, 05 Oct 2020 10:38:33 -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=GBwOGDWD; 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 S1727896AbgJERgW (ORCPT + 99 others); Mon, 5 Oct 2020 13:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbgJERgW (ORCPT ); Mon, 5 Oct 2020 13:36:22 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C1DC0613A7 for ; Mon, 5 Oct 2020 10:36:22 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y14so4152645pfp.13 for ; Mon, 05 Oct 2020 10:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tGneaUPSfmwmZclVabdMQtlpK5P/Q67PdE+cZq4zgcM=; b=GBwOGDWDRut7KhZTbQ6/Yi5l7rHvibdoTP1rWlTv094qtnCKgxidxIjLDZIspampjB dEWxjaqxkI2E/pLxBwkz5mNnUeWikWSVhEc0F4xiw4LQqc0VI+I/Gpd4Kw0BxlVF7DvU sCs3d4yP1p+CFlSyF9mp7MdSst1cLCLOTL++2rVcqvUzrV6Qqb3lrSTYJ1tpzX6QbWqf LlxpmqrhyBE54li2VPtdndcbISMNFKzaemvvZkv8UnyrU86L3/cXE6fMebI+Bb0oaqvY iMjhvjfAnZDS7s06AEcd/aUI/xi+GG8yG7ggyZ2pIr3MbiSjAuXsVuF/5jGVm+q8wydN XmvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tGneaUPSfmwmZclVabdMQtlpK5P/Q67PdE+cZq4zgcM=; b=HhJqWs+ERsgyyBO+ic1gZdA81Bg5d03SxbLOoS0zFxDD35Ch4kPnu/rKuEqrYmpoHl Mh+kcgeRvqlOJlZ+RVa/++gtYdiQbm8LKhMeU+3oRDS2GeuhSjd/zThh79VVCASaPV31 CNyninv2SRiwPm7W1x05d3KqjIrCeYJqFK0hyL9EbBCdQipcV52pWhga5CXAze4Q5ROs 3iJg6GFQUkErHgk+X6sd4BFmqe+7t7LqEj2BIyspG1kGqPVysG3MNr+rOKI0MqCmmecO 75T8eMcarHs8q9x1jMozFQAUBUxhgft3AF4IBME7kZWRDzm1tXBppqCyElFecnmAC0lc G9ug== X-Gm-Message-State: AOAM532sOczllwxFs3f0SJIvnNRaLfBLfPpvJnRLVpgr1IalFRVYgdz0 hveksKfWOV3ZkhxWVpapCVE6gXwDet1qw9AIxkkOYg== X-Received: by 2002:a65:6858:: with SMTP id q24mr596445pgt.10.1601919381716; Mon, 05 Oct 2020 10:36:21 -0700 (PDT) MIME-Version: 1.0 References: <20201005025720.2599682-1-keescook@chromium.org> In-Reply-To: <20201005025720.2599682-1-keescook@chromium.org> From: Nick Desaulniers Date: Mon, 5 Oct 2020 10:36:11 -0700 Message-ID: Subject: Re: [PATCH v2] vmlinux.lds.h: Keep .ctors.* with .ctors To: Kees Cook Cc: Ingo Molnar , Stephen Rothwell , Arnd Bergmann , clang-built-linux , linux-arch , LKML , linux-toolchains@vger.kernel.org, Segher Boessenkool Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 4, 2020 at 7:57 PM Kees Cook wrote: > > Under some circumstances, the compiler generates .ctors.* sections. This > is seen doing a cross compile of x86_64 from a powerpc64el host: > > x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/trace_clock.o' being > placed in section `.ctors.65435' > x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/ftrace.o' being > placed in section `.ctors.65435' > x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/ring_buffer.o' being > placed in section `.ctors.65435' > > Include these orphans along with the regular .ctors section. It's very curious to see different behavior based on whether one is targeting x86_64 via native compilation vs cross compilation. Acked-by: Nick Desaulniers > > Reported-by: Stephen Rothwell > Tested-by: Stephen Rothwell > Fixes: 83109d5d5fba ("x86/build: Warn on orphan section placement") > Signed-off-by: Kees Cook > --- > v2: brown paper bag version: fix whitespace for proper backslash alignment > --- > include/asm-generic/vmlinux.lds.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 5430febd34be..b83c00c63997 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -684,6 +684,7 @@ > #ifdef CONFIG_CONSTRUCTORS > #define KERNEL_CTORS() . = ALIGN(8); \ > __ctors_start = .; \ > + KEEP(*(SORT(.ctors.*))) \ > KEEP(*(.ctors)) \ > KEEP(*(SORT(.init_array.*))) \ > KEEP(*(.init_array)) \ > -- > 2.25.1 > -- Thanks, ~Nick Desaulniers