Skip to content

Commit 6560feb

Browse files
authored
Update Writer.cpp
1 parent a61195c commit 6560feb

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lld/COFF/Writer.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,8 @@ void Writer::createSections() {
10321032

10331033
// Finally, move some output sections to the end.
10341034
auto sectionOrder = [&](const OutputSection *s) {
1035+
if (ctx.config.driver && s->name == "INIT2")
1036+
return 1;
10351037
// Move DISCARDABLE (or non-memory-mapped) sections to the end of file
10361038
// because the loader cannot handle holes. Stripping can remove other
10371039
// discardable ones than .reloc, which is first of them (created early).
@@ -1040,22 +1042,18 @@ void Writer::createSections() {
10401042
// discardable sections. Stripping only removes the sections named
10411043
// .debug_* - thus try to avoid leaving holes after stripping.
10421044
if (s->name.starts_with(".debug_"))
1043-
return 3;
1044-
return 2;
1045+
return 4;
1046+
return 3;
10451047
}
10461048
// .rsrc should come at the end of the non-discardable sections because its
10471049
// size may change by the Win32 UpdateResources() function, causing
10481050
// subsequent sections to move (see https://crbug.com/827082).
10491051
if (s == rsrcSec)
1050-
return 1;
1052+
return 2;
10511053
return 0;
10521054
};
10531055
llvm::stable_sort(ctx.outputSections,
10541056
[&](const OutputSection *s, const OutputSection *t) {
1055-
if (s->name == "INIT2" && t->name == ".reloc")
1056-
return true;
1057-
if (s->name == "INIT2" && t->name == ".rsrc")
1058-
return true;
10591057
return sectionOrder(s) < sectionOrder(t);
10601058
});
10611059
}

0 commit comments

Comments
 (0)