All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jessica Yu <jeyu@kernel.org>, Nicolas Pitre <nico@fluxnic.net>,
	Sami Tolvanen <samitolvanen@google.com>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 2/4] export.h: make __ksymtab_strings per-symbol section
Date: Fri, 26 Feb 2021 01:02:44 +0900	[thread overview]
Message-ID: <20210225160247.2959903-3-masahiroy@kernel.org> (raw)
In-Reply-To: <20210225160247.2959903-1-masahiroy@kernel.org>

The export symbol tables are placed on own sections (__ksymtab*+<sym>)
and sorted by SORT (an alias of SORT_BY_NAME) because the module
subsystem uses the binary search for symbol resolution.

We did not have a good reason to do so for __ksymtab_strings, but
now I have.

To make CONFIG_TRIM_UNUSED_KSYMS work in one-pass, the linker needs
to trim unused strings of symbols and namespaces. To allow per-symbol
keep/drop choice, __ksymtab_strings must be placed on own sections.
Of course, SORT is unneeded here, though.

This keeps the string unification introduced by commit ce2b617ce8cb
("export.h: reduce __ksymtab_strings string duplication by using "MS"
section flags").

For example, the empty namespaces share the same address.

  $ nm -n
  [ snip ]
  ffffffff8233b53a r __kstrtabns_IO_APIC_get_PCI_irq_vector
  ffffffff8233b53a r __kstrtabns_I_BDEV
  ffffffff8233b53a r __kstrtabns_LZ4_decompress_fast
  ffffffff8233b53a r __kstrtabns_LZ4_decompress_fast_continue
  ffffffff8233b53a r __kstrtabns_LZ4_decompress_fast_usingDict
  ffffffff8233b53a r __kstrtabns_LZ4_decompress_safe
  ffffffff8233b53a r __kstrtabns_LZ4_decompress_safe_continue
    ...

I confirmed no size change in vmlinux.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 include/asm-generic/export.h      | 2 +-
 include/asm-generic/vmlinux.lds.h | 2 +-
 include/linux/export.h            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
index 07a36a874dca..e847f1fde367 100644
--- a/include/asm-generic/export.h
+++ b/include/asm-generic/export.h
@@ -39,7 +39,7 @@
 __ksymtab_\name:
 	__put \val, __kstrtab_\name
 	.previous
-	.section __ksymtab_strings,"aMS",%progbits,1
+	.section __ksymtab_strings+\name,"aMS",%progbits,1
 __kstrtab_\name:
 	.asciz "\name"
 	.previous
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c54adce8f6f6..5a2b31890bb8 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -513,7 +513,7 @@
 									\
 	/* Kernel symbol table: strings */				\
         __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {	\
-		*(__ksymtab_strings)					\
+		*(__ksymtab_strings+*)					\
 	}								\
 									\
 	/* __*init sections */						\
diff --git a/include/linux/export.h b/include/linux/export.h
index 6271a5d9c988..01e6ab19b226 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -99,7 +99,7 @@ struct kernel_symbol {
 	extern const char __kstrtab_##sym[];					\
 	extern const char __kstrtabns_##sym[];					\
 	__CRC_SYMBOL(sym, sec);							\
-	asm("	.section \"__ksymtab_strings\",\"aMS\",%progbits,1	\n"	\
+	asm("	.section \"__ksymtab_strings+" #sym "\",\"aMS\",%progbits,1\n"	\
 	    "__kstrtab_" #sym ":					\n"	\
 	    "	.asciz 	\"" #sym "\"					\n"	\
 	    "__kstrtabns_" #sym ":					\n"	\
-- 
2.27.0


  parent reply	other threads:[~2021-02-25 16:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 16:02 [PATCH 0/4] kbuild: build speed improvment of CONFIG_TRIM_UNUSED_KSYMS Masahiro Yamada
2021-02-25 16:02 ` [PATCH 1/4] kbuild: fix UNUSED_KSYMS_WHITELIST for Clang LTO Masahiro Yamada
2021-02-25 17:45   ` Sami Tolvanen
2021-02-25 19:08     ` Masahiro Yamada
2021-02-25 16:02 ` Masahiro Yamada [this message]
2021-02-25 16:02 ` [PATCH 3/4] kbuild: separate out vmlinux.lds generation Masahiro Yamada
2021-02-25 16:02 ` [PATCH 4/4] kbuild: re-implement CONFIG_TRIM_UNUSED_KSYMS to make it work in one-pass Masahiro Yamada
2021-02-25 18:46   ` kernel test robot
2021-02-25 18:46     ` kernel test robot
2021-02-25 20:06     ` Masahiro Yamada
2021-02-25 20:06       ` Masahiro Yamada
2021-02-25 21:20       ` Sami Tolvanen
2021-02-25 21:20         ` Sami Tolvanen
2021-02-26  7:04         ` Masahiro Yamada
2021-02-26  7:04           ` Masahiro Yamada
2021-02-25 18:56   ` kernel test robot
2021-02-25 18:56     ` kernel test robot
2021-02-25 17:19 ` [PATCH 0/4] kbuild: build speed improvment of CONFIG_TRIM_UNUSED_KSYMS Nicolas Pitre
2021-02-25 18:57   ` Masahiro Yamada
2021-02-25 19:24     ` Nicolas Pitre
2021-03-09  7:28       ` Masahiro Yamada
2021-03-09 16:49         ` Nicolas Pitre

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=20210225160247.2959903-3-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=hch@lst.de \
    --cc=jeyu@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=samitolvanen@google.com \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.