[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211122233306.155968-3-jarmo.tiitto@gmail.com>
Date: Tue, 23 Nov 2021 01:33:05 +0200
From: Jarmo Tiitto <jarmo.tiitto@...il.com>
To: Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
clang-built-linux@...glegroups.com,
Kees Cook <keescook@...omium.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Jessica Yu <jeyu@...nel.org>, Miroslav Benes <mbenes@...e.cz>,
Emil Velikov <emil.l.velikov@...il.com>,
Sean Christopherson <seanjc@...gle.com>,
Jarmo Tiitto <jarmo.tiitto@...il.com>,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 2/2] pgo: Make module.lds.S linker script to merge __llvm_prf_ sections.
The compiler leaves many duplicate instances of __llvm_prf_* sections
in final module objects and they confuse the kernel module loader.
Fix this by providing module.lds.S linker script that merges the split
sections like vmlinux.lds.S currently does.
Signed-off-by: Jarmo Tiitto <jarmo.tiitto@...il.com>
---
I'm not sure the linker script is entirely correct and
it propably needs more work.
---
scripts/module.lds.S | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index 04c5685c25cf..83ca5825c0c3 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -60,6 +60,39 @@ SECTIONS {
*(.text .text.[0-9a-zA-Z_]* .text..L.cfi*)
}
#endif
+#ifdef CONFIG_PGO_CLANG
+ /*
+ * With CONFIG_PGO_CLANG the compiler may split __llvm_prf_xxx
+ * objects into multiple sections. Merge them in final .ko object.
+ * However leave .rela__llvm_prf_data sections as-is
+ * since they are needed by the module loader.
+ */
+ __llvm_prf_data : AT(ADDR(__llvm_prf_data)) {
+ __llvm_prf_data_start = .;
+ KEEP(*(SORT(__llvm_prf_data)))
+ __llvm_prf_data_end = .;
+ }
+ __llvm_prf_cnts : AT(ADDR(__llvm_prf_cnts)) {
+ __llvm_prf_cnts_start = .;
+ KEEP(*(SORT(__llvm_prf_cnts)))
+ __llvm_prf_cnts_end = .;
+ }
+ __llvm_prf_names : AT(ADDR(__llvm_prf_names)) {
+ __llvm_prf_names_start = .;
+ KEEP(*(SORT(__llvm_prf_names)))
+ __llvm_prf_names_end = .;
+ }
+ __llvm_prf_vals : AT(ADDR(__llvm_prf_vals)) {
+ __llvm_prf_vals_start = .;
+ KEEP(*(SORT(__llvm_prf_vals)))
+ __llvm_prf_vals_end = .;
+ }
+ __llvm_prf_vnds : AT(ADDR(__llvm_prf_vnds)) {
+ __llvm_prf_vnds_start = .;
+ KEEP(*(SORT(__llvm_prf_vnds)))
+ __llvm_prf_vnds_end = .;
+ }
+#endif
}
/* bring in arch-specific sections */
--
2.34.0
Powered by blists - more mailing lists