[llvm] r235181 - Add a proper fix for pr23025.
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 17 04:27:14 PDT 2015
Author: rafael
Date: Fri Apr 17 06:27:13 2015
New Revision: 235181
URL: http://llvm.org/viewvc/llvm-project?rev=235181&view=rev
Log:
Add a proper fix for pr23025.
Instead of avoiding looking past every global symbol, only do so
if the symbol is in a comdat.
Modified:
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/test/MC/COFF/pr23025.s
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=235181&r1=235180&r2=235181&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Fri Apr 17 06:27:13 2015
@@ -663,9 +663,21 @@ bool WinCOFFObjectWriter::IsSymbolRefDif
}
bool WinCOFFObjectWriter::isWeak(const MCSymbolData &SD) const {
- // FIXME: this is for PR23025. Write a good description on
- // why this is needed.
- return SD.isExternal();
+ if (!SD.isExternal())
+ return false;
+
+ const MCSymbol &Sym = SD.getSymbol();
+ if (!Sym.isInSection())
+ return false;
+
+ const auto &Sec = cast<MCSectionCOFF>(Sym.getSection());
+ if (!Sec.getCOMDATSymbol())
+ return false;
+
+ // It looks like for COFF it is invalid to replace a reference to a global
+ // in a comdat with a reference to a local.
+ // FIXME: Add a specification reference if available.
+ return true;
}
void WinCOFFObjectWriter::RecordRelocation(
@@ -674,7 +686,7 @@ void WinCOFFObjectWriter::RecordRelocati
assert(Target.getSymA() && "Relocation must reference a symbol!");
const MCSymbol &Symbol = Target.getSymA()->getSymbol();
- const MCSymbol &A = Symbol.AliasedSymbol();
+ const MCSymbol &A = Symbol;
if (!Asm.hasSymbolData(A))
Asm.getContext().FatalError(
Fixup.getLoc(),
Modified: llvm/trunk/test/MC/COFF/pr23025.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/pr23025.s?rev=235181&r1=235180&r2=235181&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/pr23025.s (original)
+++ llvm/trunk/test/MC/COFF/pr23025.s Fri Apr 17 06:27:13 2015
@@ -3,11 +3,13 @@
// CHECK: Relocations [
// CHECK-NEXT: Section {{.*}} .text {
// CHECK-NEXT: 0x3 IMAGE_REL_AMD64_REL32 zed
+// CHECK-NEXT: 0xA IMAGE_REL_AMD64_REL32 zed2
// CHECK-NEXT: }
// CHECK-NEXT: ]
foo:
leaq zed(%rip), %rax
+ leaq zed2(%rip), %rax
retq
.section .rdata,"dr",discard,zed
@@ -16,3 +18,6 @@ Lbar:
.globl zed
zed = Lbar+1
+
+ .globl zed2
+zed2 = Lbar
More information about the llvm-commits
mailing list