[lld] [lld][ELF] Merge .ltext.* input sections into .ltext output section (PR #190305)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 21:05:29 PDT 2026


================
@@ -96,13 +94,16 @@ StringRef LinkerScript::getOutputSectionName(const InputSectionBase *s) const {
   // cold parts in .text.split instead of .text.unlikely mitigates against poor
   // profile inaccuracy. Techniques such as hugepage remapping can make
   // conservative decisions at the section granularity.
-  if (isSectionPrefix(".text", s->name)) {
-    if (ctx.arg.zKeepTextSectionPrefix)
-      for (StringRef v : {".text.hot", ".text.unknown", ".text.unlikely",
-                          ".text.startup", ".text.exit", ".text.split"})
-        if (isSectionPrefix(v.substr(5), s->name.substr(5)))
-          return v;
-    return ".text";
+  for (auto [prefix, len] :
+       {std::pair<StringRef, size_t>(".text", 5), {".ltext", 6}}) {
----------------
MaskRay wrote:

`len` is unneeded. Derive it from `prefix.size()`

https://github.com/llvm/llvm-project/pull/190305


More information about the llvm-commits mailing list