[PATCH] D101399: [lld][WebAssembly] Allow relocations against non-live global symbols

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 10:29:33 PDT 2021


sbc100 updated this revision to Diff 341258.
sbc100 added a comment.

Added test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101399

Files:
  lld/test/wasm/debuginfo-undefined-global.s
  lld/test/wasm/globals.s
  lld/wasm/InputFiles.cpp


Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -212,7 +212,7 @@
     // so this will not produce a valid range conflicting with ranges of actual
     // code. In other sections we return reloc.Addend.
 
-    if ((isa<FunctionSymbol>(sym) || isa<DataSymbol>(sym)) && !sym->isLive())
+    if (!isa<SectionSymbol>(sym) && !sym->isLive())
       return tombstone ? tombstone : reloc.Addend;
   }
 
Index: lld/test/wasm/globals.s
===================================================================
--- lld/test/wasm/globals.s
+++ lld/test/wasm/globals.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+mm# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
 # RUN: wasm-ld %t.o -o %t.wasm
 # RUN: obj2yaml %t.wasm | FileCheck %s
 
Index: lld/test/wasm/debuginfo-undefined-global.s
===================================================================
--- /dev/null
+++ lld/test/wasm/debuginfo-undefined-global.s
@@ -0,0 +1,23 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+# Debug sections are allowed to contains references to non-live symbols that
+# then get GC'd.  In this test the .debug_info seciton contains a reference to
+# foo which is not otherwise used and will not be marked a live in the output.
+# Verify the tombstone value is written to debug_info section.
+
+.globl  _start
+_start:
+  .functype _start () -> ()
+  end_function
+
+.section .debug_info,"",@
+  .int32 foo
+
+.globaltype foo, i32
+foo:
+
+# CHECK:       - Type:            CUSTOM
+# CHECK-NEXT:    Name:            .debug_info
+# CHECK-NEXT:    Payload:         FFFFFFFF


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101399.341258.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210428/0f2b0210/attachment.bin>


More information about the llvm-commits mailing list