mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
llvm-mc: Rename / redefine MCFragment::FileOffset to MCFragment::Offset (the
section offset). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79734 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -43,12 +43,11 @@ private:
|
|||||||
//
|
//
|
||||||
// FIXME: This could all be kept private to the assembler implementation.
|
// FIXME: This could all be kept private to the assembler implementation.
|
||||||
|
|
||||||
/// FileOffset - The offset of this section in the object file. This is ~0
|
/// Offset - The offset of this fragment in its section. This is ~0 until
|
||||||
/// until initialized.
|
|
||||||
uint64_t FileOffset;
|
|
||||||
|
|
||||||
/// FileSize - The size of this section in the object file. This is ~0 until
|
|
||||||
/// initialized.
|
/// initialized.
|
||||||
|
uint64_t Offset;
|
||||||
|
|
||||||
|
/// FileSize - The file size of this section. This is ~0 until initialized.
|
||||||
uint64_t FileSize;
|
uint64_t FileSize;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
@@ -83,11 +82,11 @@ public:
|
|||||||
FileSize = Value;
|
FileSize = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getFileOffset() const {
|
uint64_t getOffset() const {
|
||||||
assert(FileOffset != ~UINT64_C(0) && "File offset not set!");
|
assert(Offset != ~UINT64_C(0) && "File offset not set!");
|
||||||
return FileOffset;
|
return Offset;
|
||||||
}
|
}
|
||||||
void setFileOffset(uint64_t Value) { FileOffset = Value; }
|
void setOffset(uint64_t Value) { Offset = Value; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
@@ -202,7 +202,6 @@ MCFragment::MCFragment() : Kind(FragmentType(~0)) {
|
|||||||
|
|
||||||
MCFragment::MCFragment(FragmentType _Kind, MCSectionData *SD)
|
MCFragment::MCFragment(FragmentType _Kind, MCSectionData *SD)
|
||||||
: Kind(_Kind),
|
: Kind(_Kind),
|
||||||
FileOffset(~UINT64_C(0)),
|
|
||||||
FileSize(~UINT64_C(0))
|
FileSize(~UINT64_C(0))
|
||||||
{
|
{
|
||||||
if (SD)
|
if (SD)
|
||||||
@@ -234,22 +233,20 @@ MCAssembler::~MCAssembler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MCAssembler::LayoutSection(MCSectionData &SD) {
|
void MCAssembler::LayoutSection(MCSectionData &SD) {
|
||||||
uint64_t FileOffset = SD.getFileOffset();
|
uint64_t Offset = 0;
|
||||||
uint64_t SectionOffset = 0;
|
|
||||||
|
|
||||||
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
||||||
MCFragment &F = *it;
|
MCFragment &F = *it;
|
||||||
|
|
||||||
F.setFileOffset(FileOffset);
|
F.setOffset(Offset);
|
||||||
|
|
||||||
// Evaluate fragment size.
|
// Evaluate fragment size.
|
||||||
switch (F.getKind()) {
|
switch (F.getKind()) {
|
||||||
case MCFragment::FT_Align: {
|
case MCFragment::FT_Align: {
|
||||||
MCAlignFragment &AF = cast<MCAlignFragment>(F);
|
MCAlignFragment &AF = cast<MCAlignFragment>(F);
|
||||||
|
|
||||||
uint64_t AlignedOffset =
|
uint64_t AlignedOffset = RoundUpToAlignment(Offset, AF.getAlignment());
|
||||||
RoundUpToAlignment(SectionOffset, AF.getAlignment());
|
uint64_t PaddingBytes = AlignedOffset - Offset;
|
||||||
uint64_t PaddingBytes = AlignedOffset - SectionOffset;
|
|
||||||
|
|
||||||
if (PaddingBytes > AF.getMaxBytesToEmit())
|
if (PaddingBytes > AF.getMaxBytesToEmit())
|
||||||
AF.setFileSize(0);
|
AF.setFileSize(0);
|
||||||
@@ -271,21 +268,20 @@ void MCAssembler::LayoutSection(MCSectionData &SD) {
|
|||||||
uint64_t OrgOffset = OF.getOffset().getConstant();
|
uint64_t OrgOffset = OF.getOffset().getConstant();
|
||||||
|
|
||||||
// FIXME: We need a way to communicate this error.
|
// FIXME: We need a way to communicate this error.
|
||||||
if (OrgOffset < SectionOffset)
|
if (OrgOffset < Offset)
|
||||||
llvm_report_error("invalid .org offset '" + Twine(OrgOffset) +
|
llvm_report_error("invalid .org offset '" + Twine(OrgOffset) +
|
||||||
"' (section offset '" + Twine(SectionOffset) + "'");
|
"' (section offset '" + Twine(Offset) + "'");
|
||||||
|
|
||||||
F.setFileSize(OrgOffset - SectionOffset);
|
F.setFileSize(OrgOffset - Offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOffset += F.getFileSize();
|
Offset += F.getFileSize();
|
||||||
SectionOffset += F.getFileSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Pad section?
|
// FIXME: Pad section?
|
||||||
SD.setFileSize(FileOffset - SD.getFileOffset());
|
SD.setFileSize(Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WriteFileData - Write the \arg F data to the output file.
|
/// WriteFileData - Write the \arg F data to the output file.
|
||||||
@@ -294,8 +290,6 @@ static void WriteFileData(raw_ostream &OS, const MCFragment &F,
|
|||||||
uint64_t Start = OS.tell();
|
uint64_t Start = OS.tell();
|
||||||
(void) Start;
|
(void) Start;
|
||||||
|
|
||||||
assert(F.getFileOffset() == Start && "Invalid file offset!");
|
|
||||||
|
|
||||||
// FIXME: Embed in fragments instead?
|
// FIXME: Embed in fragments instead?
|
||||||
switch (F.getKind()) {
|
switch (F.getKind()) {
|
||||||
case MCFragment::FT_Align: {
|
case MCFragment::FT_Align: {
|
||||||
|
Reference in New Issue
Block a user