[lld] 3534d26 - [ELF] Slightly speed up -z keep-text-section-prefix
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 15 10:20:16 PST 2021
Author: Fangrui Song
Date: 2021-12-15T10:20:11-08:00
New Revision: 3534d26cc1ce666b5f603e6f387aa2ba05e4ecd3
URL: https://github.com/llvm/llvm-project/commit/3534d26cc1ce666b5f603e6f387aa2ba05e4ecd3
DIFF: https://github.com/llvm/llvm-project/commit/3534d26cc1ce666b5f603e6f387aa2ba05e4ecd3.diff
LOG: [ELF] Slightly speed up -z keep-text-section-prefix
Added:
Modified:
lld/ELF/LinkerScript.cpp
Removed:
################################################################################
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index e8aad25c9b688..782a658fdaeda 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -94,14 +94,17 @@ static StringRef getOutputSectionName(const InputSectionBase *s) {
// 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 (config->zKeepTextSectionPrefix && s->name.startswith(".text."))
- for (StringRef v : {".text.hot", ".text.unknown", ".text.unlikely",
- ".text.startup", ".text.exit", ".text.split"})
- if (isSectionPrefix(v, s->name))
- return v;
+ if (isSectionPrefix(".text", s->name)) {
+ if (config->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 (StringRef v :
- {".text", ".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss",
+ {".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss",
".gcc_except_table", ".init_array", ".fini_array", ".tbss", ".tdata",
".ARM.exidx", ".ARM.extab", ".ctors", ".dtors"})
if (isSectionPrefix(v, s->name))
More information about the llvm-commits
mailing list