aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lld/ELF/SyntheticSections.cpp')
-rw-r--r--contrib/llvm-project/lld/ELF/SyntheticSections.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/contrib/llvm-project/lld/ELF/SyntheticSections.cpp b/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
index 187b2ac90c21..f1594eb8df86 100644
--- a/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
+++ b/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
@@ -431,10 +431,11 @@ template <class ELFT>
void EhFrameSection::addSectionAux(EhInputSection *sec) {
if (!sec->isLive())
return;
- if (sec->areRelocsRela)
- addRecords<ELFT>(sec, sec->template relas<ELFT>());
+ const RelsOrRelas<ELFT> rels = sec->template relsOrRelas<ELFT>();
+ if (rels.areRelocsRel())
+ addRecords<ELFT>(sec, rels.rels);
else
- addRecords<ELFT>(sec, sec->template rels<ELFT>());
+ addRecords<ELFT>(sec, rels.relas);
}
void EhFrameSection::addSection(EhInputSection *sec) {
@@ -483,12 +484,11 @@ void EhFrameSection::iterateFDEWithLSDA(
DenseSet<size_t> ciesWithLSDA;
for (EhInputSection *sec : sections) {
ciesWithLSDA.clear();
- if (sec->areRelocsRela)
- iterateFDEWithLSDAAux<ELFT>(*sec, sec->template relas<ELFT>(),
- ciesWithLSDA, fn);
+ const RelsOrRelas<ELFT> rels = sec->template relsOrRelas<ELFT>();
+ if (rels.areRelocsRel())
+ iterateFDEWithLSDAAux<ELFT>(*sec, rels.rels, ciesWithLSDA, fn);
else
- iterateFDEWithLSDAAux<ELFT>(*sec, sec->template rels<ELFT>(),
- ciesWithLSDA, fn);
+ iterateFDEWithLSDAAux<ELFT>(*sec, rels.relas, ciesWithLSDA, fn);
}
}
@@ -1119,7 +1119,7 @@ void MipsGotSection::writeTo(uint8_t *buf) {
if (p.first == nullptr && !config->shared)
write(p.second, nullptr, 1);
else if (p.first && !p.first->isPreemptible) {
- // If we are emitting a shared libary with relocations we mustn't write
+ // If we are emitting a shared library with relocations we mustn't write
// anything to the GOT here. When using Elf_Rel relocations the value
// one will be treated as an addend and will cause crashes at runtime
if (!config->shared)
@@ -1668,11 +1668,11 @@ void RelocationBaseSection::finalizeContents() {
else
getParent()->link = 0;
- if (in.relaPlt == this) {
+ if (in.relaPlt == this && in.gotPlt->getParent()) {
getParent()->flags |= ELF::SHF_INFO_LINK;
getParent()->info = in.gotPlt->getParent()->sectionIndex;
}
- if (in.relaIplt == this) {
+ if (in.relaIplt == this && in.igotPlt->getParent()) {
getParent()->flags |= ELF::SHF_INFO_LINK;
getParent()->info = in.igotPlt->getParent()->sectionIndex;
}
@@ -2171,7 +2171,7 @@ size_t SymbolTableBaseSection::getSymbolIndex(Symbol *sym) {
return sym->dynsymIndex;
// Initializes symbol lookup tables lazily. This is used only for -r,
- // -emit-relocs and dynsyms in partitions other than the main one.
+ // --emit-relocs and dynsyms in partitions other than the main one.
llvm::call_once(onceFlag, [&] {
symbolIndexMap.reserve(symbols.size());
size_t i = 0;
@@ -2350,8 +2350,7 @@ size_t SymtabShndxSection::getSize() const {
// is to help the dynamic linker resolve symbols quickly. If ELF files
// don't have them, the dynamic linker has to do linear search on all
// dynamic symbols, which makes programs slower. Therefore, a .hash
-// section is added to a DSO by default. A .gnu.hash is added if you
-// give the -hash-style=gnu or -hash-style=both option.
+// section is added to a DSO by default.
//
// The Unix semantics of resolving dynamic symbols is somewhat expensive.
// Each ELF file has a list of DSOs that the ELF file depends on and a
@@ -2374,8 +2373,8 @@ size_t SymtabShndxSection::getSize() const {
// and better version of .hash. .hash is just an on-disk hash table, but
// .gnu.hash has a bloom filter in addition to a hash table to skip
// DSOs very quickly. If you are sure that your dynamic linker knows
-// about .gnu.hash, you want to specify -hash-style=gnu. Otherwise, a
-// safe bet is to specify -hash-style=both for backward compatibility.
+// about .gnu.hash, you want to specify --hash-style=gnu. Otherwise, a
+// safe bet is to specify --hash-style=both for backward compatibility.
GnuHashTableSection::GnuHashTableSection()
: SyntheticSection(SHF_ALLOC, SHT_GNU_HASH, config->wordsize, ".gnu.hash") {
}
@@ -2402,7 +2401,7 @@ void GnuHashTableSection::finalizeContents() {
void GnuHashTableSection::writeTo(uint8_t *buf) {
// The output buffer is not guaranteed to be zero-cleared because we pre-
// fill executable sections with trap instructions. This is a precaution
- // for that case, which happens only when -no-rosegment is given.
+ // for that case, which happens only when --no-rosegment is given.
memset(buf, 0, size);
// Write a header.
@@ -3161,10 +3160,10 @@ size_t VersionTableSection::getSize() const {
void VersionTableSection::writeTo(uint8_t *buf) {
buf += 2;
for (const SymbolTableEntry &s : getPartition().dynSymTab->getSymbols()) {
- // Use the original versionId for an unfetched lazy symbol (undefined weak),
- // which must be VER_NDX_GLOBAL (an undefined versioned symbol is an error).
- write16(buf, s.sym->isLazy() ? static_cast<uint16_t>(VER_NDX_GLOBAL)
- : s.sym->versionId);
+ // For an unfetched lazy symbol (undefined weak), it must have been
+ // converted to Undefined and have VER_NDX_GLOBAL version here.
+ assert(!s.sym->isLazy());
+ write16(buf, s.sym->versionId);
buf += 2;
}
}
@@ -3591,9 +3590,8 @@ void ARMExidxSyntheticSection::writeTo(uint8_t *buf) {
}
bool ARMExidxSyntheticSection::isNeeded() const {
- return llvm::find_if(exidxSections, [](InputSection *isec) {
- return isec->isLive();
- }) != exidxSections.end();
+ return llvm::any_of(exidxSections,
+ [](InputSection *isec) { return isec->isLive(); });
}
bool ARMExidxSyntheticSection::classof(const SectionBase *d) {