From: Jarmo Tiitto <jarmo.tiitto@gmail.com>
To: Kees Cook <keescook@chromium.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
clang-built-linux@googlegroups.com, Jessica Yu <jeyu@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Emil Velikov <emil.l.velikov@gmail.com>,
Miroslav Benes <mbenes@suse.cz>,
Jarmo Tiitto <jarmo.tiitto@gmail.com>,
Sean Christopherson <seanjc@google.com>,
linux-kernel@vger.kernel.org
Cc: Bill Wendling <wcw@google.com>, Joe Perches <joe@perches.com>
Subject: [RFC PATCH 2/2] pgo: Make module.lds.S linker script to merge __llvm_prf_ sections.
Date: Tue, 23 Nov 2021 03:21:37 +0200 [thread overview]
Message-ID: <20211123012138.160532-3-jarmo.tiitto@gmail.com> (raw)
In-Reply-To: <20211123012138.160532-1-jarmo.tiitto@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2021-11-23 1:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211123012138.160532-1-jarmo.tiitto@gmail.com>
2021-11-23 1:21 ` [RFC PATCH 1/2] pgo: Update .profraw file format to version 7 Jarmo Tiitto
2021-11-23 1:21 ` Jarmo Tiitto [this message]
[not found] <20211122233306.155968-1-jarmo.tiitto@gmail.com>
2021-11-22 23:33 ` [RFC PATCH 2/2] pgo: Make module.lds.S linker script to merge __llvm_prf_ sections Jarmo Tiitto
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=20211123012138.160532-3-jarmo.tiitto@gmail.com \
--to=jarmo.tiitto@gmail.com \
--cc=clang-built-linux@googlegroups.com \
--cc=emil.l.velikov@gmail.com \
--cc=jeyu@kernel.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=samitolvanen@google.com \
--cc=seanjc@google.com \
--cc=wcw@google.com \
/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
all inboxes | Powered by JetHome®