mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Produce the headers directly in the Finish method. This allows us to use
the existing streamer methods that are endian safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117323 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -95,8 +95,6 @@ namespace {
|
|||||||
|
|
||||||
class ObjectAttributeEmitter : public AttributeEmitter {
|
class ObjectAttributeEmitter : public AttributeEmitter {
|
||||||
MCObjectStreamer &Streamer;
|
MCObjectStreamer &Streamer;
|
||||||
size_t SectionStart;
|
|
||||||
size_t TagStart;
|
|
||||||
StringRef CurrentVendor;
|
StringRef CurrentVendor;
|
||||||
SmallString<64> Contents;
|
SmallString<64> Contents;
|
||||||
|
|
||||||
@@ -116,20 +114,7 @@ namespace {
|
|||||||
|
|
||||||
CurrentVendor = Vendor;
|
CurrentVendor = Vendor;
|
||||||
|
|
||||||
SectionStart = Contents.size();
|
assert(Contents.size() == 0);
|
||||||
|
|
||||||
// Length of the data for this vendor.
|
|
||||||
Contents.append(4, (char)0);
|
|
||||||
|
|
||||||
Contents.append(Vendor.begin(), Vendor.end());
|
|
||||||
Contents += 0;
|
|
||||||
|
|
||||||
Contents += ARMBuildAttrs::File;
|
|
||||||
|
|
||||||
TagStart = Contents.size();
|
|
||||||
|
|
||||||
// Length of the data for this tag.
|
|
||||||
Contents.append(4, (char)0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitAttribute(unsigned Attribute, unsigned Value) {
|
void EmitAttribute(unsigned Attribute, unsigned Value) {
|
||||||
@@ -139,15 +124,24 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Finish() {
|
void Finish() {
|
||||||
size_t EndPos = Contents.size();
|
const size_t ContentsSize = Contents.size();
|
||||||
|
|
||||||
// FIXME: endian.
|
// Vendor size + Vendor name + '\0'
|
||||||
*((uint32_t*)&Contents[SectionStart]) = EndPos - SectionStart;
|
const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;
|
||||||
|
|
||||||
// +1 since it includes the tag that came before it.
|
// Tag + Tag Size
|
||||||
*((uint32_t*)&Contents[TagStart]) = EndPos - TagStart + 1;
|
const size_t TagHeaderSize = 1 + 4;
|
||||||
|
|
||||||
|
Streamer.EmitIntValue(VendorHeaderSize + TagHeaderSize + ContentsSize, 4);
|
||||||
|
Streamer.EmitBytes(CurrentVendor, 0);
|
||||||
|
Streamer.EmitIntValue(0, 1); // '\0'
|
||||||
|
|
||||||
|
Streamer.EmitIntValue(ARMBuildAttrs::File, 1);
|
||||||
|
Streamer.EmitIntValue(TagHeaderSize + ContentsSize, 4);
|
||||||
|
|
||||||
Streamer.EmitBytes(Contents, 0);
|
Streamer.EmitBytes(Contents, 0);
|
||||||
|
|
||||||
|
Contents.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user