}
template <class ELFT> void OutputSection<ELFT>::finalize() {
- if (!Config->Relocatable) {
- // SHF_LINK_ORDER only has meaning in relocatable objects
- this->Flags &= ~SHF_LINK_ORDER;
- return;
- }
-
- uint32_t Type = this->Type;
if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
- // When doing a relocatable link we must preserve the link order
- // dependency of sections with the SHF_LINK_ORDER flag. The dependency
- // is indicated by the sh_link field. We need to translate the
- // InputSection sh_link to the OutputSection sh_link, all InputSections
- // in the OutputSection have the same dependency.
+ // We must preserve the link order dependency of sections with the
+ // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
+ // need to translate the InputSection sh_link to the OutputSection sh_link,
+ // all InputSections in the OutputSection have the same dependency.
if (auto *D = this->Sections.front()->getLinkOrderDep())
this->Link = D->OutSec->SectionIndex;
}
- if (Type != SHT_RELA && Type != SHT_REL)
+ uint32_t Type = this->Type;
+ if (!Config->Relocatable || (Type != SHT_RELA && Type != SHT_REL))
return;
+
this->Link = In<ELFT>::SymTab->OutSec->SectionIndex;
// sh_info for SHT_REL[A] sections should contain the section header index of
// the section to which the relocation applies.
// CHECK-PT: Name: .ARM.exidx
// CHECK-PT-NEXT: Type: SHT_ARM_EXIDX (0x70000001)
-// CHECK-PT-NEXT: Flags [ (0x2)
-// CHECK-PT-NEXT: SHF_ALLOC (0x2)
+// CHECK-PT-NEXT: Flags [
+// CHECK-PT-NEXT: SHF_ALLOC
+// CHECK-PT-NEXT: SHF_LINK_ORDER
// CHECK-PT-NEXT: ]
// CHECK-PT-NEXT: Address: 0x100D4
// CHECK-PT-NEXT: Offset: 0xD4
--- /dev/null
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-readobj -s %t.so | FileCheck %s
+
+// CHECK: Name: .ARM.exidx
+// CHECK-NEXT: Type: SHT_ARM_EXIDX
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_LINK_ORDER
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size:
+// CHECK-NEXT: Link: [[INDEX:.*]]
+
+// CHECK: Index: [[INDEX]]
+// CHECK-NEXT: Name: .text
+
+
+ f:
+ .fnstart
+ bx lr
+ .cantunwind
+ .fnend
// the .ARM.exidx output section
// CHECK-PT: Name: .ARM.exidx
// CHECK-PT-NEXT: Type: SHT_ARM_EXIDX (0x70000001)
-// CHECK-PT-NEXT: Flags [ (0x2)
-// CHECK-PT-NEXT: SHF_ALLOC (0x2)
+// CHECK-PT-NEXT: Flags [
+// CHECK-PT-NEXT: SHF_ALLOC
+// CHECK-PT-NEXT: SHF_LINK_ORDER
// CHECK-PT-NEXT: ]
// CHECK-PT-NEXT: Address: 0x100D4
// CHECK-PT-NEXT: Offset: 0xD4
// CHECK: Section {
// CHECK: Name: .ARM.exidx
// CHECK-NEXT: Type: SHT_ARM_EXIDX (0x70000001)
-// CHECK-NEXT: Flags [ (0x2)
-// CHECK-NEXT: SHF_ALLOC (0x2)
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_LINK_ORDER
// CHECK-NEXT: ]
// CHECK-NOT: Name: .ARM.exidx.text.f1