From e3a20f57d927e422874a8e7730bb7590515b586d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 5 Oct 2015 12:07:05 +0000 Subject: Fix pr24486. This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303 --- llvm/lib/MC/MachObjectWriter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/lib/MC/MachObjectWriter.cpp') diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 94d71f1116d..d5184f1d9a4 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -625,6 +625,18 @@ void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm, bindIndirectSymbols(Asm); } +bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( + const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, + bool InSet) const { + // FIXME: We don't handle things like + // foo = . + // creating atoms. + if (A.isVariable() || B.isVariable()) + return false; + return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, A, B, + InSet); +} + bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const { -- cgit v1.2.3