summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-09-30 02:22:20 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-09-30 02:22:20 +0000
commit7070387f08f7dc797b554ed8013cba9f8b74121a (patch)
treeb2551756c1093c8e4396c9c2596eca5f8657fd51 /include
parent7ebc863c156c5ccd127045ddb8d663c3b49ac5f3 (diff)
downloadllvm-7070387f08f7dc797b554ed8013cba9f8b74121a.tar.gz
llvm-7070387f08f7dc797b554ed8013cba9f8b74121a.tar.bz2
llvm-7070387f08f7dc797b554ed8013cba9f8b74121a.tar.xz
Make it possible for the MCObjectWriter to decide if a given fixup is fully
resolved or not. Different object files have different restrictions and different native assemblers have different idiosyncrasies we want to emulate for now. Move the existing MachO logic to the new place and implement an ELF one that gets fixups to globals right. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/ELFObjectWriter.h5
-rw-r--r--include/llvm/MC/MCAssembler.h13
-rw-r--r--include/llvm/MC/MCObjectWriter.h10
-rw-r--r--include/llvm/MC/MachObjectWriter.h5
4 files changed, 28 insertions, 5 deletions
diff --git a/include/llvm/MC/ELFObjectWriter.h b/include/llvm/MC/ELFObjectWriter.h
index e507106620..c8a42fe57b 100644
--- a/include/llvm/MC/ELFObjectWriter.h
+++ b/include/llvm/MC/ELFObjectWriter.h
@@ -39,6 +39,11 @@ public:
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue);
+ virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
+ const MCValue Target,
+ bool IsPCRel,
+ const MCFragment *DF) const;
+
virtual void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout);
};
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index 524f2abae2..8d899d30d2 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -621,17 +621,19 @@ private:
/// \return Whether the fixup value was fully resolved. This is true if the
/// \arg Value result is fixed, otherwise the value may change due to
/// relocation.
- bool EvaluateFixup(const MCAsmLayout &Layout,
+ bool EvaluateFixup(const MCObjectWriter &Writer, const MCAsmLayout &Layout,
const MCFixup &Fixup, const MCFragment *DF,
MCValue &Target, uint64_t &Value) const;
/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
/// (increased in size, in order to hold its value correctly).
- bool FixupNeedsRelaxation(const MCFixup &Fixup, const MCFragment *DF,
+ bool FixupNeedsRelaxation(const MCObjectWriter &Writer,
+ const MCFixup &Fixup, const MCFragment *DF,
const MCAsmLayout &Layout) const;
/// Check whether the given fragment needs relaxation.
- bool FragmentNeedsRelaxation(const MCInstFragment *IF,
+ bool FragmentNeedsRelaxation(const MCObjectWriter &Writer,
+ const MCInstFragment *IF,
const MCAsmLayout &Layout) const;
/// Compute the effective fragment size assuming it is layed out at the given
@@ -642,7 +644,7 @@ private:
/// LayoutOnce - Perform one layout iteration and return true if any offsets
/// were adjusted.
- bool LayoutOnce(MCAsmLayout &Layout);
+ bool LayoutOnce(const MCObjectWriter &Writer, MCAsmLayout &Layout);
/// FinishLayout - Finalize a layout, including fragment lowering.
void FinishLayout(MCAsmLayout &Layout);
@@ -664,7 +666,8 @@ public:
void WriteSectionData(const MCSectionData *Section, const MCAsmLayout &Layout,
MCObjectWriter *OW) const;
- void AddSectionToTheEnd(MCSectionData &SD, MCAsmLayout &Layout);
+ void AddSectionToTheEnd(const MCObjectWriter &Writer, MCSectionData &SD,
+ MCAsmLayout &Layout);
public:
/// Construct a new assembler instance.
diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h
index f1c1cb8a59..7de37f762d 100644
--- a/include/llvm/MC/MCObjectWriter.h
+++ b/include/llvm/MC/MCObjectWriter.h
@@ -75,6 +75,16 @@ public:
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) = 0;
+ /// Check if a fixup is fully resolved.
+ ///
+ /// This routine is used by the assembler to let the file format decide
+ /// if a fixup is not fully resolved. For example, one that crosses
+ /// two sections on ELF.
+ virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
+ const MCValue Target,
+ bool IsPCRel,
+ const MCFragment *DF) const = 0;
+
/// Write the object file.
///
/// This routine is called by the assembler after layout and relaxation is
diff --git a/include/llvm/MC/MachObjectWriter.h b/include/llvm/MC/MachObjectWriter.h
index 9b1ff1db84..198da8fc17 100644
--- a/include/llvm/MC/MachObjectWriter.h
+++ b/include/llvm/MC/MachObjectWriter.h
@@ -36,6 +36,11 @@ public:
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue);
+ virtual bool IsFixupFullyResolved(const MCAssembler &Asm,
+ const MCValue Target,
+ bool IsPCRel,
+ const MCFragment *DF) const;
+
virtual void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout);
};