Home | History | Annotate | Download | only in Target
      1 //===- GNUInfo.h ----------------------------------------------------------===//
      2 //
      3 //                     The MCLinker Project
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 #ifndef MCLD_TARGET_GNUINFO_H_
     10 #define MCLD_TARGET_GNUINFO_H_
     11 #include <llvm/ADT/Triple.h>
     12 #include <llvm/Support/ELF.h>
     13 
     14 namespace mcld {
     15 
     16 /** \class GNUInfo
     17  *  \brief GNUInfo records ELF-dependent and target-dependnet data fields
     18  */
     19 class GNUInfo {
     20  public:
     21   explicit GNUInfo(const llvm::Triple& pTriple);
     22 
     23   virtual ~GNUInfo() {}
     24 
     25   /// ELFVersion - the value of e_ident[EI_VERSION]
     26   virtual uint8_t ELFVersion() const { return llvm::ELF::EV_CURRENT; }
     27 
     28   /// The return value of machine() it the same as e_machine in the ELF header
     29   virtual uint32_t machine() const = 0;
     30 
     31   /// OSABI - the value of e_ident[EI_OSABI]
     32   uint8_t OSABI() const;
     33 
     34   /// ABIVersion - the value of e_ident[EI_ABIVRESION]
     35   virtual uint8_t ABIVersion() const { return 0x0; }
     36 
     37   /// defaultTextSegmentAddr - target should specify its own default start
     38   /// address of the text segment. esp. for exec.
     39   virtual uint64_t defaultTextSegmentAddr() const { return 0x0; }
     40 
     41   /// flags - the value of ElfXX_Ehdr::e_flags
     42   virtual uint64_t flags() const = 0;
     43 
     44   /// entry - the symbol name of the entry point
     45   virtual const char* entry() const { return "_start"; }
     46 
     47   /// dyld - the name of the default dynamic linker
     48   /// target may override this function if needed.
     49   virtual const char* dyld() const { return "/usr/lib/libc.so.1"; }
     50 
     51   /// isDefaultExecStack - target should specify whether the stack is default
     52   /// executable. If target favors another choice, please override this function
     53   virtual bool isDefaultExecStack() const { return true; }
     54 
     55   /// commonPageSize - the common page size of the target machine, and we set it
     56   /// to 4K here. If target favors the different size, please override this
     57   virtual uint64_t commonPageSize() const { return 0x1000; }
     58 
     59   /// abiPageSize - the abi page size of the target machine, and we set it to 4K
     60   /// here. If target favors the different size, please override this function
     61   virtual uint64_t abiPageSize() const { return 0x1000; }
     62 
     63   /// stubGroupSize - the default group size to place stubs between sections.
     64   virtual unsigned stubGroupSize() const { return 0x10000; }
     65 
     66  protected:
     67   const llvm::Triple& m_Triple;
     68 };
     69 
     70 }  // namespace mcld
     71 
     72 #endif  // MCLD_TARGET_GNUINFO_H_
     73