diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 004ecceb8dd..acb14155ad4 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -130,17 +130,14 @@ public: return 0; } - std::vector &getFixups() { - return Fixups; - } + std::vector &getFixups() { return Fixups; } + const std::vector &getFixups() const { return Fixups; } - fixup_iterator fixup_begin() { - return Fixups.begin(); - } + fixup_iterator fixup_begin() { return Fixups.begin(); } + const_fixup_iterator fixup_begin() const { return Fixups.begin(); } - fixup_iterator fixup_end() { - return Fixups.end(); - } + fixup_iterator fixup_end() {return Fixups.end();} + const_fixup_iterator fixup_end() const {return Fixups.end();} size_t fixup_size() const { return Fixups.size(); } diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index a5df4ba42be..c8fa6bd589d 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -481,6 +481,8 @@ public: if (Target.isAbsolute()) { // constant // SymbolNum of 0 indicates the absolute section. + // + // FIXME: When is this generated? Type = RIT_Vanilla; Value = 0; llvm_unreachable("FIXME: Not yet implemented!"); @@ -875,6 +877,12 @@ public: OS << StringTable.str(); } } + + void ApplyFixup(const MCAsmFixup &Fixup, MCDataFragment &DF) { + // FIXME: Endianness assumption. + for (unsigned i = 0; i != Fixup.Size; ++i) + DF.getContents()[Fixup.Offset + i] = uint8_t(Fixup.FixedValue >> (i * 8)); + } }; /* *** */ @@ -1070,9 +1078,19 @@ static void WriteFileData(raw_ostream &OS, const MCFragment &F, break; } - case MCFragment::FT_Data: + case MCFragment::FT_Data: { + MCDataFragment &DF = cast(F); + + // Apply the fixups. + // + // FIXME: Move elsewhere. + for (MCDataFragment::const_fixup_iterator it = DF.fixup_begin(), + ie = DF.fixup_end(); it != ie; ++it) + MOW.ApplyFixup(*it, DF); + OS << cast(F).getContents().str(); break; + } case MCFragment::FT_Fill: { MCFillFragment &FF = cast(F);