[PATCH] D74791: Add a --shuffle-sections option to lld

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 03:10:01 PST 2020


grimar added a comment.

+1 to idea about adding a seed.
Also this needs a test case. At least you can check that the option is accepted and perhaps seed
should allow to show that a layout produced is somehow different with/without this option for example.



================
Comment at: lld/ELF/Writer.cpp:1208
 
 // Builds section order for handling --symbol-ordering-file.
 static DenseMap<const InputSectionBase *, int> buildSectionOrder() {
----------------
Probably worth updating this comment as it is misleading.


================
Comment at: lld/ELF/Writer.cpp:1217
+      std::vector<int> priorities(inputSections.size());
+      int cur_prio = -1;
+      for (int &prio : priorities) {
----------------
I do not think we use `_` in variable names in LLD.


================
Comment at: lld/ELF/Writer.cpp:1221
+          --cur_prio;
+      }
+      std::random_device rd;
----------------
Can it be just like the following?
```
for (int &prio : priorities)
  prio = cur_prio--;
```

(It could be just `std::iota(priorities.begin(), priorities.end(), -priorities.size());` btw,
but it is still uncommon for LLD to use algorithms like that I think).


================
Comment at: lld/ELF/Writer.cpp:1227
+          sectionOrder[inputSections[i]] = priorities[i];
+      }
+      return sectionOrder;
----------------
No need to have curly bracers around a single line.


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

https://reviews.llvm.org/D74791





More information about the llvm-commits mailing list