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