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 {
     21 public:
     22   GNUInfo(const llvm::Triple& pTriple);
     23 
     24   virtual ~GNUInfo() { }
     25 
     26   /// ELFVersion - the value of e_ident[EI_VERSION]
     27   virtual uint8_t ELFVersion() const { return llvm::ELF::EV_CURRENT; }
     28 
     29   /// The return value of machine() it the same as e_machine in the ELF header
     30   virtual uint32_t machine() const = 0;
     31 
     32   /// OSABI - the value of e_ident[EI_OSABI]
     33   uint8_t OSABI() const;
     34 
     35   /// ABIVersion - the value of e_ident[EI_ABIVRESION]
     36   virtual uint8_t ABIVersion() const { return 0x0; }
     37 
     38   /// defaultTextSegmentAddr - target should specify its own default start address
     39   /// of the text segment. esp. for exec.
     40   virtual uint64_t defaultTextSegmentAddr() const { return 0x0; }
     41 
     42   /// flags - the value of ElfXX_Ehdr::e_flags
     43   virtual uint64_t flags() const = 0;
     44 
     45   /// entry - the symbol name of the entry point
     46   virtual const char* entry() const { return "_start"; }
     47 
     48   /// dyld - the name of the default dynamic linker
     49   /// target may override this function if needed.
     50   /// @ref gnu ld, bfd/elf32-i386.c:521
     51   virtual const char* dyld() const { return "/usr/lib/libc.so.1"; }
     52 
     53   /// isDefaultExecStack - target should specify whether the stack is default
     54   /// executable. If target favors another choice, please override this function
     55   virtual bool isDefaultExecStack() const { return true; }
     56 
     57   /// commonPageSize - the common page size of the target machine, and we set it
     58   /// to 4K here. If target favors the different size, please override this
     59   virtual uint64_t commonPageSize() const { return 0x1000; }
     60 
     61   /// abiPageSize - the abi page size of the target machine, and we set it to 4K
     62   /// here. If target favors the different size, please override this function
     63   virtual uint64_t abiPageSize() const { return 0x1000; }
     64 
     65 protected:
     66   const llvm::Triple& m_Triple;
     67 };
     68 
     69 } // namespace of mcld
     70 
     71 #endif
     72 
     73