Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp114788pxu; Wed, 14 Oct 2020 22:16:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3AjpKNvAfUIhTACshogD3izxF4pxkVymdr1Hgydzi4wZUYN4c2gC8osB4NxR1YgknKLKI X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr2388501edb.129.1602738984625; Wed, 14 Oct 2020 22:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602738984; cv=none; d=google.com; s=arc-20160816; b=czds3tCSNfn3r758puKAMSMEUqkmPJiGDHoWY82D9OnoKpW1/5iAvyw4wmtxThMZh3 tCQxgsvj3CLdNSZ3cKmJ4yYryap0d4dN9oy9w7rVGYbwMr0EtNpaukU9bWLycbO7ukpR JtuwidnGKZ4mpfbpSFKjxEQ2IIvWaXXrMow0CntCw5JV4IVY+wKIxyS2hWPtVvpSU0E5 DoSsZ8Cots8pC1kZiHamZWFw/41aP21jxQUkhY5iOTh29MtML+QryEpsH3cSJBEA0/hn 6BTag/ccmoP59gkReim9hbcgSSFeZiOU9b9AxS3Nho3qKZdHov2/PhjNaQPuWQJu2BBU C+iw== 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=WnT7VxOT22lB70S274n8jv3DY8IooahSVVXzJOT5Npo=; b=Wd7ERgj/D+Q7fdEN1DukAJ7/RQJP8KP0toKN0la11pzeQg7S37wpocGXrR9hA7bx6x /bZfcBD+ZQ894BIrY8Lx+qLD3U56Xkwj2stIpsQ7gQyamKkIYOa0Kn8H/de28HXP3NOH QBlVqx4pbBa3C3++wNyAVIhHHJLFepyV94ay7DzFr1dzUzMqxHgBJcWf3NqAEzQAtfNy qYkY1ofqHMCkBL3s+rwMv6/t6ocwUfaNOfUKPRFIQDe9QW7UMKvYDpO8VxxXm4Y1cLIe v5zN3M8lY1V5dp4whO6zwM9cE4zR+PcrP8l+vT9dXq10Gj2Lo0hNwXZjp1g060gmLtV8 y6tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ErrZa3fP; 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 h24si1341429ejf.680.2020.10.14.22.16.02; Wed, 14 Oct 2020 22:16:24 -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=ErrZa3fP; 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 S1728750AbgJOExv (ORCPT + 99 others); Thu, 15 Oct 2020 00:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgJOExv (ORCPT ); Thu, 15 Oct 2020 00:53:51 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67B35C061755 for ; Wed, 14 Oct 2020 21:53:51 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y1so930510plp.6 for ; Wed, 14 Oct 2020 21:53:51 -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=WnT7VxOT22lB70S274n8jv3DY8IooahSVVXzJOT5Npo=; b=ErrZa3fPnuCZhR9OKjBG0KwI9Dy24n9g1z/rXD+KQJT6GVNwvzKJ/zcljR37vCMyqU udTVtqjX0T9o8HnDCwYanc81u4uNT5ni0xwqQU4VGEYbfroj6bLhLGL5ONCbioSV9MwN IzEQoyGCYEVxE0XCOgEdc3CYSRrS+uuPeJSLcY2v5oxUUe/+/jukunvhp9/MDwy4gWwv uSeqpZwdbnL67KJIqUBykeqKpL3c9ctQ8IUzN9bKSequgA7hJmBeobS4QeukTr29Ee4o ZiLMZqMQ0pmJSgTL0sMu34/4S7XhdEv6u/W7M1FDkmSs3akxSPuVSNGxNqqvVLYsAN4J DqBw== 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=WnT7VxOT22lB70S274n8jv3DY8IooahSVVXzJOT5Npo=; b=A/UCrVazN1nR0/rMF6TayT8Z/Svq5TvpfwNxeWrNqJMLItABe/VpagfxkhggpZ1r9C fIXdozBjf/n99hEyuiMVr6nyFF8TdJh2YrZ4G4Q4s1pTAWpfLNhWEPsWBFRXpIyDpFpJ 1Sw2nr7ZKBQrQylV6R1A6bloCjkKqvo9w/zplt3r26CWXMZuViGnmjJGEpvHkYsEk1kB jFjMd+dradVr99QLth2iupvwmk+yanxlECigIMtii4c/3mP7GElV0Qwm3wcLWcft1uz2 66WrrDveiSmw+QgVCHe3WiGPJ2HkPvT0XmxQYreg8lz5RAnWRzd93YQuoJuIbKoeodwy NffQ== X-Gm-Message-State: AOAM533cY3bpAEaznMmm6eKRtlzMFmlg8YdjDlu2aUI46AlGW6alnOJn IGPJdoB54/WwgBO13C58QUGTYOWf/mwJIMceWM2Awg== X-Received: by 2002:a17:90a:8002:: with SMTP id b2mr2638763pjn.47.1602737630777; Wed, 14 Oct 2020 21:53:50 -0700 (PDT) MIME-Version: 1.0 References: <20201005025720.2599682-1-keescook@chromium.org> <202010141603.49EA0CE@keescook> In-Reply-To: <202010141603.49EA0CE@keescook> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Wed, 14 Oct 2020 21:53:39 -0700 Message-ID: Subject: Re: [PATCH v2] vmlinux.lds.h: Keep .ctors.* with .ctors To: Kees Cook Cc: Ingo Molnar , Stephen Rothwell , Nick Desaulniers , Arnd Bergmann , clang-built-linux , linux-arch , LKML , X86 ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 14, 2020 at 4:04 PM Kees Cook wrote: > > On Sun, Oct 04, 2020 at 07:57:20PM -0700, 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. > > > > Reported-by: Stephen Rothwell > > Tested-by: Stephen Rothwell > > Fixes: 83109d5d5fba ("x86/build: Warn on orphan section placement") > > Signed-off-by: Kees Cook > > Ping -- please take this for tip/urgent, otherwise we're drowning sfr in > warnings. :) > > -Kees > > > --- > > 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 > > > > -- > Kees Cook > > -- > 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/202010141603.49EA0CE%40keescook. I think it would be great to figure out why these .ctors.* .dtors.* are generated. ~GCC 4.7 switched to default to .init_array/.fini_array if libc supports it. I have some refactoring in this area of Clang as well (e.g. https://reviews.llvm.org/D71393) And I am not sure SORT(.init_array.*) or SORT(.ctors.*) will work. The correct construct is SORT_BY_INIT_PRIORITY(.init_array.*)