From baa3eb0dd9ac788d3decf33bb17bd552b59af19d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 22 Dec 2021 20:51:11 -0800 Subject: [PATCH] [ELF] Change some non-null pointer parameters to references. NFC --- lld/ELF/Arch/PPC.cpp | 2 +- lld/ELF/LinkerScript.cpp | 22 ++++----- lld/ELF/LinkerScript.h | 2 +- lld/ELF/Relocations.cpp | 44 ++++++++--------- lld/ELF/SyntheticSections.cpp | 48 +++++++++--------- lld/ELF/SyntheticSections.h | 4 +- lld/ELF/Thunks.cpp | 2 +- lld/ELF/Writer.cpp | 92 +++++++++++++++++------------------ 8 files changed, 108 insertions(+), 108 deletions(-) diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp index 3a7d3f477e02..e28b62329494 100644 --- a/lld/ELF/Arch/PPC.cpp +++ b/lld/ELF/Arch/PPC.cpp @@ -77,7 +77,7 @@ void elf::writePPC32GlinkSection(uint8_t *buf, size_t numEntries) { // non-GOT-non-PLT relocations referencing external functions for -fpie/-fPIE. uint32_t glink = in.plt->getVA(); // VA of .glink if (!config->isPic) { - for (const Symbol *sym : cast(in.plt)->canonical_plts) { + for (const Symbol *sym : cast(*in.plt).canonical_plts) { writePPC32PltCallStub(buf, sym->getGotPltVA(), nullptr, 0); buf += 16; glink += 16; diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 38b1b9093cd5..999bb94d6416 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -560,22 +560,22 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd, return ret; } -void LinkerScript::discard(InputSectionBase *s) { - if (s == in.shStrTab || s == mainPart->relrDyn) - error("discarding " + s->name + " section is not allowed"); +void LinkerScript::discard(InputSectionBase &s) { + if (&s == in.shStrTab || &s == mainPart->relrDyn) + error("discarding " + s.name + " section is not allowed"); // You can discard .hash and .gnu.hash sections by linker scripts. Since // they are synthesized sections, we need to handle them differently than // other regular sections. - if (s == mainPart->gnuHashTab) + if (&s == mainPart->gnuHashTab) mainPart->gnuHashTab = nullptr; - if (s == mainPart->hashTab) + if (&s == mainPart->hashTab) mainPart->hashTab = nullptr; - s->markDead(); - s->parent = nullptr; - for (InputSection *ds : s->dependentSections) - discard(ds); + s.markDead(); + s.parent = nullptr; + for (InputSection *sec : s.dependentSections) + discard(*sec); } void LinkerScript::discardSynthetic(OutputSection &outCmd) { @@ -589,7 +589,7 @@ void LinkerScript::discardSynthetic(OutputSection &outCmd) { std::vector matches = computeInputSections(isd, secs); for (InputSectionBase *s : matches) - discard(s); + discard(*s); } } } @@ -618,7 +618,7 @@ void LinkerScript::processSectionCommands() { // Any input section assigned to it is discarded. if (osec->name == "/DISCARD/") { for (InputSectionBase *s : v) - discard(s); + discard(*s); discardSynthetic(*osec); osec->commands.clear(); return false; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 5e9a3542c426..f385c8320978 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -312,7 +312,7 @@ public: bool hasPhdrsCommands() { return !phdrsCommands.empty(); } uint64_t getDot() { return dot; } - void discard(InputSectionBase *s); + void discard(InputSectionBase &s); ExprValue getSymbolValue(StringRef name, const Twine &loc); diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 79ba3194d73b..466c80d91dd6 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -833,10 +833,10 @@ private: }; } // namespace -static void addRelativeReloc(InputSectionBase *isec, uint64_t offsetInSec, +static void addRelativeReloc(InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, int64_t addend, RelExpr expr, RelType type) { - Partition &part = isec->getPartition(); + Partition &part = isec.getPartition(); // Add a relative relocation. If relrDyn section is enabled, and the // relocation offset is guaranteed to be even, add the relocation to @@ -844,9 +844,9 @@ static void addRelativeReloc(InputSectionBase *isec, uint64_t offsetInSec, // relrDyn sections don't support odd offsets. Also, relrDyn sections // don't store the addend values, so we must write it to the relocated // address. - if (part.relrDyn && isec->alignment >= 2 && offsetInSec % 2 == 0) { - isec->relocations.push_back({expr, type, offsetInSec, addend, &sym}); - part.relrDyn->relocs.push_back({isec, offsetInSec}); + if (part.relrDyn && isec.alignment >= 2 && offsetInSec % 2 == 0) { + isec.relocations.push_back({expr, type, offsetInSec, addend, &sym}); + part.relrDyn->relocs.push_back({&isec, offsetInSec}); return; } part.relaDyn->addRelativeReloc(target->relativeRel, isec, offsetInSec, sym, @@ -854,14 +854,14 @@ static void addRelativeReloc(InputSectionBase *isec, uint64_t offsetInSec, } template -static void addPltEntry(PltSection *plt, GotPltSection *gotPlt, - RelocationBaseSection *rel, RelType type, Symbol &sym) { - plt->addEntry(sym); - gotPlt->addEntry(sym); - rel->addReloc({type, gotPlt, sym.getGotPltOffset(), - sym.isPreemptible ? DynamicReloc::AgainstSymbol - : DynamicReloc::AddendOnlyWithTargetVA, - sym, 0, R_ABS}); +static void addPltEntry(PltSection &plt, GotPltSection &gotPlt, + RelocationBaseSection &rel, RelType type, Symbol &sym) { + plt.addEntry(sym); + gotPlt.addEntry(sym); + rel.addReloc({type, &gotPlt, sym.getGotPltOffset(), + sym.isPreemptible ? DynamicReloc::AgainstSymbol + : DynamicReloc::AddendOnlyWithTargetVA, + sym, 0, R_ABS}); } static void addGotEntry(Symbol &sym) { @@ -880,7 +880,7 @@ static void addGotEntry(Symbol &sym) { if (!config->isPic || isAbsolute(sym)) in.got->relocations.push_back({R_ABS, target->symbolicRel, off, 0, &sym}); else - addRelativeReloc(in.got, off, sym, 0, R_ABS, target->symbolicRel); + addRelativeReloc(*in.got, off, sym, 0, R_ABS, target->symbolicRel); } static void addTpOffsetGotEntry(Symbol &sym) { @@ -891,7 +891,7 @@ static void addTpOffsetGotEntry(Symbol &sym) { return; } mainPart->relaDyn->addAddendOnlyRelocIfNonPreemptible( - target->tlsGotRel, in.got, off, sym, target->symbolicRel); + target->tlsGotRel, *in.got, off, sym, target->symbolicRel); } // Return true if we can define a symbol in the executable that @@ -1019,7 +1019,7 @@ static void processRelocAux(InputSectionBase &sec, RelExpr expr, RelType type, if (canWrite) { RelType rel = target->getDynRel(type); if (expr == R_GOT || (rel == target->symbolicRel && !sym.isPreemptible)) { - addRelativeReloc(&sec, offset, sym, addend, expr, type); + addRelativeReloc(sec, offset, sym, addend, expr, type); return; } else if (rel != 0) { if (config->emachine == EM_MIPS && rel == target->symbolicRel) @@ -1161,7 +1161,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c, if (in.got->addDynTlsEntry(sym)) { uint64_t off = in.got->getGlobalDynOffset(sym); mainPart->relaDyn->addAddendOnlyRelocIfNonPreemptible( - target->tlsDescRel, in.got, off, sym, target->tlsDescRel); + target->tlsDescRel, *in.got, off, sym, target->tlsDescRel); } if (expr != R_TLSDESC_CALL) c.relocations.push_back({expr, type, offset, addend, &sym}); @@ -1292,7 +1292,7 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c, addTpOffsetGotEntry(sym); // R_GOT needs a relative relocation for PIC on i386 and Hexagon. if (expr == R_GOT && config->isPic && !target->usesOnlyLowPageBits(type)) - addRelativeReloc(&c, offset, sym, addend, expr, type); + addRelativeReloc(c, offset, sym, addend, expr, type); else c.relocations.push_back({expr, type, offset, addend, &sym}); } @@ -1585,7 +1585,7 @@ static bool handleNonPreemptibleIfunc(Symbol &sym) { // may alter section/value, so create a copy of the symbol to make // section/value fixed. auto *directSym = makeDefined(cast(sym)); - addPltEntry(in.iplt, in.igotPlt, in.relaIplt, target->iRelativeRel, + addPltEntry(*in.iplt, *in.igotPlt, *in.relaIplt, target->iRelativeRel, *directSym); sym.pltIndex = directSym->pltIndex; @@ -1615,7 +1615,7 @@ void elf::postScanRelocations() { if (sym.needsGot) addGotEntry(sym); if (sym.needsPlt) - addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); + addPltEntry(*in.plt, *in.gotPlt, *in.relaPlt, target->pltRel, sym); if (sym.needsCopy) { if (sym.isObject()) { addCopyRelSymbol(cast(sym)); @@ -1633,7 +1633,7 @@ void elf::postScanRelocations() { // PPC32 canonical PLT entries are at the beginning of .glink cast(sym).value = in.plt->headerSize; in.plt->headerSize += 16; - cast(in.plt)->canonical_plts.push_back(&sym); + cast(*in.plt).canonical_plts.push_back(&sym); } } } @@ -2159,7 +2159,7 @@ void elf::hexagonTLSSymbolUpdate(ArrayRef outputSections) { for (Relocation &rel : isec->relocations) if (rel.sym->type == llvm::ELF::STT_TLS && rel.expr == R_PLT_PC) { if (needEntry) { - addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, + addPltEntry(*in.plt, *in.gotPlt, *in.relaPlt, target->pltRel, *sym); needEntry = false; } diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index e25401baabcb..9691bac76e44 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1297,8 +1297,8 @@ DynamicSection::computeContents() { auto addInt = [&](int32_t tag, uint64_t val) { entries.emplace_back(tag, val); }; - auto addInSec = [&](int32_t tag, const InputSection *sec) { - entries.emplace_back(tag, sec->getVA()); + auto addInSec = [&](int32_t tag, const InputSection &sec) { + entries.emplace_back(tag, sec.getVA()); }; for (StringRef s : config->filterList) @@ -1374,7 +1374,7 @@ DynamicSection::computeContents() { if (part.relaDyn->isNeeded() || (in.relaIplt->isNeeded() && part.relaDyn->getParent() == in.relaIplt->getParent())) { - addInSec(part.relaDyn->dynamicTag, part.relaDyn); + addInSec(part.relaDyn->dynamicTag, *part.relaDyn); entries.emplace_back(part.relaDyn->sizeDynamicTag, addRelaSz(part.relaDyn)); bool isRela = config->isRela; @@ -1392,7 +1392,7 @@ DynamicSection::computeContents() { } if (part.relrDyn && !part.relrDyn->relocs.empty()) { addInSec(config->useAndroidRelrTags ? DT_ANDROID_RELR : DT_RELR, - part.relrDyn); + *part.relrDyn); addInt(config->useAndroidRelrTags ? DT_ANDROID_RELRSZ : DT_RELRSZ, part.relrDyn->getParent()->size); addInt(config->useAndroidRelrTags ? DT_ANDROID_RELRENT : DT_RELRENT, @@ -1405,14 +1405,14 @@ DynamicSection::computeContents() { // case, so here we always use relaPlt as marker for the beginning of // .rel[a].plt section. if (isMain && (in.relaPlt->isNeeded() || in.relaIplt->isNeeded())) { - addInSec(DT_JMPREL, in.relaPlt); + addInSec(DT_JMPREL, *in.relaPlt); entries.emplace_back(DT_PLTRELSZ, addPltRelSz()); switch (config->emachine) { case EM_MIPS: - addInSec(DT_MIPS_PLTGOT, in.gotPlt); + addInSec(DT_MIPS_PLTGOT, *in.gotPlt); break; case EM_SPARCV9: - addInSec(DT_PLTGOT, in.plt); + addInSec(DT_PLTGOT, *in.plt); break; case EM_AARCH64: if (llvm::find_if(in.relaPlt->relocs, [](const DynamicReloc &r) { @@ -1422,7 +1422,7 @@ DynamicSection::computeContents() { addInt(DT_AARCH64_VARIANT_PCS, 0); LLVM_FALLTHROUGH; default: - addInSec(DT_PLTGOT, in.gotPlt); + addInSec(DT_PLTGOT, *in.gotPlt); break; } addInt(DT_PLTREL, config->isRela ? DT_RELA : DT_REL); @@ -1435,16 +1435,16 @@ DynamicSection::computeContents() { addInt(DT_AARCH64_PAC_PLT, 0); } - addInSec(DT_SYMTAB, part.dynSymTab); + addInSec(DT_SYMTAB, *part.dynSymTab); addInt(DT_SYMENT, sizeof(Elf_Sym)); - addInSec(DT_STRTAB, part.dynStrTab); + addInSec(DT_STRTAB, *part.dynStrTab); addInt(DT_STRSZ, part.dynStrTab->getSize()); if (!config->zText) addInt(DT_TEXTREL, 0); if (part.gnuHashTab) - addInSec(DT_GNU_HASH, part.gnuHashTab); + addInSec(DT_GNU_HASH, *part.gnuHashTab); if (part.hashTab) - addInSec(DT_HASH, part.hashTab); + addInSec(DT_HASH, *part.hashTab); if (isMain) { if (Out::preinitArray) { @@ -1469,13 +1469,13 @@ DynamicSection::computeContents() { } if (part.verSym && part.verSym->isNeeded()) - addInSec(DT_VERSYM, part.verSym); + addInSec(DT_VERSYM, *part.verSym); if (part.verDef && part.verDef->isLive()) { - addInSec(DT_VERDEF, part.verDef); + addInSec(DT_VERDEF, *part.verDef); addInt(DT_VERDEFNUM, getVerDefNum()); } if (part.verNeed && part.verNeed->isNeeded()) { - addInSec(DT_VERNEED, part.verNeed); + addInSec(DT_VERNEED, *part.verNeed); unsigned needNum = 0; for (SharedFile *f : sharedFiles) if (!f->vernauxs.empty()) @@ -1494,10 +1494,10 @@ DynamicSection::computeContents() { addInt(DT_MIPS_GOTSYM, b->dynsymIndex); else addInt(DT_MIPS_GOTSYM, part.dynSymTab->getNumSymbols()); - addInSec(DT_PLTGOT, in.mipsGot); + addInSec(DT_PLTGOT, *in.mipsGot); if (in.mipsRldMap) { if (!config->pie) - addInSec(DT_MIPS_RLD_MAP, in.mipsRldMap); + addInSec(DT_MIPS_RLD_MAP, *in.mipsRldMap); // Store the offset to the .rld_map section // relative to the address of the tag. addInt(DT_MIPS_RLD_MAP_REL, @@ -1508,7 +1508,7 @@ DynamicSection::computeContents() { // DT_PPC_GOT indicates to glibc Secure PLT is used. If DT_PPC_GOT is absent, // glibc assumes the old-style BSS PLT layout which we don't support. if (config->emachine == EM_PPC) - addInSec(DT_PPC_GOT, in.got); + addInSec(DT_PPC_GOT, *in.got); // Glink dynamic tag is required by the V2 abi if the plt section isn't empty. if (config->emachine == EM_PPC64 && in.plt->isNeeded()) { @@ -1582,7 +1582,7 @@ void RelocationBaseSection::addSymbolReloc(RelType dynType, } void RelocationBaseSection::addRelativeReloc( - RelType dynType, InputSectionBase *inputSec, uint64_t offsetInSec, + RelType dynType, InputSectionBase &inputSec, uint64_t offsetInSec, Symbol &sym, int64_t addend, RelType addendRelType, RelExpr expr) { // This function should only be called for non-preemptible symbols or // RelExpr values that refer to an address inside the output file (e.g. the @@ -1590,19 +1590,19 @@ void RelocationBaseSection::addRelativeReloc( assert((!sym.isPreemptible || expr == R_GOT) && "cannot add relative relocation against preemptible symbol"); assert(expr != R_ADDEND && "expected non-addend relocation expression"); - addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, inputSec, offsetInSec, - sym, addend, expr, addendRelType); + addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, &inputSec, + offsetInSec, sym, addend, expr, addendRelType); } void RelocationBaseSection::addAddendOnlyRelocIfNonPreemptible( - RelType dynType, InputSectionBase *isec, uint64_t offsetInSec, Symbol &sym, + RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, RelType addendRelType) { // No need to write an addend to the section for preemptible symbols. if (sym.isPreemptible) - addReloc({dynType, isec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0, + addReloc({dynType, &isec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0, R_ABS}); else - addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, isec, offsetInSec, + addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, &isec, offsetInSec, sym, 0, R_ABS, addendRelType); } diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 04a3b9b394af..8953601da390 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -524,13 +524,13 @@ public: llvm::Optional addendRelType = llvm::None); /// Add a relative dynamic relocation that uses the target address of \p sym /// (i.e. InputSection::getRelocTargetVA()) + \p addend as the addend. - void addRelativeReloc(RelType dynType, InputSectionBase *isec, + void addRelativeReloc(RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, int64_t addend, RelType addendRelType, RelExpr expr); /// Add a dynamic relocation using the target address of \p sym as the addend /// if \p sym is non-preemptible. Otherwise add a relocation against \p sym. void addAddendOnlyRelocIfNonPreemptible(RelType dynType, - InputSectionBase *isec, + InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym, RelType addendRelType); void addReloc(DynamicReloc::Kind kind, RelType dynType, diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp index ffbc8d94a800..85a0a67d613c 100644 --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -384,7 +384,7 @@ public: if (Optional index = in.ppc64LongBranchTarget->addEntry(&dest, addend)) { mainPart->relaDyn->addRelativeReloc( - target->relativeRel, in.ppc64LongBranchTarget, *index * UINT64_C(8), + target->relativeRel, *in.ppc64LongBranchTarget, *index * UINT64_C(8), dest, addend + getPPC64GlobalEntryToLocalEntryOffset(dest.stOther), target->symbolicRel, R_ABS); } diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9390027487ed..bce524811b84 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -297,7 +297,7 @@ template void elf::createSyntheticSections() { } } - auto add = [](SyntheticSection *sec) { inputSections.push_back(sec); }; + auto add = [](SyntheticSection &sec) { inputSections.push_back(&sec); }; in.shStrTab = make(".shstrtab", false); @@ -311,7 +311,7 @@ template void elf::createSyntheticSections() { } in.bss = make(".bss", 0, 1); - add(in.bss); + add(*in.bss); // If there is a SECTIONS command and a .data.rel.ro section name use name // .data.rel.ro.bss so that we match in the .data.rel.ro output section. @@ -320,42 +320,42 @@ template void elf::createSyntheticSections() { script->hasSectionsCommand && findSection(".data.rel.ro", 0); in.bssRelRo = make(hasDataRelRo ? ".data.rel.ro.bss" : ".bss.rel.ro", 0, 1); - add(in.bssRelRo); + add(*in.bssRelRo); // Add MIPS-specific sections. if (config->emachine == EM_MIPS) { if (!config->shared && config->hasDynSymTab) { in.mipsRldMap = make(); - add(in.mipsRldMap); + add(*in.mipsRldMap); } if (auto *sec = MipsAbiFlagsSection::create()) - add(sec); + add(*sec); if (auto *sec = MipsOptionsSection::create()) - add(sec); + add(*sec); if (auto *sec = MipsReginfoSection::create()) - add(sec); + add(*sec); } StringRef relaDynName = config->isRela ? ".rela.dyn" : ".rel.dyn"; for (Partition &part : partitions) { - auto add = [&](SyntheticSection *sec) { - sec->partition = part.getNumber(); - inputSections.push_back(sec); + auto add = [&](SyntheticSection &sec) { + sec.partition = part.getNumber(); + inputSections.push_back(&sec); }; if (!part.name.empty()) { part.elfHeader = make>(); part.elfHeader->name = part.name; - add(part.elfHeader); + add(*part.elfHeader); part.programHeaders = make>(); - add(part.programHeaders); + add(*part.programHeaders); } if (config->buildId != BuildIdKind::None) { part.buildId = make(); - add(part.buildId); + add(*part.buildId); } part.dynStrTab = make(".dynstr", true); @@ -368,53 +368,53 @@ template void elf::createSyntheticSections() { make>(relaDynName, config->zCombreloc); if (config->hasDynSymTab) { - add(part.dynSymTab); + add(*part.dynSymTab); part.verSym = make(); - add(part.verSym); + add(*part.verSym); if (!namedVersionDefs().empty()) { part.verDef = make(); - add(part.verDef); + add(*part.verDef); } part.verNeed = make>(); - add(part.verNeed); + add(*part.verNeed); if (config->gnuHash) { part.gnuHashTab = make(); - add(part.gnuHashTab); + add(*part.gnuHashTab); } if (config->sysvHash) { part.hashTab = make(); - add(part.hashTab); + add(*part.hashTab); } - add(part.dynamic); - add(part.dynStrTab); - add(part.relaDyn); + add(*part.dynamic); + add(*part.dynStrTab); + add(*part.relaDyn); } if (config->relrPackDynRelocs) { part.relrDyn = make>(); - add(part.relrDyn); + add(*part.relrDyn); } if (!config->relocatable) { if (config->ehFrameHdr) { part.ehFrameHdr = make(); - add(part.ehFrameHdr); + add(*part.ehFrameHdr); } part.ehFrame = make(); - add(part.ehFrame); + add(*part.ehFrame); } if (config->emachine == EM_ARM && !config->relocatable) { // The ARMExidxsyntheticsection replaces all the individual .ARM.exidx // InputSections. part.armExidx = make(); - add(part.armExidx); + add(*part.armExidx); } } @@ -424,39 +424,39 @@ template void elf::createSyntheticSections() { // special handling (see createPhdrs() and combineEhSections()). in.partEnd = make(".part.end", config->maxPageSize, 1); in.partEnd->partition = 255; - add(in.partEnd); + add(*in.partEnd); in.partIndex = make(); addOptionalRegular("__part_index_begin", in.partIndex, 0); addOptionalRegular("__part_index_end", in.partIndex, in.partIndex->getSize()); - add(in.partIndex); + add(*in.partIndex); } // Add .got. MIPS' .got is so different from the other archs, // it has its own class. if (config->emachine == EM_MIPS) { in.mipsGot = make(); - add(in.mipsGot); + add(*in.mipsGot); } else { in.got = make(); - add(in.got); + add(*in.got); } if (config->emachine == EM_PPC) { in.ppc32Got2 = make(); - add(in.ppc32Got2); + add(*in.ppc32Got2); } if (config->emachine == EM_PPC64) { in.ppc64LongBranchTarget = make(); - add(in.ppc64LongBranchTarget); + add(*in.ppc64LongBranchTarget); } in.gotPlt = make(); - add(in.gotPlt); + add(*in.gotPlt); in.igotPlt = make(); - add(in.igotPlt); + add(*in.igotPlt); // _GLOBAL_OFFSET_TABLE_ is defined relative to either .got.plt or .got. Treat // it as a relocation and ensure the referenced section is created. @@ -468,13 +468,13 @@ template void elf::createSyntheticSections() { } if (config->gdbIndex) - add(GdbIndexSection::create()); + add(*GdbIndexSection::create()); // We always need to add rel[a].plt to output if it has entries. // Even for static linking it can contain R_[*]_IRELATIVE relocations. in.relaPlt = make>( config->isRela ? ".rela.plt" : ".rel.plt", /*sort=*/false); - add(in.relaPlt); + add(*in.relaPlt); // The relaIplt immediately follows .rel[a].dyn to ensure that the IRelative // relocations are processed last by the dynamic loader. We cannot place the @@ -485,22 +485,22 @@ template void elf::createSyntheticSections() { in.relaIplt = make>( config->androidPackDynRelocs ? in.relaPlt->name : relaDynName, /*sort=*/false); - add(in.relaIplt); + add(*in.relaIplt); if ((config->emachine == EM_386 || config->emachine == EM_X86_64) && (config->andFeatures & GNU_PROPERTY_X86_FEATURE_1_IBT)) { in.ibtPlt = make(); - add(in.ibtPlt); + add(*in.ibtPlt); } in.plt = config->emachine == EM_PPC ? make() : make(); - add(in.plt); + add(*in.plt); in.iplt = make(); - add(in.iplt); + add(*in.iplt); if (config->andFeatures) - add(make()); + add(*make()); // .note.GNU-stack is always added when we are creating a re-linkable // object file. Other linkers are using the presence of this marker @@ -508,15 +508,15 @@ template void elf::createSyntheticSections() { // is irrelevant these days. Stack area should always be non-executable // by default. So we emit this section unconditionally. if (config->relocatable) - add(make()); + add(*make()); if (in.symTab) - add(in.symTab); + add(*in.symTab); if (in.symTabShndx) - add(in.symTabShndx); - add(in.shStrTab); + add(*in.symTabShndx); + add(*in.shStrTab); if (in.strTab) - add(in.strTab); + add(*in.strTab); } // The main function of the writer.