From 3ea19301f75285a615be258919812635493602cb Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Thu, 10 Dec 2020 11:58:38 -0800 Subject: [PATCH] FROMLIST: kbuild: lto: add a default list of used symbols With CONFIG_LTO_CLANG, LLVM bitcode has not yet been compiled into a binary when the .mod files are generated, which means they don't yet contain references to certain symbols that will be present in the final binaries. This includes intrinsic functions, such as memcpy, memmove, and memset [1], and stack protector symbols [2]. This change adds a default symbol list to use with CONFIG_TRIM_UNUSED_KSYMS when Clang's LTO is used. [1] https://llvm.org/docs/LangRef.html#standard-c-c-library-intrinsics [2] https://llvm.org/docs/LangRef.html#llvm-stackprotector-intrinsic Bug: 145210207 Change-Id: I9da92fba820c72633209e292fdc6f1c44abe7b9a Link: https://lore.kernel.org/lkml/20201211184633.3213045-7-samitolvanen@google.com/ Signed-off-by: Sami Tolvanen --- init/Kconfig | 1 + scripts/lto-used-symbols.txt | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 scripts/lto-used-symbols.txt diff --git a/init/Kconfig b/init/Kconfig index 188dde6ed879..fdf4957aadb0 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2308,6 +2308,7 @@ config TRIM_UNUSED_KSYMS config UNUSED_KSYMS_WHITELIST string "Whitelist of symbols to keep in ksymtab" depends on TRIM_UNUSED_KSYMS + default "scripts/lto-used-symbols.txt" if LTO_CLANG help By default, all unused exported symbols will be un-exported from the build when TRIM_UNUSED_KSYMS is selected. diff --git a/scripts/lto-used-symbols.txt b/scripts/lto-used-symbols.txt new file mode 100644 index 000000000000..38e7bb9ebaae --- /dev/null +++ b/scripts/lto-used-symbols.txt @@ -0,0 +1,5 @@ +memcpy +memmove +memset +__stack_chk_fail +__stack_chk_guard