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 
~GNUInfo()23   virtual ~GNUInfo() {}
24 
25   /// ELFVersion - the value of e_ident[EI_VERSION]
ELFVersion()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]
ABIVersion()35   virtual uint8_t ABIVersion() const { return 0x0; }
36 
37   /// defaultTextSegmentAddr - target should specify its own default start
38   /// address
39   /// of the text segment. esp. for exec.
defaultTextSegmentAddr()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
entry()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
dyld()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
isDefaultExecStack()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
commonPageSize()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
abiPageSize()63   virtual uint64_t abiPageSize() const { return 0x1000; }
64 
65  protected:
66   const llvm::Triple& m_Triple;
67 };
68 
69 }  // namespace mcld
70 
71 #endif  // MCLD_TARGET_GNUINFO_H_
72