[PATCH] D55098: Do not assume .idata is zero-initialized.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 30 08:37:53 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL348000: Do not assume .idata is zero-initialized. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55098?vs=176002&id=176137#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55098/new/

https://reviews.llvm.org/D55098

Files:
  lld/trunk/COFF/Chunks.cpp
  lld/trunk/COFF/DLL.cpp
  lld/trunk/test/COFF/export.test


Index: lld/trunk/test/COFF/export.test
===================================================================
--- lld/trunk/test/COFF/export.test
+++ lld/trunk/test/COFF/export.test
@@ -97,3 +97,12 @@
 FORWARDER:        0        0
 FORWARDER:        1   0x1010  exportfn
 FORWARDER:        2           foo (forwarded to kernel32.foobar)
+
+# RUN: lld-link /out:%t.dll /dll %t.obj /merge:.rdata=.text /export:exportfn1 /export:exportfn2
+# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=MERGE -match-full-lines %s
+
+MERGE:      DLL name: export.test.tmp.dll
+MERGE:      Ordinal      RVA  Name
+MERGE-NEXT:       0        0
+MERGE-NEXT:       1   0x1008  exportfn1
+MERGE-NEXT:       2   0x1010  exportfn2
Index: lld/trunk/COFF/DLL.cpp
===================================================================
--- lld/trunk/COFF/DLL.cpp
+++ lld/trunk/COFF/DLL.cpp
@@ -416,6 +416,8 @@
   size_t getSize() const override { return Size * 4; }
 
   void writeTo(uint8_t *Buf) const override {
+    memset(Buf + OutputSectionOff, 0, getSize());
+
     for (const Export &E : Config->Exports) {
       uint8_t *P = Buf + OutputSectionOff + E.Ordinal * 4;
       uint32_t Bit = 0;
Index: lld/trunk/COFF/Chunks.cpp
===================================================================
--- lld/trunk/COFF/Chunks.cpp
+++ lld/trunk/COFF/Chunks.cpp
@@ -619,6 +619,7 @@
 
 void StringChunk::writeTo(uint8_t *Buf) const {
   memcpy(Buf + OutputSectionOff, Str.data(), Str.size());
+  Buf[OutputSectionOff + Str.size()] = '\0';
 }
 
 ImportThunkChunkX64::ImportThunkChunkX64(Defined *S) : ImpSymbol(S) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55098.176137.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181130/f533716f/attachment.bin>


More information about the llvm-commits mailing list