[PATCH] D29330: Replace MergeOutputSection with synthetic input section MergeSection.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 01:39:26 PST 2017

grimar added inline comments.

Comment at: ELF/Writer.cpp:157
+// This function scans over V and creates mergeable synthetic sections. It
+// removes MergeInputSections from array and adds new synthetic ones to the end.
+template <class ELFT> static void combineMergableSections() {
ruiu wrote:
> Update this comment -- this function does not add sections to the end.
Ah, I did not notice it at first. That is done to not allow .comment section move and do not break tests I guess.

I think that logic is fine, though we have at least one place where write in comment
that synthetics are placed to the end:

static void removeUnusedSyntheticSections(std::vector<OutputSectionBase *> &V) {
  // Input synthetic sections are placed after all regular ones. We iterate over
  // them all and exit at first non-synthetic.
  for (InputSectionBase<ELFT> *S : llvm::reverse(Symtab<ELFT>::X->Sections)) {

That place above does not affect merge synthetic sections, because them are always !empty(),
but probably also needs some comment update.

As an alternative - in the following patch we probably can make .comment section to be synthetic from start
and change this method to what it did initially: place them to the end.


More information about the llvm-commits mailing list