mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
MC/Mach-O: Start passing in the basic MCAsmLayout object.
- Also, drop the current location part of AsmLayout, I think I prefer to implement this via explicit symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98240 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
040056fd11
commit
18ff2cced7
@ -22,26 +22,13 @@ class MCAssembler;
|
|||||||
/// even during the relaxation process.
|
/// even during the relaxation process.
|
||||||
class MCAsmLayout {
|
class MCAsmLayout {
|
||||||
private:
|
private:
|
||||||
uint64_t CurrentLocation;
|
|
||||||
|
|
||||||
MCAssembler &Assembler;
|
MCAssembler &Assembler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCAsmLayout(MCAssembler &_Assembler)
|
MCAsmLayout(MCAssembler &_Assembler) : Assembler(_Assembler) {}
|
||||||
: CurrentLocation(0), Assembler(_Assember) {}
|
|
||||||
|
|
||||||
/// Get the assembler object this is a layout for.
|
/// Get the assembler object this is a layout for.
|
||||||
MCAssembler &getAssembler() { return Assembler; }
|
MCAssembler &getAssembler() { return Assembler; }
|
||||||
|
|
||||||
/// Get the current location value, i.e. that value of the '.' expression.
|
|
||||||
uin64_t getCurrentLocation() {
|
|
||||||
return CurrentLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the current location.
|
|
||||||
void setCurrentLocation(uint64_t Value) {
|
|
||||||
CurrentLocation = Value;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#define DEBUG_TYPE "assembler"
|
#define DEBUG_TYPE "assembler"
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCAssembler.h"
|
||||||
|
#include "llvm/MC/MCAsmLayout.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
@ -510,8 +511,11 @@ public:
|
|||||||
unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
|
unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind);
|
||||||
unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
|
unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind);
|
||||||
|
|
||||||
|
// FIXME: Share layout object.
|
||||||
|
MCAsmLayout Layout(Asm);
|
||||||
|
|
||||||
MCValue Target;
|
MCValue Target;
|
||||||
if (!Fixup.Value->EvaluateAsRelocatable(Target))
|
if (!Fixup.Value->EvaluateAsRelocatable(Target, &Layout))
|
||||||
llvm_report_error("expected relocatable expression");
|
llvm_report_error("expected relocatable expression");
|
||||||
|
|
||||||
// If this is a difference or a defined symbol plus an offset, then we need
|
// If this is a difference or a defined symbol plus an offset, then we need
|
||||||
@ -1001,6 +1005,7 @@ MCAssembler::~MCAssembler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MCAssembler::LayoutSection(MCSectionData &SD) {
|
void MCAssembler::LayoutSection(MCSectionData &SD) {
|
||||||
|
MCAsmLayout Layout(*this);
|
||||||
uint64_t Address = SD.getAddress();
|
uint64_t Address = SD.getAddress();
|
||||||
|
|
||||||
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
||||||
@ -1029,21 +1034,17 @@ void MCAssembler::LayoutSection(MCSectionData &SD) {
|
|||||||
case MCFragment::FT_Org: {
|
case MCFragment::FT_Org: {
|
||||||
MCOrgFragment &OF = cast<MCOrgFragment>(F);
|
MCOrgFragment &OF = cast<MCOrgFragment>(F);
|
||||||
|
|
||||||
MCValue Target;
|
int64_t TargetLocation;
|
||||||
if (!OF.getOffset().EvaluateAsRelocatable(Target))
|
if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout))
|
||||||
llvm_report_error("expected relocatable expression");
|
llvm_report_error("expected assembly-time absolute expression");
|
||||||
|
|
||||||
if (!Target.isAbsolute())
|
|
||||||
llvm_unreachable("FIXME: Not yet implemented!");
|
|
||||||
uint64_t OrgOffset = Target.getConstant();
|
|
||||||
uint64_t Offset = Address - SD.getAddress();
|
|
||||||
|
|
||||||
// FIXME: We need a way to communicate this error.
|
// FIXME: We need a way to communicate this error.
|
||||||
if (OrgOffset < Offset)
|
int64_t Offset = TargetLocation - F.getOffset();
|
||||||
llvm_report_error("invalid .org offset '" + Twine(OrgOffset) +
|
if (Offset < 0)
|
||||||
"' (at offset '" + Twine(Offset) + "'");
|
llvm_report_error("invalid .org offset '" + Twine(TargetLocation) +
|
||||||
|
"' (at offset '" + Twine(F.getOffset()) + "'");
|
||||||
|
|
||||||
F.setFileSize(OrgOffset - Offset);
|
F.setFileSize(Offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user