[PATCH] D22960: [ELF] LinkerScript: Implement custom output section factory

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 10:12:27 PDT 2016


evgeny777 added a comment.

Honestly, I don't know how to radically simplify this. Using two separate classes involves code duplication:

- Output section creation (see OutputSectionFactoryBase::create)
- Handling .opd, .init_array and .fini_array (See Writer::finalizeSections)
- OwningSections vector (minor issue, but still ...)

So, I also think it makes sense to proceed with https://reviews.llvm.org/D22683 without this change.


================
Comment at: ELF/Writer.cpp:663
@@ -663,1 +662,3 @@
   std::vector<OutputSectionBase<ELFT> *> RegularSections = OutputSections;
+  OutputSectionFactoryBase<ELFT> *Fac =
+      ScriptConfig->HasContents ? Script<ELFT>::X->getFactory() : &Factory;
----------------
grimar wrote:
> May be would be better just initialize Writer::Factory differently depending on whether script is used or not ?
Not sure. You'll have to maintain two different indexes with the same class.


https://reviews.llvm.org/D22960





More information about the llvm-commits mailing list