<div dir="ltr">This patch looks really weird. Basically in the atom model a reference is a relocation, and an atom is a symbol + data. However, looks like this patch made a reference to have an item that it is pointing to. If so, that doesn't sound correct.<div><br></div><div>Send this kind of nontrivial changes to pre-commit review first, please.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 22, 2015 at 3:46 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: shankare<br>
Date: Sun Feb 22 17:46:21 2015<br>
New Revision: 230191<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230191&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230191&view=rev</a><br>
Log:<br>
[ELF] Add symbol to ELFReference.<br>
<br>
Relocation handling need more information about the Symbol that we are creating<br>
references for.<br>
<br>
No change in functionality.<br>
<br>
Modified:<br>
lld/trunk/lib/ReaderWriter/ELF/Atoms.h<br>
lld/trunk/lib/ReaderWriter/ELF/ELFFile.h<br>
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=230191&r1=230190&r2=230191&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=230191&r1=230190&r2=230191&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Sun Feb 22 17:46:21 2015<br>
@@ -35,23 +35,27 @@ template <typename ELFT> class ELFFile;<br>
template <class ELFT> class ELFReference : public Reference {<br>
typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;<br>
typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;<br>
+ typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;<br>
+<br>
public:<br>
- ELFReference(const Elf_Rela *rela, uint64_t off, Reference::KindArch arch,<br>
- Reference::KindValue relocType, uint32_t idx)<br>
- : Reference(Reference::KindNamespace::ELF, arch, relocType),<br>
+ ELFReference(const Elf_Sym *sym, const Elf_Rela *rela, uint64_t off,<br>
+ Reference::KindArch arch, Reference::KindValue relocType,<br>
+ uint32_t idx)<br>
+ : Reference(Reference::KindNamespace::ELF, arch, relocType), _sym(sym),<br>
_target(nullptr), _targetSymbolIndex(idx), _offsetInAtom(off),<br>
_addend(rela->r_addend) {}<br>
<br>
- ELFReference(uint64_t off, Reference::KindArch arch,<br>
+ ELFReference(const Elf_Sym *sym, uint64_t off, Reference::KindArch arch,<br>
Reference::KindValue relocType, uint32_t idx)<br>
- : Reference(Reference::KindNamespace::ELF, arch, relocType),<br>
+ : Reference(Reference::KindNamespace::ELF, arch, relocType), _sym(sym),<br>
_target(nullptr), _targetSymbolIndex(idx), _offsetInAtom(off),<br>
_addend(0) {}<br>
<br>
ELFReference(uint32_t edgeKind)<br>
: Reference(Reference::KindNamespace::all, Reference::KindArch::all,<br>
edgeKind),<br>
- _target(nullptr), _targetSymbolIndex(0), _offsetInAtom(0), _addend(0) {}<br>
+ _sym(nullptr), _target(nullptr), _targetSymbolIndex(0),<br>
+ _offsetInAtom(0), _addend(0) {}<br>
<br>
uint64_t offsetInAtom() const override { return _offsetInAtom; }<br>
<br>
@@ -70,7 +74,10 @@ public:<br>
<br>
void setTarget(const Atom *newAtom) override { _target = newAtom; }<br>
<br>
+ const Elf_Sym *symbol() const { return _sym; }<br>
+<br>
private:<br>
+ const Elf_Sym *_sym;<br>
const Atom *_target;<br>
uint64_t _targetSymbolIndex;<br>
uint64_t _offsetInAtom;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=230191&r1=230190&r2=230191&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=230191&r1=230190&r2=230191&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Sun Feb 22 17:46:21 2015<br>
@@ -181,12 +181,12 @@ protected:<br>
std::error_code doParse() override;<br>
<br>
/// \brief Iterate over Elf_Rela relocations list and create references.<br>
- virtual void createRelocationReferences(const Elf_Sym &symbol,<br>
+ virtual void createRelocationReferences(const Elf_Sym *symbol,<br>
ArrayRef<uint8_t> content,<br>
range<Elf_Rela_Iter> rels);<br>
<br>
/// \brief Iterate over Elf_Rel relocations list and create references.<br>
- virtual void createRelocationReferences(const Elf_Sym &symbol,<br>
+ virtual void createRelocationReferences(const Elf_Sym *symbol,<br>
ArrayRef<uint8_t> symContent,<br>
ArrayRef<uint8_t> secContent,<br>
range<Elf_Rel_Iter> rels);<br>
@@ -796,12 +796,12 @@ ELFDefinedAtom<ELFT> *ELFFile<ELFT>::cre<br>
// Add Rela (those with r_addend) references:<br>
auto rari = _relocationAddendReferences.find(sectionName);<br>
if (rari != _relocationAddendReferences.end())<br>
- createRelocationReferences(*symbol, symContent, rari->second);<br>
+ createRelocationReferences(symbol, symContent, rari->second);<br>
<br>
// Add Rel references.<br>
auto rri = _relocationReferences.find(sectionName);<br>
if (rri != _relocationReferences.end())<br>
- createRelocationReferences(*symbol, symContent, secContent, rri->second);<br>
+ createRelocationReferences(symbol, symContent, secContent, rri->second);<br>
<br>
// Create the DefinedAtom and add it to the list of DefinedAtoms.<br>
return *handleDefinedSymbol(symbolName, sectionName, symbol, section,<br>
@@ -810,35 +810,35 @@ ELFDefinedAtom<ELFT> *ELFFile<ELFT>::cre<br>
}<br>
<br>
template <class ELFT><br>
-void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym &symbol,<br>
+void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,<br>
ArrayRef<uint8_t> content,<br>
range<Elf_Rela_Iter> rels) {<br>
bool isMips64EL = _objFile->isMips64EL();<br>
- const auto symValue = getSymbolValue(&symbol);<br>
+ const auto symValue = getSymbolValue(symbol);<br>
for (const auto &rel : rels) {<br>
if (rel.r_offset < symValue ||<br>
symValue + content.size() <= rel.r_offset)<br>
continue;<br>
_references.push_back(new (_readerStorage) ELFReference<ELFT>(<br>
- &rel, rel.r_offset - symValue, kindArch(),<br>
+ symbol, &rel, rel.r_offset - symValue, kindArch(),<br>
rel.getType(isMips64EL), rel.getSymbol(isMips64EL)));<br>
}<br>
}<br>
<br>
template <class ELFT><br>
-void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym &symbol,<br>
+void ELFFile<ELFT>::createRelocationReferences(const Elf_Sym *symbol,<br>
ArrayRef<uint8_t> symContent,<br>
ArrayRef<uint8_t> secContent,<br>
range<Elf_Rel_Iter> rels) {<br>
bool isMips64EL = _objFile->isMips64EL();<br>
- const auto symValue = getSymbolValue(&symbol);<br>
+ const auto symValue = getSymbolValue(symbol);<br>
for (const auto &rel : rels) {<br>
if (rel.r_offset < symValue ||<br>
symValue + symContent.size() <= rel.r_offset)<br>
continue;<br>
_references.push_back(new (_readerStorage) ELFReference<ELFT>(<br>
- rel.r_offset - symValue, kindArch(),<br>
- rel.getType(isMips64EL), rel.getSymbol(isMips64EL)));<br>
+ symbol, rel.r_offset - symValue, kindArch(), rel.getType(isMips64EL),<br>
+ rel.getSymbol(isMips64EL)));<br>
int32_t addend = *(symContent.data() + rel.r_offset - symValue);<br>
_references.back()->setAddend(addend);<br>
}<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=230191&r1=230190&r2=230191&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=230191&r1=230190&r2=230191&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Sun Feb 22 17:46:21 2015<br>
@@ -199,17 +199,17 @@ private:<br>
return std::error_code();<br>
}<br>
<br>
- void createRelocationReferences(const Elf_Sym &symbol,<br>
+ void createRelocationReferences(const Elf_Sym *symbol,<br>
ArrayRef<uint8_t> symContent,<br>
ArrayRef<uint8_t> secContent,<br>
range<Elf_Rel_Iter> rels) override {<br>
for (Elf_Rel_Iter rit = rels.begin(), eit = rels.end(); rit != eit; ++rit) {<br>
- if (rit->r_offset < symbol.st_value ||<br>
- symbol.st_value + symContent.size() <= rit->r_offset)<br>
+ if (rit->r_offset < symbol->st_value ||<br>
+ symbol->st_value + symContent.size() <= rit->r_offset)<br>
continue;<br>
<br>
this->_references.push_back(new (this->_readerStorage) ELFReference<ELFT>(<br>
- rit->r_offset - symbol.st_value, this->kindArch(),<br>
+ symbol, rit->r_offset - symbol->st_value, this->kindArch(),<br>
rit->getType(isMips64EL()), rit->getSymbol(isMips64EL())));<br>
<br>
auto addend = getAddend(*rit, secContent);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>