[PATCH] D66435: [WebAssembly][lld] Fix crash when applying relocations to debug sections

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 11:38:18 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369423: [WebAssembly][lld] Fix crash when applying relocations to debug sections (authored by sbc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D66435?vs=215967&id=216200#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66435

Files:
  lld/trunk/test/wasm/debuginfo-relocs.s
  lld/trunk/wasm/InputChunks.cpp
  lld/trunk/wasm/InputFiles.cpp
  llvm/trunk/lib/MC/MCParser/WasmAsmParser.cpp


Index: lld/trunk/test/wasm/debuginfo-relocs.s
===================================================================
--- lld/trunk/test/wasm/debuginfo-relocs.s
+++ lld/trunk/test/wasm/debuginfo-relocs.s
@@ -0,0 +1,23 @@
+# 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
+
+bar:
+    .functype bar () -> ()
+    end_function
+
+    .globl _start
+_start:
+    .functype _start () -> ()
+    call bar
+    end_function
+
+    .section .debug_info,"",@
+    .int32 bar
+
+# Even though `bar` is live in the final binary it doesn't have a table entry
+# since its not address taken in the code.  In this case any relocations in the
+# debug sections see a address of zero.
+
+# CHECK:         Name:            .debug_info
+# CHECK-NEXT:    Payload:         '00000000'
Index: lld/trunk/wasm/InputFiles.cpp
===================================================================
--- lld/trunk/wasm/InputFiles.cpp
+++ lld/trunk/wasm/InputFiles.cpp
@@ -166,7 +166,7 @@
   case R_WASM_TABLE_INDEX_I32:
   case R_WASM_TABLE_INDEX_SLEB:
   case R_WASM_TABLE_INDEX_REL_SLEB:
-    if (config->isPic && !getFunctionSymbol(reloc.Index)->hasTableIndex())
+    if (!getFunctionSymbol(reloc.Index)->hasTableIndex())
       return 0;
     return getFunctionSymbol(reloc.Index)->getTableIndex();
   case R_WASM_MEMORY_ADDR_SLEB:
Index: lld/trunk/wasm/InputChunks.cpp
===================================================================
--- lld/trunk/wasm/InputChunks.cpp
+++ lld/trunk/wasm/InputChunks.cpp
@@ -100,7 +100,7 @@
   verifyRelocTargets();
 #endif
 
-  LLVM_DEBUG(dbgs() << "applying relocations: " << getName()
+  LLVM_DEBUG(dbgs() << "applying relocations: " << toString(this)
                     << " count=" << relocations.size() << "\n");
   int32_t off = outputOffset - getInputSectionOffset();
 
Index: llvm/trunk/lib/MC/MCParser/WasmAsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/WasmAsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/WasmAsmParser.cpp
@@ -123,6 +123,7 @@
                     // See use of .init_array in WasmObjectWriter and
                     // TargetLoweringObjectFileWasm
                     .StartsWith(".init_array", SectionKind::getData())
+                    .StartsWith(".debug_", SectionKind::getMetadata())
                     .Default(Optional<SectionKind>());
     if (!Kind.hasValue())
       return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66435.216200.patch
Type: text/x-patch
Size: 2549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/ab456e78/attachment.bin>


More information about the llvm-commits mailing list