MCAssembler: Start applying fixups in the data section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96090 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-02-13 09:28:15 +00:00
parent b7c3a4b195
commit 3a30b827a5
2 changed files with 25 additions and 10 deletions

View File

@ -130,17 +130,14 @@ public:
return 0;
}
std::vector<MCAsmFixup> &getFixups() {
return Fixups;
}
std::vector<MCAsmFixup> &getFixups() { return Fixups; }
const std::vector<MCAsmFixup> &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(); }

View File

@ -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<MCDataFragment>(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<MCDataFragment>(F).getContents().str();
break;
}
case MCFragment::FT_Fill: {
MCFillFragment &FF = cast<MCFillFragment>(F);