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.
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