Skip to content

Commit 3bdc90e

Browse files
committed
[ELF] adjustOutputSections: update sortRank. NFC
... as flags have changed. This allows us to revisit the `osd->osec.hasInputSections` condition in `getRankProximity` (originally introduced as `Sec->Live` in https://reviews.llvm.org/D61197).
1 parent 34b14cc commit 3bdc90e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lld/ELF/LinkerScript.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,9 +1249,11 @@ void LinkerScript::adjustOutputSections() {
12491249

12501250
// We do not want to keep any special flags for output section
12511251
// in case it is empty.
1252-
if (isEmpty)
1252+
if (isEmpty) {
12531253
sec->flags =
12541254
flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) | SHF_WRITE);
1255+
sec->sortRank = getSectionRank(*sec);
1256+
}
12551257

12561258
// The code below may remove empty output sections. We should save the
12571259
// specified program headers (if exist) and propagate them to subsequent

lld/ELF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ enum RankFlags {
630630
RF_BSS = 1 << 7,
631631
};
632632

633-
static unsigned getSectionRank(OutputSection &osec) {
633+
unsigned elf::getSectionRank(OutputSection &osec) {
634634
unsigned rank = osec.partition * RF_PARTITION;
635635

636636
// We want to put section specified by -T option first, so we

lld/ELF/Writer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct PhdrEntry {
4646

4747
void addReservedSymbols();
4848
bool includeInSymtab(const Symbol &b);
49+
unsigned getSectionRank(OutputSection &osec);
4950

5051
template <class ELFT> uint32_t calcMipsEFlags();
5152

0 commit comments

Comments
 (0)