[PATCH] [ELF] Remove unused parameter from ELFReference c'tor.

Rui Ueyama ruiu at google.com
Tue Jun 11 21:40:19 PDT 2013


Hi shankarke,

Remove unused parameter from ELFReference c'tor. Also added
a comment to describe why we don't need that parameter for the
constructor.

http://llvm-reviews.chandlerc.com/D961

Files:
  lib/ReaderWriter/ELF/Atoms.h
  lib/ReaderWriter/ELF/File.h

Index: lib/ReaderWriter/ELF/Atoms.h
===================================================================
--- lib/ReaderWriter/ELF/Atoms.h
+++ lib/ReaderWriter/ELF/Atoms.h
@@ -28,22 +28,27 @@
 
 /// \brief Relocation References: Defined Atoms may contain references that will
 /// need to be patched before the executable is written.
+///
+/// Construction of ELFReferences is two pass process. ELFReferences are
+/// instantiated while we are iterating over symbol tables to atomize
+/// symbols. At that time we only know the index of relocation target symbol
+/// (not target atom) about a relocation, so we store the index to
+/// ELFREference. In the second pass, ELFReferences are revisited to update
+/// target atoms by target symbol indexes.
 template <class ELFT> class ELFReference LLVM_FINAL : public Reference {
   typedef llvm::object::Elf_Rel_Impl<ELFT, false> Elf_Rel;
   typedef llvm::object::Elf_Rel_Impl<ELFT, true> Elf_Rela;
 public:
 
-  ELFReference(const Elf_Rela *rela, uint64_t offset, const Atom *target,
-               Kind kind, uint32_t symbol)
-      : _target(target), _targetSymbolIndex(symbol),
-        _offsetInAtom(offset), _addend(rela->r_addend) {
+  ELFReference(const Elf_Rela *rela, uint64_t off, Kind kind, uint32_t idx)
+      : _target(nullptr), _targetSymbolIndex(idx),
+        _offsetInAtom(off), _addend(rela->r_addend) {
     _kind = kind;
   }
 
-  ELFReference(const Elf_Rel *rel, uint64_t offset, const Atom *target,
-               Kind kind, uint32_t symbol)
-      : _target(target), _targetSymbolIndex(symbol),
-        _offsetInAtom(offset), _addend(0) {
+  ELFReference(const Elf_Rel *rel, uint64_t off, Kind kind, uint32_t idx)
+      : _target(nullptr), _targetSymbolIndex(idx),
+        _offsetInAtom(off), _addend(0) {
     _kind = kind;
   }
 
Index: lib/ReaderWriter/ELF/File.h
===================================================================
--- lib/ReaderWriter/ELF/File.h
+++ lib/ReaderWriter/ELF/File.h
@@ -513,7 +513,7 @@
         Reference::Kind kind = (Reference::Kind) rai.getType(isMips64EL);
         uint32_t symbolIndex = rai.getSymbol(isMips64EL);
         auto *ERef = new (_readerStorage)
-            ELFReference<ELFT>(&rai, rai.r_offset - symbol->st_value, nullptr,
+            ELFReference<ELFT>(&rai, rai.r_offset - symbol->st_value,
                                kind, symbolIndex);
         _references.push_back(ERef);
       }
@@ -530,7 +530,7 @@
         Reference::Kind kind = (Reference::Kind) ri.getType(isMips64EL);
         uint32_t symbolIndex = ri.getSymbol(isMips64EL);
         auto *ERef = new (_readerStorage)
-            ELFReference<ELFT>(&ri, ri.r_offset - symbol->st_value, nullptr,
+            ELFReference<ELFT>(&ri, ri.r_offset - symbol->st_value,
                                kind, symbolIndex);
         // Read the addend from the section contents
         // TODO : We should move the way lld reads relocations totally from
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D961.1.patch
Type: text/x-patch
Size: 2945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130611/270e0f59/attachment.bin>


More information about the llvm-commits mailing list