[lld] [LLD][COFF] Add support for custom section layout (PR #152779)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 12:28:51 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- lld/COFF/Config.h lld/COFF/Driver.cpp lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/COFF/Writer.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index ed71844ae..f777dcb4a 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1424,23 +1424,23 @@ void Writer::layoutSections() {
for (size_t i = 0; i < ctx.outputSections.size(); ++i)
originalOrder[ctx.outputSections[i]] = i;
- std::stable_sort(ctx.outputSections.begin(), ctx.outputSections.end(),
- [this, &originalOrder](const OutputSection *a,
- const OutputSection *b) {
- auto itA = ctx.config.sectionLayout.find(a->name.str());
- auto itB = ctx.config.sectionLayout.find(b->name.str());
-
- if (itA != ctx.config.sectionLayout.end() &&
- itB != ctx.config.sectionLayout.end())
- return itA->second < itB->second;
-
- if (itA == ctx.config.sectionLayout.end() &&
- itB == ctx.config.sectionLayout.end())
- return originalOrder[a] < originalOrder[b];
-
- // Not found in layout file; respect the original order
- return originalOrder[a] < originalOrder[b];
- });
+ std::stable_sort(
+ ctx.outputSections.begin(), ctx.outputSections.end(),
+ [this, &originalOrder](const OutputSection *a, const OutputSection *b) {
+ auto itA = ctx.config.sectionLayout.find(a->name.str());
+ auto itB = ctx.config.sectionLayout.find(b->name.str());
+
+ if (itA != ctx.config.sectionLayout.end() &&
+ itB != ctx.config.sectionLayout.end())
+ return itA->second < itB->second;
+
+ if (itA == ctx.config.sectionLayout.end() &&
+ itB == ctx.config.sectionLayout.end())
+ return originalOrder[a] < originalOrder[b];
+
+ // Not found in layout file; respect the original order
+ return originalOrder[a] < originalOrder[b];
+ });
}
// The Windows loader doesn't seem to like empty sections,
``````````
</details>
https://github.com/llvm/llvm-project/pull/152779
More information about the llvm-commits
mailing list