summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-12-19 23:59:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-12-19 23:59:35 +0000
commit1037eef8e08847d9f457b15710652cb38be279dd (patch)
tree360d7f30c445b53043cd2b2725b3254763130075
parent86795d9166bd6fd18cf06aaedc5a487944394e16 (diff)
downloadbcm5719-llvm-1037eef8e08847d9f457b15710652cb38be279dd.tar.gz
bcm5719-llvm-1037eef8e08847d9f457b15710652cb38be279dd.zip
Use references instead of pointers. NFC.
These values are trivially never null. While at it, also use InputSection instead of InputSectionBase when possible. llvm-svn: 321126
-rw-r--r--lld/ELF/AArch64ErrataFix.cpp4
-rw-r--r--lld/ELF/Arch/ARM.cpp10
-rw-r--r--lld/ELF/SyntheticSections.cpp10
-rw-r--r--lld/ELF/SyntheticSections.h2
-rw-r--r--lld/ELF/Target.h4
-rw-r--r--lld/ELF/Thunks.cpp32
6 files changed, 30 insertions, 32 deletions
diff --git a/lld/ELF/AArch64ErrataFix.cpp b/lld/ELF/AArch64ErrataFix.cpp
index 6cc68cc08e1..9c0d536dea7 100644
--- a/lld/ELF/AArch64ErrataFix.cpp
+++ b/lld/ELF/AArch64ErrataFix.cpp
@@ -400,8 +400,8 @@ lld::elf::Patch843419Section::Patch843419Section(InputSection *P, uint64_t Off)
this->Parent = P->getParent();
PatchSym = addSyntheticLocal(
Saver.save("__CortexA53843419_" + utohexstr(getLDSTAddr())), STT_FUNC, 0,
- getSize(), this);
- addSyntheticLocal(Saver.save("$x"), STT_NOTYPE, 0, 0, this);
+ getSize(), *this);
+ addSyntheticLocal(Saver.save("$x"), STT_NOTYPE, 0, 0, *this);
}
uint64_t lld::elf::Patch843419Section::getLDSTAddr() const {
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index f869237ccd8..b9f551e4b3b 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -37,8 +37,8 @@ public:
void writePltHeader(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
- void addPltSymbols(InputSectionBase *IS, uint64_t Off) const override;
- void addPltHeaderSymbols(InputSectionBase *ISD) const override;
+ void addPltSymbols(InputSection &IS, uint64_t Off) const override;
+ void addPltHeaderSymbols(InputSection &ISD) const override;
bool needsThunk(RelExpr Expr, RelType Type, const InputFile *File,
uint64_t BranchAddr, const Symbol &S) const override;
bool inBranchRange(RelType Type, uint64_t Src, uint64_t Dst) const override;
@@ -232,8 +232,7 @@ void ARM::writePltHeader(uint8_t *Buf) const {
write32le(Buf + 28, TrapInstr);
}
-void ARM::addPltHeaderSymbols(InputSectionBase *ISD) const {
- auto *IS = cast<InputSection>(ISD);
+void ARM::addPltHeaderSymbols(InputSection &IS) const {
addSyntheticLocal("$a", STT_NOTYPE, 0, 0, IS);
addSyntheticLocal("$d", STT_NOTYPE, 16, 0, IS);
}
@@ -282,8 +281,7 @@ void ARM::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr,
write32le(Buf + 12, TrapInstr); // Pad to 16-byte boundary
}
-void ARM::addPltSymbols(InputSectionBase *ISD, uint64_t Off) const {
- auto *IS = cast<InputSection>(ISD);
+void ARM::addPltSymbols(InputSection &IS, uint64_t Off) const {
addSyntheticLocal("$a", STT_NOTYPE, Off, 0, IS);
addSyntheticLocal("$d", STT_NOTYPE, Off + 12, 0, IS);
}
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index b408e653dfa..afa87269adc 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -275,9 +275,9 @@ InputSection *elf::createInterpSection() {
}
Symbol *elf::addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
- uint64_t Size, InputSectionBase *Section) {
- auto *S = make<Defined>(Section->File, Name, STB_LOCAL, STV_DEFAULT, Type,
- Value, Size, Section);
+ uint64_t Size, InputSectionBase &Section) {
+ auto *S = make<Defined>(Section.File, Name, STB_LOCAL, STV_DEFAULT, Type,
+ Value, Size, &Section);
if (InX::SymTab)
InX::SymTab->addSymbol(S);
return S;
@@ -1893,10 +1893,10 @@ size_t PltSection::getSize() const {
void PltSection::addSymbols() {
// The PLT may have symbols defined for the Header, the IPLT has no header
if (HeaderSize != 0)
- Target->addPltHeaderSymbols(this);
+ Target->addPltHeaderSymbols(*this);
size_t Off = HeaderSize;
for (size_t I = 0; I < Entries.size(); ++I) {
- Target->addPltSymbols(this, Off);
+ Target->addPltSymbols(*this, Off);
Off += Target->PltEntrySize;
}
}
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 5aaf479f3e3..6118b9d99d7 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -814,7 +814,7 @@ void decompressSections();
void mergeSections();
Symbol *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
- uint64_t Size, InputSectionBase *Section);
+ uint64_t Size, InputSectionBase &Section);
// Linker generated sections which can be used as inputs.
struct InX {
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 2902dbc9914..1f58adba181 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -40,8 +40,8 @@ public:
virtual void writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
uint64_t PltEntryAddr, int32_t Index,
unsigned RelOff) const {}
- virtual void addPltHeaderSymbols(InputSectionBase *IS) const {}
- virtual void addPltSymbols(InputSectionBase *IS, uint64_t Off) const {}
+ virtual void addPltHeaderSymbols(InputSection &IS) const {}
+ virtual void addPltSymbols(InputSection &IS, uint64_t Off) const {}
// Returns true if a relocation only uses the low bits of a value such that
// all those bits are in in the same page. For example, if the relocation
diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp
index 91ca3b9b5bc..b0bbf6da705 100644
--- a/lld/ELF/Thunks.cpp
+++ b/lld/ELF/Thunks.cpp
@@ -164,9 +164,9 @@ void AArch64ABSLongThunk::writeTo(uint8_t *Buf, ThunkSection &IS) const {
void AArch64ABSLongThunk::addSymbols(ThunkSection &IS) {
ThunkSym = addSyntheticLocal(
Saver.save("__AArch64AbsLongThunk_" + Destination.getName()), STT_FUNC,
- Offset, size(), &IS);
- addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, &IS);
- addSyntheticLocal("$d", STT_NOTYPE, Offset + 8, 0, &IS);
+ Offset, size(), IS);
+ addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, IS);
+ addSyntheticLocal("$d", STT_NOTYPE, Offset + 8, 0, IS);
}
// This Thunk has a maximum range of 4Gb, this is sufficient for all programs
@@ -192,8 +192,8 @@ void AArch64ADRPThunk::addSymbols(ThunkSection &IS)
{
ThunkSym = addSyntheticLocal(
Saver.save("__AArch64ADRPThunk_" + Destination.getName()), STT_FUNC,
- Offset, size(), &IS);
- addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, &IS);
+ Offset, size(), IS);
+ addSyntheticLocal("$x", STT_NOTYPE, Offset, 0, IS);
}
// ARM Target Thunks
@@ -217,8 +217,8 @@ void ARMV7ABSLongThunk::writeTo(uint8_t *Buf, ThunkSection &IS) const {
void ARMV7ABSLongThunk::addSymbols(ThunkSection &IS) {
ThunkSym = addSyntheticLocal(
Saver.save("__ARMv7ABSLongThunk_" + Destination.getName()), STT_FUNC,
- Offset, size(), &IS);
- addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, &IS);
+ Offset, size(), IS);
+ addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, IS);
}
bool ARMV7ABSLongThunk::isCompatibleWith(RelType Type) const {
@@ -241,8 +241,8 @@ void ThumbV7ABSLongThunk::writeTo(uint8_t *Buf, ThunkSection &IS) const {
void ThumbV7ABSLongThunk::addSymbols(ThunkSection &IS) {
ThunkSym = addSyntheticLocal(
Saver.save("__Thumbv7ABSLongThunk_" + Destination.getName()), STT_FUNC,
- Offset | 0x1, size(), &IS);
- addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, &IS);
+ Offset | 0x1, size(), IS);
+ addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, IS);
}
bool ThumbV7ABSLongThunk::isCompatibleWith(RelType Type) const {
@@ -268,8 +268,8 @@ void ARMV7PILongThunk::writeTo(uint8_t *Buf, ThunkSection &IS) const {
void ARMV7PILongThunk::addSymbols(ThunkSection &IS) {
ThunkSym = addSyntheticLocal(
Saver.save("__ARMV7PILongThunk_" + Destination.getName()), STT_FUNC,
- Offset, size(), &IS);
- addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, &IS);
+ Offset, size(), IS);
+ addSyntheticLocal("$a", STT_NOTYPE, Offset, 0, IS);
}
bool ARMV7PILongThunk::isCompatibleWith(RelType Type) const {
@@ -295,8 +295,8 @@ void ThumbV7PILongThunk::writeTo(uint8_t *Buf, ThunkSection &IS) const {
void ThumbV7PILongThunk::addSymbols(ThunkSection &IS) {
ThunkSym = addSyntheticLocal(
Saver.save("__ThumbV7PILongThunk_" + Destination.getName()), STT_FUNC,
- Offset | 0x1, size(), &IS);
- addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, &IS);
+ Offset | 0x1, size(), IS);
+ addSyntheticLocal("$t", STT_NOTYPE, Offset, 0, IS);
}
bool ThumbV7PILongThunk::isCompatibleWith(RelType Type) const {
@@ -318,7 +318,7 @@ void MipsThunk::writeTo(uint8_t *Buf, ThunkSection &) const {
void MipsThunk::addSymbols(ThunkSection &IS) {
ThunkSym =
addSyntheticLocal(Saver.save("__LA25Thunk_" + Destination.getName()),
- STT_FUNC, Offset, size(), &IS);
+ STT_FUNC, Offset, size(), IS);
}
InputSection *MipsThunk::getTargetInputSection() const {
@@ -342,7 +342,7 @@ void MicroMipsThunk::writeTo(uint8_t *Buf, ThunkSection &) const {
void MicroMipsThunk::addSymbols(ThunkSection &IS) {
ThunkSym =
addSyntheticLocal(Saver.save("__microLA25Thunk_" + Destination.getName()),
- STT_FUNC, Offset, size(), &IS);
+ STT_FUNC, Offset, size(), IS);
ThunkSym->StOther |= STO_MIPS_MICROMIPS;
}
@@ -367,7 +367,7 @@ void MicroMipsR6Thunk::writeTo(uint8_t *Buf, ThunkSection &) const {
void MicroMipsR6Thunk::addSymbols(ThunkSection &IS) {
ThunkSym =
addSyntheticLocal(Saver.save("__microLA25Thunk_" + Destination.getName()),
- STT_FUNC, Offset, size(), &IS);
+ STT_FUNC, Offset, size(), IS);
ThunkSym->StOther |= STO_MIPS_MICROMIPS;
}
OpenPOWER on IntegriCloud