[PATCH] [lld][PECOFF] Fix data directory entry RVA of base relocations section

Rui Ueyama ruiu at google.com
Mon Sep 23 13:03:59 PDT 2013

Comment at: lib/ReaderWriter/PECOFF/Atoms.h:257
@@ -254,2 +256,3 @@
+    *(reinterpret_cast<uint32_t *>(&data[0])) = entryAddr;
     *(reinterpret_cast<uint32_t *>(&data[4])) = entrySize;
     return data;
I wrote this code but this seems to be correct only the little endian machine. This would produce invalid binary when the linker is run on a BE machine. We should cast to a pointer to a ulittle32_t rather than a pointer to uint32_t.

Comment at: lib/ReaderWriter/PECOFF/WriterPECOFF.cpp:429
@@ -429,1 +428,3 @@
+        _file, llvm::COFF::DataDirectoryIndex::BASE_RELOCATION_TABLE, size,
+        addr);
     uint64_t offset = atom->ordinal() * sizeof(llvm::object::data_directory);
Doesn't this fit in 80 char?


More information about the llvm-commits mailing list