[PATCH] D27041: [ELF] - Disable emiting multiple output sections when merging is disabled.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 02:08:59 PST 2016


grimar added inline comments.


================
Comment at: ELF/InputSection.cpp:60-62
+  if (Config->Optimize == 0)
+    return Flags & ~(SHF_MERGE | SHF_STRINGS);
+  return Flags;
----------------
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


https://reviews.llvm.org/D27041





More information about the llvm-commits mailing list