[PATCH] D158025: [lld][WebAssembly] Always include bss segments when `--emit-relocs` is used

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 14:50:59 PDT 2023


sbc100 created this revision.
Herald added subscribers: pmatos, asb, wingo, sunfish, jgravelle-google, dschuff.
Herald added a project: All.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

If we don't do this then we end up with symbols that refer to
non-existent segments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158025

Files:
  lld/wasm/Writer.cpp


Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -676,7 +676,10 @@
   // memory is not being imported then we can assume its zero initialized.
   // In the case the memory is imported, and we can use the memory.fill
   // instruction, then we can also avoid including the segments.
-  if (config->memoryImport.has_value() && !allowed.count("bulk-memory"))
+  // Finally, if we are emitting relocation then may refer to locations within
+  // the bss segments, so those segments need to exist.
+  if (config.emitRelocs ||
+      (config->memoryImport.has_value() && !allowed.count("bulk-memory")))
     config->emitBssSegments = true;
 
   if (allowed.count("extended-const"))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158025.550487.patch
Type: text/x-patch
Size: 773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/7f4d60bb/attachment.bin>


More information about the llvm-commits mailing list