[PATCH] D69600: [WebAssembly][lld] Fix for static linking of PIC code

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 18:38:52 PDT 2019


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.

When statically linking PIC code we create an internalized __memory_base
so that memory-base-relative relocation work correctly.  The value of
this global should be zero, and not the globalBase since the globalBase
offset is already taken into account by getVirtualAddress.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69600

Files:
  lld/test/wasm/pic-static.ll
  lld/wasm/Writer.cpp


Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -226,8 +226,6 @@
 
   if (WasmSym::globalBase)
     WasmSym::globalBase->setVirtualAddress(memoryPtr);
-  if (WasmSym::definedMemoryBase)
-    WasmSym::definedMemoryBase->setVirtualAddress(memoryPtr);
 
   uint32_t dataStart = memoryPtr;
 
Index: lld/test/wasm/pic-static.ll
===================================================================
--- lld/test/wasm/pic-static.ll
+++ lld/test/wasm/pic-static.ll
@@ -118,4 +118,4 @@
 ; CHECK-NEXT:         Mutable:         false
 ; CHECK-NEXT:         InitExpr:
 ; CHECK-NEXT:           Opcode:          I32_CONST
-; CHECK-NEXT:           Value:           1024
+; CHECK-NEXT:           Value:           0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69600.227016.patch
Type: text/x-patch
Size: 795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191030/dfde793b/attachment.bin>


More information about the llvm-commits mailing list