[PATCH] D74781: Wasm-ld emits invalid .debug_ranges entries for non-live symbols

Paolo Severini via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 21 22:59:57 PDT 2020


paolosev updated this revision to Diff 251876.
paolosev added a comment.

Thank you Sam, fixing this in calcNewValue also works and it's cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74781

Files:
  lld/wasm/InputFiles.cpp


Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -167,10 +167,12 @@
   if (reloc.Type != R_WASM_TYPE_INDEX_LEB) {
     sym = symbols[reloc.Index];
 
-    // We can end up with relocations against non-live symbols.  For example
-    // in debug sections.
+    // We can end up with relocations against non-live symbols. For example
+    // in debug sections. We return reloc.Addend because always returning zero
+    // causes the generation of spurious range-list terminators in the
+    // .debug_ranges section.
     if ((isa<FunctionSymbol>(sym) || isa<DataSymbol>(sym)) && !sym->isLive())
-      return 0;
+      return reloc.Addend;
   }
 
   switch (reloc.Type) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74781.251876.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200322/94a40067/attachment.bin>


More information about the llvm-commits mailing list