/// and creates the associated COFF section staging object.
void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
assert(SectionData.getSection().getVariant() == MCSection::SV_COFF
- && "Got non COFF section in the COFF backend!");
+ && "Got non-COFF section in the COFF backend!");
// FIXME: Not sure how to verify this (at least in a debug build).
MCSectionCOFF const &Sec =
static_cast<MCSectionCOFF const &>(SectionData.getSection());
const MCSymbol &Symbol = Target.getSymA()->getSymbol();
const MCSymbol &A = Symbol.AliasedSymbol();
+ if (!Asm.hasSymbolData(A))
+ Asm.getContext().FatalError(
+ Fixup.getLoc(),
+ Twine("symbol '") + A.getName() + "' can not be undefined");
+
MCSymbolData &A_SD = Asm.getSymbolData(A);
MCSectionData const *SectionData = Fragment->getParent();
COFFSection *coff_section = SectionMap[&SectionData->getSection()];
COFFSymbol *coff_symbol = SymbolMap[&A_SD.getSymbol()];
- const MCSymbolRefExpr *SymA = Target.getSymA();
const MCSymbolRefExpr *SymB = Target.getSymB();
- const bool CrossSection = SymB &&
- &SymA->getSymbol().getSection() != &SymB->getSymbol().getSection();
+ bool CrossSection = false;
- if (Target.getSymB()) {
- const MCSymbol *B = &Target.getSymB()->getSymbol();
+ if (SymB) {
+ const MCSymbol *B = &SymB->getSymbol();
MCSymbolData &B_SD = Asm.getSymbolData(*B);
+ if (!B_SD.getFragment())
+ Asm.getContext().FatalError(
+ Fixup.getLoc(),
+ Twine("symbol '") + B->getName() +
+ "' can not be undefined in a subtraction expression");
+
+ if (!A_SD.getFragment())
+ Asm.getContext().FatalError(
+ Fixup.getLoc(),
+ Twine("symbol '") + Symbol.getName() +
+ "' can not be undefined in a subtraction expression");
+
+ CrossSection = &Symbol.getSection() != &B->getSection();
// Offset of the symbol in the section
int64_t a = Layout.getSymbolOffset(&B_SD);
Header.PointerToSymbolTable = offset;
- Header.TimeDateStamp = sys::TimeValue::now().toEpochTime();
+ // We want a deterministic output. It looks like GNU as also writes 0 in here.
+ Header.TimeDateStamp = 0;
// Write it all to disk...
WriteFileHeader(Header);