@@ -618,7 +618,6 @@ enum RankFlags {
618
618
RF_NOT_ADDR_SET = 1 << 27 ,
619
619
RF_NOT_ALLOC = 1 << 26 ,
620
620
RF_PARTITION = 1 << 18 , // Partition number (8 bits)
621
- RF_NOT_SPECIAL = 1 << 17 ,
622
621
RF_LARGE_ALT = 1 << 15 ,
623
622
RF_WRITE = 1 << 14 ,
624
623
RF_EXEC_WRITE = 1 << 13 ,
@@ -644,24 +643,6 @@ unsigned elf::getSectionRank(OutputSection &osec) {
644
643
if (!(osec.flags & SHF_ALLOC))
645
644
return rank | RF_NOT_ALLOC;
646
645
647
- if (osec.type == SHT_LLVM_PART_EHDR)
648
- return rank;
649
- if (osec.type == SHT_LLVM_PART_PHDR)
650
- return rank | 1 ;
651
-
652
- // Put .interp first because some loaders want to see that section
653
- // on the first page of the executable file when loaded into memory.
654
- if (osec.name == " .interp" )
655
- return rank | 2 ;
656
-
657
- // Put .note sections at the beginning so that they are likely to be included
658
- // in a truncate core file. In particular, .note.gnu.build-id, if available,
659
- // can identify the object file.
660
- if (osec.type == SHT_NOTE)
661
- return rank | 3 ;
662
-
663
- rank |= RF_NOT_SPECIAL;
664
-
665
646
// Sort sections based on their access permission in the following
666
647
// order: R, RX, RXW, RW(RELRO), RW(non-RELRO).
667
648
//
@@ -677,11 +658,6 @@ unsigned elf::getSectionRank(OutputSection &osec) {
677
658
bool isWrite = osec.flags & SHF_WRITE;
678
659
679
660
if (!isWrite && !isExec) {
680
- // Make PROGBITS sections (e.g .rodata .eh_frame) closer to .text to
681
- // alleviate relocation overflow pressure. Large special sections such as
682
- // .dynstr and .dynsym can be away from .text.
683
- if (osec.type == SHT_PROGBITS)
684
- rank |= RF_RODATA;
685
661
// Among PROGBITS sections, place .lrodata further from .text.
686
662
// For -z lrodata-after-bss, place .lrodata after .lbss like GNU ld. This
687
663
// layout has one extra PT_LOAD, but alleviates relocation overflow
@@ -691,6 +667,25 @@ unsigned elf::getSectionRank(OutputSection &osec) {
691
667
rank |= config->zLrodataAfterBss ? RF_LARGE_ALT : 0 ;
692
668
else
693
669
rank |= config->zLrodataAfterBss ? 0 : RF_LARGE;
670
+
671
+ if (osec.type == SHT_LLVM_PART_EHDR)
672
+ ;
673
+ else if (osec.type == SHT_LLVM_PART_PHDR)
674
+ rank |= 1 ;
675
+ else if (osec.name == " .interp" )
676
+ rank |= 2 ;
677
+ // Put .note sections at the beginning so that they are likely to be
678
+ // included in a truncate core file. In particular, .note.gnu.build-id, if
679
+ // available, can identify the object file.
680
+ else if (osec.type == SHT_NOTE)
681
+ rank |= 3 ;
682
+ // Make PROGBITS sections (e.g .rodata .eh_frame) closer to .text to
683
+ // alleviate relocation overflow pressure. Large special sections such as
684
+ // .dynstr and .dynsym can be away from .text.
685
+ else if (osec.type != SHT_PROGBITS)
686
+ rank |= 4 ;
687
+ else
688
+ rank |= RF_RODATA;
694
689
} else if (isExec) {
695
690
rank |= isWrite ? RF_EXEC_WRITE : RF_EXEC;
696
691
} else {
0 commit comments