[PATCH] D24920: [ELF] Linkerscript: Yet Another Fix For Empty Sections.

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 15:49:04 PDT 2016


rafael added a comment.

I think I am sold on this, but it needs some comments. Also, please don't delete the tests, instead show what is now produced. One of the advantages of this implementation is precisely that PT_LOAD creation is not impacted.


================
Comment at: ELF/LinkerScript.cpp:456
@@ +455,3 @@
+                                    static_cast<uint8_t>(S->Visibility));
+  auto *Regular = cast<DefinedRegular<ELFT>>(Body);
+  Regular->GotIndex = GotIndex;
----------------
Don't you have to adjust the value?

================
Comment at: ELF/LinkerScript.cpp:500
@@ -497,1 +499,3 @@
+template <class ELFT> void LinkerScript<ELFT>::addEmptySections() {
+  auto InsertIt = OutputSections->begin();
   for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
----------------
Add a comment about what is being done. If I understand it correctly, it is:

* In here, create any missing output section as SHF_EXCLUDE.  They are created such that in the end the OutputSectionCommands and the OutputSections are in the same order and have a 1:1 mapping.
* The creation is after the creation of PT_LOADs, so they don't impact them.
* Once addresses have been computed, the sections are deleted.

Also comment about the fact that we know no existing section can have the SHF_EXCLUDE flag.


================
Comment at: ELF/LinkerScript.cpp:507
@@ +506,3 @@
+    bool FoundIt = false;
+    for (auto It = OutputSections->begin(); It != OutputSections->end(); ++It)
+      if ((*It)->getName() == Cmd->Name) {
----------------
std::find_if


Repository:
  rL LLVM

https://reviews.llvm.org/D24920





More information about the llvm-commits mailing list