[PATCH] D98679: [ELF] Change --shuffle-sections=<seed> to --shuffle-sections=<section-glob>=<seed>
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 17 01:40:08 PDT 2021
jhenderson added a comment.
Pre-merge bots indicate there's another test using --shuffle-sections which needs updating.
================
Comment at: lld/ELF/Driver.cpp:1154
+ if (kv.first.empty() || kv.second.empty()) {
+ error(errPrefix + "expected <section_glob>=<seed>");
+ continue;
----------------
It would probably be helpful if this error message included what was actually the option, in case they have multiple --shuffle-sections, to allow them to find the right one. Example:
```
error: --shuffle-sections=: expected <section_glob>=<seed>, but was "abcdef"
```
================
Comment at: lld/ELF/Writer.cpp:1301-1303
+ for (InputSectionBase *sec : sections)
+ if (patAndSeed.first.match(sec->name))
+ matched.push_back(sec);
----------------
Was wondering if there was a way to do this loop in a way using the existing built-in algorithms, but the best I've got is the following:
```std::copy_if(sections.begin(), sections.end(), std::back_inserter(matched),
[&](InputSectionBase *sec) { return patAndSeed.first.match(sec->name); });```
which doesn't really seem any clearer to me.
================
Comment at: lld/test/ELF/shuffle-sections.s:48
+# RUN: not ld.lld --shuffle-sections=a= 2>&1 | FileCheck %s --check-prefix=USAGE
+# RUN: not ld.lld --shuffle-sections==0 2>&1 | FileCheck %s --check-prefix=USAGE
+
----------------
Perhaps also `--shuffle-sections=a`, (i.e. where the '=' is missing for the option value, but the string is non-empty).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98679/new/
https://reviews.llvm.org/D98679
More information about the llvm-commits
mailing list