[PATCH] [lld][PECOFF] Don't add RVAs to base relocations table

Ron Ofir ron.ofir at gmail.com
Fri Sep 6 14:03:37 PDT 2013


Hi rui314,

This patch changes WriterCOFF to ignore RVAs (DIR32NB) while creating the base relocations table, as they shouldn't be fixed in base relocations.

Unfortunately, fixing this doesn't break base-reloc.test because (I guess) llvm-objdump doesn't parse the .reloc section...

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

Files:
  lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Index: lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
===================================================================
--- lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
+++ lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
@@ -342,15 +345,15 @@
     }
   }
 
-  /// List all the relocation sites that need to be fixed up if image base is
-  /// relocated. Such relocation types are DIR32 and DIR32NB on i386. REL32 does
-  /// not be (and should not be) fixed up because it's PC-relative.
+  /// List all virtual addresses (and not relative virtual addresses) that need
+  /// to be fixed up if image base is relocated. The only relocation type that
+  /// needs to be fixed is DIR32 on i386. REL32 is not (and should not be)
+  /// fixed up because it's PC-relative. 
   void addBaseRelocations(std::vector<uint64_t> &relocSites) {
     for (const auto *layout : _atomLayouts) {
       const DefinedAtom *atom = cast<DefinedAtom>(layout->_atom);
       for (const Reference *ref : *atom)
-        if (ref->kind() == llvm::COFF::IMAGE_REL_I386_DIR32 ||
-            ref->kind() == llvm::COFF::IMAGE_REL_I386_DIR32NB)
+        if (ref->kind() == llvm::COFF::IMAGE_REL_I386_DIR32)
           relocSites.push_back(layout->_virtualAddr + ref->offsetInAtom());
     }
   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1624.1.patch
Type: text/x-patch
Size: 1251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130906/5a7f446b/attachment.bin>


More information about the llvm-commits mailing list