[PATCH] D33194: [DWARF] - Cleanup relocations proccessing.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 05:24:23 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL303251: [DWARF] - Cleanup relocations proccessing. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D33194?vs=98995&id=99274#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33194

Files:
  llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
  llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp


Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
===================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
@@ -17,7 +17,6 @@
 namespace llvm {
 
 struct RelocAddrEntry {
-  uint8_t Width;
   int64_t Value;
 };
 
Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1086,49 +1086,32 @@
         continue;
     }
 
+    if (Section.relocation_begin() == Section.relocation_end())
+      continue;
+
     std::map<SymbolRef, uint64_t> AddrCache;
-    if (Section.relocation_begin() != Section.relocation_end()) {
-      uint64_t SectionSize = RelocatedSection->getSize();
-      for (const RelocationRef &Reloc : Section.relocations()) {
-        // FIXME: it's not clear how to correctly handle scattered
-        // relocations.
-        if (isRelocScattered(Obj, Reloc))
-          continue;
+    for (const RelocationRef &Reloc : Section.relocations()) {
+      // FIXME: it's not clear how to correctly handle scattered
+      // relocations.
+      if (isRelocScattered(Obj, Reloc))
+        continue;
 
-        Expected<uint64_t> SymAddrOrErr =
-            getSymbolAddress(Obj, Reloc, L, AddrCache);
-        if (!SymAddrOrErr) {
-          errs() << toString(SymAddrOrErr.takeError()) << '\n';
-          continue;
-        }
+      Expected<uint64_t> SymAddrOrErr =
+          getSymbolAddress(Obj, Reloc, L, AddrCache);
+      if (!SymAddrOrErr) {
+        errs() << toString(SymAddrOrErr.takeError()) << '\n';
+        continue;
+      }
 
-        object::RelocVisitor V(Obj);
-        object::RelocToApply R(V.visit(Reloc.getType(), Reloc, *SymAddrOrErr));
-        if (V.error()) {
-          SmallString<32> Name;
-          Reloc.getTypeName(Name);
-          errs() << "error: failed to compute relocation: "
-                 << Name << "\n";
-          continue;
-        }
-        uint64_t Address = Reloc.getOffset();
-        if (Address + R.Width > SectionSize) {
-          errs() << "error: " << R.Width << "-byte relocation starting "
-                 << Address << " bytes into section " << name << " which is "
-                 << SectionSize << " bytes long.\n";
-          continue;
-        }
-        if (R.Width > 8) {
-          errs() << "error: can't handle a relocation of more than 8 bytes at "
-                    "a time.\n";
-          continue;
-        }
-        DEBUG(dbgs() << "Writing " << format("%p", R.Value)
-                     << " at " << format("%p", Address)
-                     << " with width " << format("%d", R.Width)
-                     << "\n");
-        Map->insert({Address, {(uint8_t)R.Width, R.Value}});
+      object::RelocVisitor V(Obj);
+      object::RelocToApply R(V.visit(Reloc.getType(), Reloc, *SymAddrOrErr));
+      if (V.error()) {
+        SmallString<32> Name;
+        Reloc.getTypeName(Name);
+        errs() << "error: failed to compute relocation: " << Name << "\n";
+        continue;
       }
+      Map->insert({Reloc.getOffset(), {R.Value}});
     }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33194.99274.patch
Type: text/x-patch
Size: 3276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/601426a6/attachment.bin>


More information about the llvm-commits mailing list