[PATCH] D74887: [ELF] Shuffle .init_array/.fini_array with --shuffle-sections=

Rafael Avila de Espindola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 16:32:44 PST 2020


respindola added inline comments.


================
Comment at: lld/ELF/Writer.cpp:1364
+  // by --symbol-ordering-file or --shuffle-sections=.
+  if (!order.empty())
+    for (BaseCommand *b : sec->sectionCommands)
----------------
MaskRay wrote:
> respindola wrote:
> > This will break code that uses init_priority, no?
> > 
> > I think we can only shuffle sections of equal priority.
> > 
> Priorities are respected. Sections with the same priority can be shuffled.
> 
> See the test below, `.init_array.1` is the first.
> 
> ```
> # CHECK:      Hex dump of section '.init_array'
> # CHECK-NEXT: 0x{{[0-9a-f]+}} ff
> # ORDERED-SAME: 000102 03040506 0708090a 0b
> # SHUFFLED-NOT: 000102 03040506 0708090a 0b
> ```
Oh, I see. I was somehow reading a return after sortISDBySectionOrder, sorry.
What happens is that we first shuffle and then depend on functions like sortInitFini producing a valid order. Sounds reasonable.

What about the script->hasSectionsCommand case? Don't we have to skip sortISDBySectionOrder in when it is true?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74887





More information about the llvm-commits mailing list