[lld] r248056 - [elf2] Relocate against undefined weak symbols.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 15:26:14 PDT 2015


Author: mspencer
Date: Fri Sep 18 17:26:13 2015
New Revision: 248056

URL: http://llvm.org/viewvc/llvm-project?rev=248056&view=rev
Log:
[elf2] Relocate against undefined weak symbols.

Added:
    lld/trunk/test/elf2/relocation-undefined-weak.s
Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248056&r1=248055&r2=248056&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Sep 18 17:26:13 2015
@@ -750,7 +750,9 @@ void OutputSection<ELFT>::relocate(
       Type = R_X86_64_PC32;
       break;
     case SymbolBody::UndefinedKind:
-      continue;
+      assert(Body->isWeak() && "Undefined symbol reached writer");
+      SymVA = 0;
+      break;
     case SymbolBody::LazyKind:
       llvm_unreachable("Lazy symbol reached writer");
     }

Added: lld/trunk/test/elf2/relocation-undefined-weak.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-undefined-weak.s?rev=248056&view=auto
==============================================================================
--- lld/trunk/test/elf2/relocation-undefined-weak.s (added)
+++ lld/trunk/test/elf2/relocation-undefined-weak.s Fri Sep 18 17:26:13 2015
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: lld -flavor gnu2 %t -o %tout
+// RUN: llvm-objdump -d %tout | FileCheck %s
+// REQUIRES: x86
+
+.global _start
+_start:
+  movl $1, sym1(%rip)
+
+.weak sym1
+
+// CHECK: movl    $1, -69642(%rip)




More information about the llvm-commits mailing list