[lld] r308315 - [COFF] Accept discarded relocations in DWARF debug sections

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 08:11:05 PDT 2017


Author: smeenai
Date: Tue Jul 18 08:11:05 2017
New Revision: 308315

URL: http://llvm.org/viewvc/llvm-project?rev=308315&view=rev
Log:
[COFF] Accept discarded relocations in DWARF debug sections

DWARF debug sections can also contain relocations against symbols in
discared segments. LLD should accept such relocations.

Differential Revision: https://reviews.llvm.org/D35526

Added:
    lld/trunk/test/COFF/reloc-discarded-dwarf.s
Modified:
    lld/trunk/COFF/Chunks.cpp
    lld/trunk/COFF/Chunks.h

Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=308315&r1=308314&r2=308315&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Tue Jul 18 08:11:05 2017
@@ -235,7 +235,7 @@ void SectionChunk::writeTo(uint8_t *Buf)
     // sections are not GC roots and can end up with these kinds of relocations.
     // Skip these relocations.
     if (!OS && !isa<DefinedAbsolute>(Sym) && !isa<DefinedSynthetic>(Sym)) {
-      if (isCodeView())
+      if (isCodeView() || isDWARF())
         continue;
       fatal("relocation against symbol in discarded section: " +
             Sym->getName());

Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=308315&r1=308314&r2=308315&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Tue Jul 18 08:11:05 2017
@@ -188,6 +188,9 @@ public:
     return SectionName == ".debug" || SectionName.startswith(".debug$");
   }
 
+  // True if this is a DWARF debug info chunk.
+  bool isDWARF() const { return SectionName.startswith(".debug_"); }
+
   // Allow iteration over the bodies of this chunk's relocated symbols.
   llvm::iterator_range<symbol_iterator> symbols() const {
     return llvm::make_range(symbol_iterator(File, Relocs.begin()),

Added: lld/trunk/test/COFF/reloc-discarded-dwarf.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/reloc-discarded-dwarf.s?rev=308315&view=auto
==============================================================================
--- lld/trunk/test/COFF/reloc-discarded-dwarf.s (added)
+++ lld/trunk/test/COFF/reloc-discarded-dwarf.s Tue Jul 18 08:11:05 2017
@@ -0,0 +1,15 @@
+# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t1.obj %s
+# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t2.obj %s
+
+# LLD should not error on relocations in DWARF debug sections against symbols in
+# discarded sections.
+# RUN: lld-link -entry:main -debug %t1.obj %t2.obj
+
+	.section	.text,"xr",discard,main
+	.globl	main
+main:
+f:
+	retq
+
+	.section	.debug_info,"dr"
+	.quad	f




More information about the llvm-commits mailing list