[PATCH] D29327: [LLD][ELF] Use Synthetic Sections for Thunks (try 2)

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 11:58:02 PST 2017


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: ELF/Relocations.cpp:822-824
+    // MSVC debug implementation checks std library preconditions so we can't
+    // assume A will be Thunk, also both Thunks and InputSections must be
+    // ordered by MergeCmp prior to merge.
----------------
What MSVC does is not wrong, so mentioning about MSVC as a special case would probably confuse readers. The thing is that the function needs to be a strict weak ordering (some standard libraries actually check for that in debug mode.)


================
Comment at: ELF/Relocations.cpp:827-834
+    if (A->OutSecOff == B->OutSecOff) {
+      // Check if Thunk is immediately before any specific Target InputSection
+      // for example Mips LA25 Thunks.
+      auto *TA = dyn_cast<ThunkSection<ELFT>>(A);
+      auto *TB = dyn_cast<ThunkSection<ELFT>>(B);
+      if (TA && !TB && TA->getTargetInputSection() == B)
+        return true;
----------------
Can't `getTargetInputSection` point only to a non-thunk input section, can it? I wonder if you can write something like this.

  if (if (A->OutSecOff == B->OutSecOff)
    if (auto *TA = dyn_cast<ThunkSection<ELFT>>(A))
      if (TA->getTargetInputSection() == B)
        return true;


https://reviews.llvm.org/D29327





More information about the llvm-commits mailing list