Move PPC bits to lib/Target/PowerPC.
[oota-llvm.git] / include / llvm / MC / MCELFObjectWriter.h
1 //===-- llvm/MC/MCELFObjectWriter.h - ELF Object Writer ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_MC_MCELFOBJECTWRITER_H
11 #define LLVM_MC_MCELFOBJECTWRITER_H
12
13 #include "llvm/MC/MCObjectWriter.h"
14 #include "llvm/Support/DataTypes.h"
15 #include "llvm/Support/ELF.h"
16
17 namespace llvm {
18 class MCELFObjectTargetWriter {
19   const uint8_t OSABI;
20   const uint16_t EMachine;
21   const unsigned HasRelocationAddend : 1;
22   const unsigned Is64Bit : 1;
23
24 protected:
25
26   MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_,
27                           uint16_t EMachine_,  bool HasRelocationAddend_);
28
29 public:
30   static uint8_t getOSABI(Triple::OSType OSType) {
31     switch (OSType) {
32       case Triple::FreeBSD:
33         return ELF::ELFOSABI_FREEBSD;
34       case Triple::Linux:
35         return ELF::ELFOSABI_LINUX;
36       default:
37         return ELF::ELFOSABI_NONE;
38     }
39   }
40
41   virtual ~MCELFObjectTargetWriter();
42
43   virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
44                                 bool IsPCRel, bool IsRelocWithSymbol,
45                                 int64_t Addend) const; // FIXME: add = 0
46   virtual unsigned getEFlags() const;
47   virtual const MCSymbol *ExplicitRelSym(const MCAssembler &Asm,
48                                          const MCValue &Target,
49                                          const MCFragment &F,
50                                          const MCFixup &Fixup,
51                                          bool IsPCRel) const;
52   virtual void adjustFixupOffset(const MCFixup &Fixup,
53                                  uint64_t &RelocOffset);
54
55
56   /// @name Accessors
57   /// @{
58   uint8_t getOSABI() { return OSABI; }
59   uint16_t getEMachine() { return EMachine; }
60   bool hasRelocationAddend() { return HasRelocationAddend; }
61   bool is64Bit() const { return Is64Bit; }
62   /// @}
63 };
64
65 /// \brief Construct a new ELF writer instance.
66 ///
67 /// \param MOTW - The target specific ELF writer subclass.
68 /// \param OS - The stream to write to.
69 /// \returns The constructed object writer.
70 MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
71                                       raw_ostream &OS, bool IsLittleEndian);
72 } // End llvm namespace
73
74 #endif