[PATCH] D26662: Avoid creating reference from nullptr.

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 23:42:36 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL286937: Avoid creating reference from nullptr. (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D26662?vs=77951&id=77952#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26662

Files:
  lld/trunk/ELF/Relocations.cpp


Index: lld/trunk/ELF/Relocations.cpp
===================================================================
--- lld/trunk/ELF/Relocations.cpp
+++ lld/trunk/ELF/Relocations.cpp
@@ -615,7 +615,7 @@
     Out<ELFT>::RelaDyn->addReloc(Reloc);
   };
 
-  const elf::ObjectFile<ELFT> &File = *C.getFile();
+  const elf::ObjectFile<ELFT> *File = C.getFile();
   ArrayRef<uint8_t> SectionData = C.Data;
   const uint8_t *Buf = SectionData.begin();
 
@@ -628,7 +628,7 @@
 
   for (auto I = Rels.begin(), E = Rels.end(); I != E; ++I) {
     const RelTy &RI = *I;
-    SymbolBody &Body = File.getRelocTargetSym(RI);
+    SymbolBody &Body = File->getRelocTargetSym(RI);
     uint32_t Type = RI.getType(Config->Mips64EL);
 
     if (Config->MipsN32Abi) {
@@ -645,7 +645,7 @@
 
     RelExpr Expr = Target->getRelExpr(Type, Body);
     bool Preemptible = isPreemptible(Body, Type);
-    Expr = adjustExpr(File, Body, IsWrite, Expr, Type, Buf + RI.r_offset);
+    Expr = adjustExpr(*File, Body, IsWrite, Expr, Type, Buf + RI.r_offset);
     if (HasError)
       continue;
 
@@ -673,7 +673,7 @@
         Expr == R_GOTREL || Expr == R_GOTREL_FROM_END || Expr == R_PPC_TOC)
       In<ELFT>::Got->HasGotOffRel = true;
 
-    uintX_t Addend = computeAddend(File, Buf, E, RI, Expr, Body);
+    uintX_t Addend = computeAddend(*File, Buf, E, RI, Expr, Body);
 
     if (unsigned Processed =
             handleTlsRelocation<ELFT>(Type, Body, C, Offset, Addend, Expr)) {
@@ -796,14 +796,14 @@
 
 template <class ELFT, class RelTy>
 static void createThunks(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
-  const elf::ObjectFile<ELFT> &File = *C.getFile();
+  const elf::ObjectFile<ELFT> *File = C.getFile();
   for (const RelTy &Rel : Rels) {
-    SymbolBody &Body = File.getRelocTargetSym(Rel);
+    SymbolBody &Body = File->getRelocTargetSym(Rel);
     uint32_t Type = Rel.getType(Config->Mips64EL);
     RelExpr Expr = Target->getRelExpr(Type, Body);
     if (!isPreemptible(Body, Type) && needsPlt(Expr))
       Expr = fromPlt(Expr);
-    Expr = Target->getThunkExpr(Expr, Type, File, Body);
+    Expr = Target->getThunkExpr(Expr, Type, *File, Body);
     // Some targets might require creation of thunks for relocations.
     // Now we support only MIPS which requires LA25 thunk to call PIC
     // code from non-PIC one, and ARM which requires interworking.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26662.77952.patch
Type: text/x-patch
Size: 2341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/5d9fca94/attachment.bin>


More information about the llvm-commits mailing list