diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-11 05:53:33 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-11 05:53:33 +0000 |
commit | 18ff2cced7e08ac76d8d5bcff8160a5f9a109cbb (patch) | |
tree | 16c56ca447dbba5777596b2042d8424e5fbba5c1 /lib/MC/MCAssembler.cpp | |
parent | 040056fd11693ffc41ce9b777281c71705d0dc1f (diff) |
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
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 277cf92125..21feeedd67 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -9,6 +9,7 @@ #define DEBUG_TYPE "assembler" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSymbol.h" @@ -510,8 +511,11 @@ public: unsigned IsPCRel = isFixupKindPCRel(Fixup.Kind); unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); + // FIXME: Share layout object. + MCAsmLayout Layout(Asm); + MCValue Target; - if (!Fixup.Value->EvaluateAsRelocatable(Target)) + if (!Fixup.Value->EvaluateAsRelocatable(Target, &Layout)) llvm_report_error("expected relocatable expression"); // 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) { + MCAsmLayout Layout(*this); uint64_t Address = SD.getAddress(); 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: { MCOrgFragment &OF = cast<MCOrgFragment>(F); - MCValue Target; - if (!OF.getOffset().EvaluateAsRelocatable(Target)) - llvm_report_error("expected relocatable expression"); - - if (!Target.isAbsolute()) - llvm_unreachable("FIXME: Not yet implemented!"); - uint64_t OrgOffset = Target.getConstant(); - uint64_t Offset = Address - SD.getAddress(); + int64_t TargetLocation; + if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout)) + llvm_report_error("expected assembly-time absolute expression"); // FIXME: We need a way to communicate this error. - if (OrgOffset < Offset) - llvm_report_error("invalid .org offset '" + Twine(OrgOffset) + - "' (at offset '" + Twine(Offset) + "'"); + int64_t Offset = TargetLocation - F.getOffset(); + if (Offset < 0) + llvm_report_error("invalid .org offset '" + Twine(TargetLocation) + + "' (at offset '" + Twine(F.getOffset()) + "'"); - F.setFileSize(OrgOffset - Offset); + F.setFileSize(Offset); break; } |