[PATCH] D27041: [ELF] - Disable emiting multiple output sections when merging is disabled.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 10:16:03 PST 2016
ruiu added inline comments.
================
Comment at: ELF/InputSection.cpp:60-62
+ if (Config->Optimize == 0)
+ return Flags & ~(SHF_MERGE | SHF_STRINGS);
+ return Flags;
----------------
grimar wrote:
> ruiu wrote:
> > We shouldn't implement the same logic again here. You want to change this line https://github.com/llvm-mirror/lld/blob/d93aa5ab9ac56831d625a0233a0e17f482822d07/ELF/InputSection.cpp#L208to turn off SHF_MERGE and SHF_STRINGS flags unconditionally.
> That will not work unfortunately.
> Next code is involved here and not that line:
>
> ```
> if (shouldMerge(Sec))
> return make<MergeInputSection<ELFT>>(this, &Sec, Name);
> return make<InputSection<ELFT>>(this, &Sec, Name);
> ```
> calls:
> ```
> template <class ELFT>
> InputSection<ELFT>::InputSection(elf::ObjectFile<ELFT> *F,
> const Elf_Shdr *Header, StringRef Name)
> : InputSectionBase<ELFT>(F, Header, Name, Base::Regular) {}
> ```
>
> So the suggested change will not take any affect on .data
But implementing the same logic here is not right.
================
Comment at: ELF/InputSection.cpp:91
Alignment = V;
}
----------------
How about this. You could add code here to drop the flag.
// If it is not a mergeable section, overwrite the flag so that the flag
// is consistent with the class. This inconsistency could occur when
// string merging is disabled using -O0 flag.
if (!isa<MergeInputSection<ELFT>>(this))
Flags &= ~(SHF_MERGE | SHF_STRINGS);
https://reviews.llvm.org/D27041
More information about the llvm-commits
mailing list