Delete getSectionHdr.
We were fairly inconsistent as to what information should be accessed
with getSectionHdr and what information (like alignment) was stored
elsewhere.
Now all section info has a dedicated getter. The code is also a bit
more compact.
llvm-svn: 285079
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index ba8bb4c..5fd49eb 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -156,7 +156,7 @@
return true;
bool IsRW = llvm::any_of(Sections, [=](InputSectionData *Sec2) {
auto *Sec = static_cast<InputSectionBase<ELFT> *>(Sec2);
- return Sec->getSectionHdr()->sh_flags & SHF_WRITE;
+ return Sec->getFlags() & SHF_WRITE;
});
return (IsRW && Kind == ConstraintKind::ReadWrite) ||
(!IsRW && Kind == ConstraintKind::ReadOnly);
@@ -268,13 +268,12 @@
// Fortunately, creating symbols in the middle of a merge section is not
// supported by bfd or gold, so we can just create multiple section in that
// case.
- const typename ELFT::Shdr *H = C->getSectionHdr();
typedef typename ELFT::uint uintX_t;
- uintX_t Flags = H->sh_flags & (SHF_MERGE | SHF_STRINGS);
+ uintX_t Flags = C->getFlags() & (SHF_MERGE | SHF_STRINGS);
uintX_t Alignment = 0;
if (isa<MergeInputSection<ELFT>>(C))
- Alignment = std::max(H->sh_addralign, H->sh_entsize);
+ Alignment = std::max<uintX_t>(C->Alignment, C->getEntsize());
return SectionKey<ELFT::Is64Bits>{OutsecName, /*Type*/ 0, Flags, Alignment};
}