Make it possible for the MCObjectWriter to decide if a given fixup is fully
[oota-llvm.git] / include / llvm / MC / MCObjectWriter.h
index d4fab0ea477f25c6ca0abbed002d2b2e49006f32..7de37f762d365ea8c44efa95352bcb6d51ef58b9 100644 (file)
 #include <cassert>
 
 namespace llvm {
-class MCAsmFixup;
+class MCAsmLayout;
 class MCAssembler;
-class MCDataFragment;
+class MCFixup;
+class MCFragment;
 class MCValue;
 class raw_ostream;
 
@@ -48,7 +49,7 @@ protected: // Can only create subclasses.
 public:
   virtual ~MCObjectWriter();
 
-  bool isLittleEndian() { return IsLittleEndian; }
+  bool isLittleEndian() const { return IsLittleEndian; }
 
   raw_ostream &getStream() { return OS; }
 
@@ -69,16 +70,28 @@ public:
   /// information about the relocation so that it can be emitted during
   /// WriteObject().
   virtual void RecordRelocation(const MCAssembler &Asm,
-                                const MCDataFragment &Fragment,
-                                const MCAsmFixup &Fixup, MCValue Target,
+                                const MCAsmLayout &Layout,
+                                const MCFragment *Fragment,
+                                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
-  /// complete, fixups have been evaluate and applied, and relocations
+  /// complete, fixups have been evaluated and applied, and relocations
   /// generated.
-  virtual void WriteObject(const MCAssembler &Asm) = 0;
+  virtual void WriteObject(const MCAssembler &Asm,
+                           const MCAsmLayout &Layout) = 0;
 
   /// @}
   /// @name Binary Output
@@ -149,6 +162,8 @@ public:
   }
 
   void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) {
+    assert((ZeroFillSize == 0 || Str.size () <= ZeroFillSize) &&
+      "data size greater than fill size, unexpected large write will occur");
     OS << Str;
     if (ZeroFillSize)
       WriteZeros(ZeroFillSize - Str.size());
@@ -157,6 +172,8 @@ public:
   /// @}
 };
 
+MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS, bool is64Bit);
+
 } // End llvm namespace
 
 #endif