[PATCH] D91127: [ELF] Use input order instead of pattern order within an input section description

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 09:07:14 PST 2020


MaskRay added inline comments.


================
Comment at: lld/ELF/LinkerScript.cpp:468
+      // Prevent duplicate elements in ret.
+      pos[sec] |= 1;
     }
----------------
grimar wrote:
> Looks a bit hacky approach to me.
This could be another DenseSet, but that would have more overhead. So I reused the map.


================
Comment at: lld/ELF/LinkerScript.cpp:473
+      continue;
+    sortByPosition(sizeLastSort);
     sortInputSections(
----------------
grimar wrote:
> You don't need to call `sortByPosition` here? It is always sorted I believe.
This is the key. We need to sort patterns between two `SORT` by position.

Similarly, we need to sort the trailing patterns outside of the loop (if the last pattern is not `SORT`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91127/new/

https://reviews.llvm.org/D91127



More information about the llvm-commits mailing list