[PATCH] D40026: [ELF] - Allow applying SHF_MERGE optimization for relocatable output.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 00:01:44 PST 2017


ruiu added inline comments.


================
Comment at: ELF/InputSection.cpp:414
       if (Config->IsRela) {
-        P->r_addend += Sym.getVA() - Section->getOutputSection()->Addr;
+        int64_t Addend = getAddend<ELFT>(Rel);
+        P->r_addend = Sym.getVA(Addend) - Section->getOutputSection()->Addr;
----------------
Do you need this temporary variable?


================
Comment at: ELF/LinkerScript.cpp:470-472
+  // For relocatable case each input mergeable section contains data grouped by
+  // sh_entsize and we want to allow final link to perform the last merging
+  // optimization, so we emit unique output section for each input.
----------------
... already been merged by sh_entsize. If -r was given, we want to create an output section for each mergeable input section because we don't want to mix two sections with different sh_entsize.


================
Comment at: ELF/Writer.cpp:494
+    // which is used for -r.
+    if (isa<SyntheticSection>(IS) && !(IS->Flags & SHF_MERGE))
+      continue;
----------------
I wonder if you really need to handle this as a special case.


https://reviews.llvm.org/D40026





More information about the llvm-commits mailing list