From 3deb82cd072bd4bb6172ece5e6d01ea6600dc3a8 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 15 Dec 2021 00:18:58 -0800 Subject: [PATCH] [ELF] Adjust getOutputSectionName prefix order Sorting the prefixes by decreasing frequency can improve performance. .gcc_except_table is relatively frequent, so move it ahead. .ctors and .dtors mostly disappear and should be the last. --- lld/ELF/LinkerScript.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 3a7228453f18..e8aad25c9b68 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -101,9 +101,9 @@ static StringRef getOutputSectionName(const InputSectionBase *s) { return v; for (StringRef v : - {".text", ".rodata", ".data.rel.ro", ".data", ".bss.rel.ro", ".bss", - ".init_array", ".fini_array", ".ctors", ".dtors", ".tbss", - ".gcc_except_table", ".tdata", ".ARM.exidx", ".ARM.extab"}) + {".text", ".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)) return v;