linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Daniel Mentz <danielmentz@google.com>,
	<linux-snps-arc@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>,
	Vineet Gupta <Vineet.Gupta1@synopsys.com>
Subject: [PATCH] ARC: module: provide linker script to discard debug sections
Date: Tue, 13 Sep 2016 15:37:17 -0700	[thread overview]
Message-ID: <1473806237-16800-1-git-send-email-vgupta@synopsys.com> (raw)

The module .ko files seem to  bloated due to lot of needless sections,
most of which come due to -gdwarf-2 toggle (needed in turn to get
.debug_frame which kernel stack unwinder usese).

However there's no reason for the other .debug_* sections, so discard
them using arch specific linker script (linker collates module-common.lds
and arch specific lds)

For a very simply module using DEBUG_FS

before
| There are 35 section headers, starting at offset 0x205a0:
| ls -sh q_proc.ko
| 132K q_proc.ko

after
| There are 25 section headers, starting at offset 0x205a0:
| ls -sh q_proc.ko
| 8K q_proc.ko

Reported-by: Daniel Mentz <danielmentz@google.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/Makefile          |  5 +++++
 arch/arc/kernel/module.lds | 12 ++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 arch/arc/kernel/module.lds

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 85814e74677d..fe1b702f5c69 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -97,6 +97,11 @@ LIBGCC	:= $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
 # Modules with short calls might break for calls into builtin-kernel
 KBUILD_CFLAGS_MODULE	+= -mlong-calls -mno-millicode
 
+# toss away debug section, ifdef not allowed in the linker script
+ifndef CONFIG_DEBUG_INFO
+KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arc/kernel/module.lds
+endif
+
 # Finally dump eveything into kernel build system
 KBUILD_CFLAGS	+= $(cflags-y)
 KBUILD_AFLAGS	+= $(KBUILD_CFLAGS)
diff --git a/arch/arc/kernel/module.lds b/arch/arc/kernel/module.lds
new file mode 100644
index 000000000000..c9839be105fc
--- /dev/null
+++ b/arch/arc/kernel/module.lds
@@ -0,0 +1,12 @@
+SECTIONS
+{
+	/DISCARD/ : { *(.debug_aranges) }
+	/DISCARD/ : { *(.debug_pubnames) }
+	/DISCARD/ : { *(.debug_info) }
+	/DISCARD/ : { *(.debug_abbrev) }
+	/DISCARD/ : { *(.debug_line) }
+	/DISCARD/ : { *(.debug_str) }
+	/DISCARD/ : { *(.debug_loc) }
+	/DISCARD/ : { *(.debug_macinfo) }
+	/DISCARD/ : { *(.debug_ranges) }
+}
-- 
2.7.4

                 reply	other threads:[~2016-09-13 22:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473806237-16800-1-git-send-email-vgupta@synopsys.com \
    --to=vineet.gupta1@synopsys.com \
    --cc=danielmentz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).