[lld] r267163 - This reverts commit r267154 and r267161.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 09:40:00 PDT 2016
Author: rafael
Date: Fri Apr 22 11:39:59 2016
New Revision: 267163
URL: http://llvm.org/viewvc/llvm-project?rev=267163&view=rev
Log:
This reverts commit r267154 and r267161.
It turns out that this will read data from the section to properly
handle Elf_Rel implicit addends.
Sorry for the noise.
Original messages:
Try to fix Windows lld build.
Move getRelocTarget to ObjectFile.
It doesn't use anything from the InputSection.
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/MarkLive.cpp
lld/trunk/ELF/OutputSections.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Apr 22 11:39:59 2016
@@ -251,24 +251,6 @@ elf::ObjectFile<ELFT>::getRelocTarget(co
return Target;
}
-// Returns a section that Rel relocation is pointing to.
-template <class ELFT>
-InputSectionBase<ELFT> *
-elf::ObjectFile<ELFT>::getRelocTarget(const Elf_Rel &Rel) const {
- uint32_t SymIndex = Rel.getSymbol(Config->Mips64EL);
- SymbolBody &B = getSymbolBody(SymIndex).repl();
- if (auto *D = dyn_cast<DefinedRegular<ELFT>>(&B))
- if (D->Section)
- return D->Section->Repl;
- return nullptr;
-}
-
-template <class ELFT>
-InputSectionBase<ELFT> *
-elf::ObjectFile<ELFT>::getRelocTarget(const Elf_Rela &Rel) const {
- return getRelocTarget(reinterpret_cast<const Elf_Rel &>(Rel));
-}
-
template <class ELFT>
InputSectionBase<ELFT> *
elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Fri Apr 22 11:39:59 2016
@@ -104,8 +104,6 @@ template <class ELFT> class ObjectFile :
typedef typename ELFT::SymRange Elf_Sym_Range;
typedef typename ELFT::Word Elf_Word;
typedef typename ELFT::uint uintX_t;
- typedef typename ELFT::Rel Elf_Rel;
- typedef typename ELFT::Rela Elf_Rela;
StringRef getShtGroupSignature(const Elf_Shdr &Sec);
ArrayRef<Elf_Word> getShtGroupEntries(const Elf_Shdr &Sec);
@@ -140,10 +138,6 @@ public:
// st_name of the symbol.
std::vector<std::pair<const DefinedRegular<ELFT> *, unsigned>> KeptLocalSyms;
- // Returns a section that Rel is pointing to. Used by the garbage collector.
- InputSectionBase<ELFT> *getRelocTarget(const Elf_Rel &Rel) const;
- InputSectionBase<ELFT> *getRelocTarget(const Elf_Rela &Rel) const;
-
private:
void initializeSections(llvm::DenseSet<StringRef> &ComdatGroups);
void initializeSymbols();
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Apr 22 11:39:59 2016
@@ -77,6 +77,25 @@ InputSectionBase<ELFT>::getOffset(const
return getOffset(Sym.Value);
}
+// Returns a section that Rel relocation is pointing to.
+template <class ELFT>
+InputSectionBase<ELFT> *
+InputSectionBase<ELFT>::getRelocTarget(const Elf_Rel &Rel) const {
+ // Global symbol
+ uint32_t SymIndex = Rel.getSymbol(Config->Mips64EL);
+ SymbolBody &B = File->getSymbolBody(SymIndex).repl();
+ if (auto *D = dyn_cast<DefinedRegular<ELFT>>(&B))
+ if (D->Section)
+ return D->Section->Repl;
+ return nullptr;
+}
+
+template <class ELFT>
+InputSectionBase<ELFT> *
+InputSectionBase<ELFT>::getRelocTarget(const Elf_Rela &Rel) const {
+ return getRelocTarget(reinterpret_cast<const Elf_Rel &>(Rel));
+}
+
template <class ELFT>
InputSection<ELFT>::InputSection(elf::ObjectFile<ELFT> *F,
const Elf_Shdr *Header)
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Fri Apr 22 11:39:59 2016
@@ -76,6 +76,8 @@ struct Relocation {
// This corresponds to a section of an input file.
template <class ELFT> class InputSectionBase {
protected:
+ typedef typename ELFT::Rel Elf_Rel;
+ typedef typename ELFT::Rela Elf_Rela;
typedef typename ELFT::Shdr Elf_Shdr;
typedef typename ELFT::Sym Elf_Sym;
typedef typename ELFT::uint uintX_t;
@@ -121,6 +123,10 @@ public:
ArrayRef<uint8_t> getSectionData() const;
+ // Returns a section that Rel is pointing to. Used by the garbage collector.
+ InputSectionBase<ELFT> *getRelocTarget(const Elf_Rel &Rel) const;
+ InputSectionBase<ELFT> *getRelocTarget(const Elf_Rela &Rel) const;
+
void relocate(uint8_t *Buf, uint8_t *BufEnd);
std::vector<Relocation> Relocations;
};
Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Fri Apr 22 11:39:59 2016
@@ -46,15 +46,14 @@ static void forEachSuccessor(InputSectio
typedef typename ELFT::Rela Elf_Rela;
typedef typename ELFT::Shdr Elf_Shdr;
- lld::elf::ObjectFile<ELFT> *File = Sec->getFile();
- ELFFile<ELFT> &Obj = File->getObj();
+ ELFFile<ELFT> &Obj = Sec->getFile()->getObj();
for (const Elf_Shdr *RelSec : Sec->RelocSections) {
if (RelSec->sh_type == SHT_RELA) {
for (const Elf_Rela &RI : Obj.relas(RelSec))
- Fn(File->getRelocTarget(RI));
+ Fn(Sec->getRelocTarget(RI));
} else {
for (const Elf_Rel &RI : Obj.rels(RelSec))
- Fn(File->getRelocTarget(RI));
+ Fn(Sec->getRelocTarget(RI));
}
}
}
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=267163&r1=267162&r2=267163&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Apr 22 11:39:59 2016
@@ -1132,7 +1132,7 @@ void EHOutputSection<ELFT>::addSectionAu
} else {
if (!HasReloc)
fatal("FDE doesn't reference another section");
- InputSectionBase<ELFT> *Target = S->getFile()->getRelocTarget(*RelI);
+ InputSectionBase<ELFT> *Target = S->getRelocTarget(*RelI);
if (Target && Target->Live) {
uint32_t CieOffset = Offset + 4 - ID;
auto I = OffsetToIndex.find(CieOffset);
More information about the llvm-commits
mailing list