summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 3af58b2143e..4307b48f034 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -369,6 +369,18 @@ static void addCommonSymbols(std::vector<DefinedCommon<ELFT> *> &Syms) {
Out<ELFT>::Bss->setSize(Off);
}
+static StringRef getOutputName(StringRef S) {
+ if (S.startswith(".text."))
+ return ".text";
+ if (S.startswith(".rodata."))
+ return ".rodata";
+ if (S.startswith(".data."))
+ return ".data";
+ if (S.startswith(".bss."))
+ return ".bss";
+ return S;
+}
+
// Create output section objects and add them to OutputSections.
template <class ELFT> void Writer<ELFT>::createSections() {
// .interp needs to be on the first page in the output file.
@@ -403,7 +415,8 @@ template <class ELFT> void Writer<ELFT>::createSections() {
continue;
const Elf_Shdr *H = C->getSectionHdr();
uintX_t OutFlags = H->sh_flags & ~SHF_GROUP;
- SectionKey<ELFT::Is64Bits> Key{C->getSectionName(), H->sh_type, OutFlags};
+ SectionKey<ELFT::Is64Bits> Key{getOutputName(C->getSectionName()),
+ H->sh_type, OutFlags};
OutputSection<ELFT> *&Sec = Map[Key];
if (!Sec) {
Sec = new (CAlloc.Allocate())
OpenPOWER on IntegriCloud