From patchwork Fri Sep 16 10:50:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 670790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sbBrz6ysMz9sR9 for ; Fri, 16 Sep 2016 20:50:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B79228C6BF; Fri, 16 Sep 2016 10:50:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T56pqb9stRPk; Fri, 16 Sep 2016 10:50:37 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A69E28C67F; Fri, 16 Sep 2016 10:50:37 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 205431C0975 for ; Fri, 16 Sep 2016 10:50:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 181838C67F for ; Fri, 16 Sep 2016 10:50:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HlmvTtDK-QYQ for ; Fri, 16 Sep 2016 10:50:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.47.9]) by whitealder.osuosl.org (Postfix) with ESMTPS id 86C838C678 for ; Fri, 16 Sep 2016 10:50:33 +0000 (UTC) Received: from us02secmta1.synopsys.com (us02secmta1.synopsys.com [10.12.235.96]) by smtprelay.synopsys.com (Postfix) with ESMTP id 8CE1524E16C3; Fri, 16 Sep 2016 03:50:32 -0700 (PDT) Received: from us02secmta1.internal.synopsys.com (us02secmta1.internal.synopsys.com [127.0.0.1]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 801814E219; Fri, 16 Sep 2016 03:50:32 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 3B6824E218; Fri, 16 Sep 2016 03:50:32 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 24869584; Fri, 16 Sep 2016 03:50:32 -0700 (PDT) Received: from abrodkin-7440l.internal.synopsys.com (unknown [10.121.14.110]) by mailhost.synopsys.com (Postfix) with ESMTP id 5D65856D; Fri, 16 Sep 2016 03:50:30 -0700 (PDT) From: Alexey Brodkin To: buildroot@busybox.net Date: Fri, 16 Sep 2016 13:50:24 +0300 Message-Id: <1474023024-9105-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 2.7.4 Cc: Thomas Petazzoni , Alexey Brodkin , Vineet Gupta , Daniel Mentz Subject: [Buildroot] [PATCH] linux: Allow kernel strip modules itself X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" We used to do a special handling of Linux kernel modules when stripping target binaries because there's some special precious data in modules that we must keep for them to properly operate. This is for example true for stack unwinding data etc. It turned out there're cases when our existing "strip --strip-unneeded" doesn't work well. For example this removes .debug_frame section used by Linux on ARC for stack unwinding, refer to [1] and [2] for more details. Now Linux kernel may strip modules as a part of "modules_install" target if INSTALL_MOD_STRIP=1 is passed in command line. And so we'll do allowing kernel decide how to strip modules in the best way. Still note as of today Linux kernel strips modules uniformly for all arches with "strip" command, so this commit alone doesn't solve mentioned problem but it opens a possibility to add later a patch to the kernel which will strip modules for ARC differently - and that's our plan for mainline kernel. [1] https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/86 [2] http://lists.busybox.net/pipermail/buildroot/2016-September/172161.html Signed-off-by: Alexey Brodkin Cc: Vineet Gupta Cc: Peter Korsgaard Cc: Thomas Petazzoni Cc: Daniel Mentz --- Makefile | 3 --- linux/linux.mk | 6 +++++- package/Makefile.in | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index dfef021..0a44fa7 100644 --- a/Makefile +++ b/Makefile @@ -631,9 +631,6 @@ endif rm -rf $(TARGET_DIR)/usr/share/gtk-doc -rmdir $(TARGET_DIR)/usr/share 2>/dev/null $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true - if test -d $(TARGET_DIR)/lib/modules; then \ - find $(TARGET_DIR)/lib/modules -type f -name '*.ko' -print0 | \ - xargs -0 -r $(KSTRIPCMD); fi # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads # besides the one in which crash occurred; or SIGTRAP kills my program when diff --git a/linux/linux.mk b/linux/linux.mk index 6e41a92..82c6d38 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -384,12 +384,16 @@ define LINUX_INSTALL_IMAGES_CMDS $(call LINUX_INSTALL_DTB,$(BINARIES_DIR)) endef +ifeq ($(BR2_STRIP_strip),y) +LINUX_MOD_STRIP_FLAGS := INSTALL_MOD_STRIP=1 +endif + define LINUX_INSTALL_TARGET_CMDS $(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET) # Install modules and remove symbolic links pointing to build # directories, not relevant on the target @if grep -q "CONFIG_MODULES=y" $(@D)/.config; then \ - $(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install; \ + $(LINUX_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) modules_install $(LINUX_MOD_STRIP_FLAGS); \ rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/build ; \ rm -f $(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED)/source ; \ fi diff --git a/package/Makefile.in b/package/Makefile.in index afd5d3a..1eb5ef7 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -207,12 +207,10 @@ STRIP_STRIP_UNNEEDED := --strip-unneeded STRIP_STRIP_ALL := --strip-all TARGET_STRIP = $(TARGET_CROSS)strip STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note -KSTRIPCMD = $(STRIPCMD) $(STRIP_STRIP_UNNEEDED) endif ifeq ($(BR2_STRIP_none),y) TARGET_STRIP = true STRIPCMD = $(TARGET_STRIP) -KSTRIPCMD = $(TARGET_STRIP) endif INSTALL := $(shell which install || type -p install) FLEX := $(shell which flex || type -p flex)