Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2869551ybv; Mon, 24 Feb 2020 13:18:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxKFZvE9/U7em8qNnhWjkH3xC7/2aj25eYG/GQgpnhIu1tKuQ3WC+4gJsET2ZSVvRr8wn9v X-Received: by 2002:a9d:6215:: with SMTP id g21mr21567287otj.265.1582579135023; Mon, 24 Feb 2020 13:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582579135; cv=none; d=google.com; s=arc-20160816; b=QOd1SN5Gl94BXw/kCSascvjSHQMk6vRoNVS4hdJaMX4TKeDIEsI7ofTSKg3yz372VV fe0yC7onI3ZR7OR84GgkeyvrqOWam11yG+712qRZk0JQmPUSQNaXuhzA1skx77bR3GhR eQedxYJX0HIaSJBOpOgwUUBou90kEg4glKFg3pxjuAyfBYIgts/tq+ERuh5U+4uiX379 U+TIgIZPXIJGa+G7ECHb7hU66Ng+z9MmG//lvMYVD/+EbdMXPPe6aWpSHfB8XP3X7HwF 6Fp8Sbmcf9dQbOc89ewwRCXAx7I1UbFTDIuP78DR7Zq9JttbKpXkThmMK7jLkq7/BoNg bzag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=n81gtXjw+2ieZ/bEPe6r6jWFZXVIieracfuZrlD29fQ=; b=hQF1S37yo5yFQVtcxm+t1fZXzrzVyiRyq5kprtR3XSSksxZ4wlkSFCMBeAct18fFI5 5T9GGnOOXr8/IJJnJLGd0514SgUeXn0kmSbtbeQHAF0jNg59NQJqxYGRmNSObzrLYtSL XlBk6aYZlaFjfaJB0oEn39z2KRlKinZ+TN/IYjMGv95Yuts4YVULTCtwg4dCO4m1Z0/g pu0fkgxky6aaoA1gxs2MHlLlcZWr53bErafblV2z4U+FRaasBMvudysSwfytpKwJxgSj pi2Y9Y+sqxYgolQsfHoa8HLWp9VqqfhA4QG5EAVNgCYt5eu8nmJpxe2JDzl408MgDDr9 VrNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CgLHd9z6; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si5746175oij.242.2020.02.24.13.18.43; Mon, 24 Feb 2020 13:18:55 -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=@google.com header.s=20161025 header.b=CgLHd9z6; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbgBXVRW (ORCPT + 99 others); Mon, 24 Feb 2020 16:17:22 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:40034 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbgBXVRW (ORCPT ); Mon, 24 Feb 2020 16:17:22 -0500 Received: by mail-pj1-f68.google.com with SMTP id 12so298210pjb.5 for ; Mon, 24 Feb 2020 13:17:22 -0800 (PST) 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=n81gtXjw+2ieZ/bEPe6r6jWFZXVIieracfuZrlD29fQ=; b=CgLHd9z6q/Tw2VVqGIzOmXdtrGyMfkzCVFkTje/+lwlipv7xNGkMEobT1OkO+hBkdz BD1aLja4Fz+Q/QGduWjDes6hjM9u0Tyq/HidcqF55LwA1I6nwwQfb3a53vZFI1yk/3S/ UBWQKkm3eUUDRwi6duYuNlA3omDHYAUk4ghfRUHCoQWHDBFQfoiM/8IyWOFdfF2EpOTb l2dQE7K+L5eQqoGEqBV+jJs8oCbNRTIpxov5ocIx1tMvwMfWeDLick6SNk7nqGruK36y vnYfAj7XhTHOelT/rY5/fZ7WbL9h43G+XyTzLUfnNm8Loege901tsitxia4BCNsDILPi 2Cmw== 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=n81gtXjw+2ieZ/bEPe6r6jWFZXVIieracfuZrlD29fQ=; b=NgR4APn8tvI7SzJCAPbU6TD7x7Q+K7O6SPwfVwPE9h06eNpJgE1APKd4f2nXzSWnuV nwNI2+B04BNUG+NuYiU55G6uEDdACTStV6MM88jMiOWP6IObfWtI/RDagCbmS1twM9Jt rRGRywAdOdeJW8zMaw7Pc0JAKNBgxavRTitVIe7PdAPo567E6b6sRyS/KmwB1HZfAgbo tZUqNz6+xz/smj0WT6bENNsjVudHzfuSCBh759NjfKuzKGLQmWHOWApqo3H36dhZsGxV DrSE9uj5akkFwufjTyhj+cnPeEb3PHzxf0MMWCw+GplfkWL5mw373JGqsgc2FXiji2oK aiIg== X-Gm-Message-State: APjAAAWS9EBi5YkKAyz2Fmyo7s8U0NgEJ5Jv/smWpk2rWm/8BbLCTvOX onsxQd/C+V7RIKEutfFv4MSgMFhXcZzyX+m8WH6PNA== X-Received: by 2002:a17:90a:be06:: with SMTP id a6mr1149344pjs.73.1582579041319; Mon, 24 Feb 2020 13:17:21 -0800 (PST) MIME-Version: 1.0 References: <20200222235709.GA3786197@rani.riverdale.lan> <20200223193715.83729-2-nivedita@alum.mit.edu> <20200224210522.GA409112@rani.riverdale.lan> <20200224211209.3snqf7atf5h4ywcr@google.com> In-Reply-To: <20200224211209.3snqf7atf5h4ywcr@google.com> From: Nick Desaulniers Date: Mon, 24 Feb 2020 13:17:10 -0800 Message-ID: Subject: Re: [PATCH 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections To: Fangrui Song Cc: Arvind Sankar , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , clang-built-linux , Michael Matz , Kees Cook , Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 1:12 PM Fangrui Song wrote: > > On 2020-02-24, Arvind Sankar wrote: > >On Mon, Feb 24, 2020 at 12:33:49PM -0800, Nick Desaulniers wrote: > >> On Sun, Feb 23, 2020 at 11:37 AM Arvind Sankar wrote: > >> > > >> > While discussing a patch to discard .eh_frame from the compressed > >> > vmlinux using the linker script, Fangrui Song pointed out [1] that these > >> > sections shouldn't exist in the first place because arch/x86/Makefile > >> > uses -fno-asynchronous-unwind-tables. > >> > >> Another benefit is that -fno-asynchronous-unwind-tables may help > >> reduce the size of .text! > >> https://stackoverflow.com/a/26302715/1027966 > > > >Hm I don't see any change in .text size. > >> > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > >> > index 98a81576213d..a1140c4ee478 100644 > >> > --- a/drivers/firmware/efi/libstub/Makefile > >> > +++ b/drivers/firmware/efi/libstub/Makefile > >> > @@ -12,7 +12,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ > >> > -mno-mmx -mno-sse -fshort-wchar \ > >> > -Wno-pointer-sign \ > >> > $(call cc-disable-warning, address-of-packed-member) \ > >> > - $(call cc-disable-warning, gnu) > >> > + $(call cc-disable-warning, gnu) \ > >> > + -fno-asynchronous-unwind-tables > >> > >> I think we want to add this flag a little lower, line 27 has: > >> > >> KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ > >> > >> so the `cflags-y` variable you modify in this hunk will only set > >> -fno-asynchronous-unwind-tables for CONFIG_X86, which I don't think is > >> intentional. Though when I run > > > >It is intentional -- the other case is that we're building for ARM, > >which only filters out the regular KBUILD_CFLAGS, so adding the flag for > >it should not be necessary. The cflags for ARM are constructed by > >manipulating KBUILD_CFLAGS. Besides it may or may not want unwind > >tables. 32-bit ARM appears to have an option to enable -funwind-tables. Ah, right the `subst` from `KBUILD_CFLAGS`. Are there other architectures that care about EFI beyond x86 and ARM? IA64? > > clang (as of today) has not implemented the > -funwind-tables/-fasynchronous-unwind-tables distinction as GCC does.. > (probably because not many people care..) Ah, thanks for the clarification. > > >> > >> $ llvm-readelf -S drivers/firmware/efi/libstub/lib.a | grep eh_frame > >> > >> after doing an x86_64 defconfig, I don't get any hits. Do you observe > >> .eh_frame sections on any of these objects in this dir? (I'm fine > >> adding it to be safe, but I'm curious why I'm not seeing any > >> .eh_frame) > >> > > > >You mean before this patch, right? I see hits on every .o file in there > >(compiling with gcc 9.2.0). > > > >> > > >> > # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly > >> > # disable the stackleak plugin > >> > -- > >> > 2.24.1 > >> > -- Thanks, ~Nick Desaulniers