virtual bool
IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
- const MCSymbolRefExpr *B) const = 0;
+ const MCSymbolRefExpr *B,
+ bool InSet) const;
/// Check if a fixup is fully resolved.
///
bool IsPCRel,
const MCFragment *DF) const = 0;
- virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
- const MCSymbol &B) const = 0;
-
/// Write the object file.
///
/// This routine is called by the assembler after layout and relaxation is
MCDataFragment *F,
const MCSectionData *SD);
- virtual bool
- IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
- const MCSymbolRefExpr *A,
- const MCSymbolRefExpr *B) const {
- // FIXME: Implement this!
- return false;
- }
-
- virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
- const MCSymbol &B) const {
- // On ELF A - B is absolute if A and B are in the same section.
- return &A.getSection() == &B.getSection();
- }
-
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target,
bool IsPCRel,
const MCAssembler &Asm = Layout->getAssembler();
if (A && B &&
- Asm.getWriter().IsSymbolRefDifferenceFullyResolved(Asm, A, B)) {
+ Asm.getWriter().IsSymbolRefDifferenceFullyResolved(Asm, A, B, false)) {
// Eagerly evaluate.
Addend += (Layout->getSymbolOffset(&Asm.getSymbolData(A->getSymbol())) -
Layout->getSymbolOffset(&Asm.getSymbolData(B->getSymbol())));
"Must have an assembler object if layout is given!");
if (Asm && A && B) {
- const MCSymbol &SA = A->getSymbol();
- const MCSymbol &SB = B->getSymbol();
- if (SA.isDefined() && SB.isDefined() &&
- Asm->getWriter().isAbsolute(InSet, SA, SB)) {
+ if (A->getSymbol().isDefined() && B->getSymbol().isDefined() &&
+ Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B,
+ InSet)) {
MCSymbolData &AD = Asm->getSymbolData(A->getSymbol());
MCSymbolData &BD = Asm->getSymbolData(B->getSymbol());
//
//===----------------------------------------------------------------------===//
+#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectWriter.h"
+#include "llvm/MC/MCSymbol.h"
using namespace llvm;
OS << char(Byte);
} while (Value != 0);
}
+
+bool
+MCObjectWriter::IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
+ const MCSymbolRefExpr *A,
+ const MCSymbolRefExpr *B,
+ bool InSet) const {
+ // Modified symbol references cannot be resolved.
+ if (A->getKind() != MCSymbolRefExpr::VK_None ||
+ B->getKind() != MCSymbolRefExpr::VK_None)
+ return false;
+
+ const MCSymbol &SA = A->getSymbol();
+ const MCSymbol &SB = B->getSymbol();
+ if (SA.isUndefined() || SB.isUndefined())
+ return false;
+
+ // On ELF and COFF A - B is absolute if A and B are in the same section.
+ return &SA.getSection() == &SB.getSection();
+}
UndefinedSymbolData);
}
- bool isAbsolute(bool IsSet, const MCSymbol &A,
- const MCSymbol &B) const {
- // On MachO A - B is absolute only if in a set.
- return IsSet;
- }
-
bool IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
const MCSymbolRefExpr *A,
- const MCSymbolRefExpr *B) const {
+ const MCSymbolRefExpr *B,
+ bool InSet) const {
+ if (InSet)
+ return true;
+
if (!TargetObjectWriter->useAggressiveSymbolFolding())
return false;
MCValue Target,
uint64_t &FixedValue);
- virtual bool
- IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm,
- const MCSymbolRefExpr *A,
- const MCSymbolRefExpr *B) const {
- // FIXME: Implement this!
- return false;
- }
-
- virtual bool isAbsolute(bool IsSet, const MCSymbol &A,
- const MCSymbol &B) const {
- // On COFF A - B is absolute if A and B are in the same section.
- return &A.getSection() == &B.getSection();
- }
-
virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
const MCValue Target,
bool IsPCRel,