summaryrefslogtreecommitdiff
path: root/include/mcld/Target/GNUInfo.h
blob: d09e5d9f0641d452498fed9009c549ab50e7bd02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//===- GNUInfo.h ----------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_TARGET_GNUINFO_H_
#define MCLD_TARGET_GNUINFO_H_
#include <llvm/ADT/Triple.h>
#include <llvm/Support/ELF.h>

namespace mcld {

/** \class GNUInfo
 *  \brief GNUInfo records ELF-dependent and target-dependnet data fields
 */
class GNUInfo {
 public:
  explicit GNUInfo(const llvm::Triple& pTriple);

  virtual ~GNUInfo() {}

  /// ELFVersion - the value of e_ident[EI_VERSION]
  virtual uint8_t ELFVersion() const { return llvm::ELF::EV_CURRENT; }

  /// The return value of machine() it the same as e_machine in the ELF header
  virtual uint32_t machine() const = 0;

  /// OSABI - the value of e_ident[EI_OSABI]
  uint8_t OSABI() const;

  /// ABIVersion - the value of e_ident[EI_ABIVRESION]
  virtual uint8_t ABIVersion() const { return 0x0; }

  /// defaultTextSegmentAddr - target should specify its own default start
  /// address of the text segment. esp. for exec.
  virtual uint64_t defaultTextSegmentAddr() const { return 0x0; }

  /// flags - the value of ElfXX_Ehdr::e_flags
  virtual uint64_t flags() const = 0;

  /// entry - the symbol name of the entry point
  virtual const char* entry() const { return "_start"; }

  /// dyld - the name of the default dynamic linker
  /// target may override this function if needed.
  virtual const char* dyld() const { return "/usr/lib/libc.so.1"; }

  /// isDefaultExecStack - target should specify whether the stack is default
  /// executable. If target favors another choice, please override this function
  virtual bool isDefaultExecStack() const { return true; }

  /// commonPageSize - the common page size of the target machine, and we set it
  /// to 4K here. If target favors the different size, please override this
  virtual uint64_t commonPageSize() const { return 0x1000; }

  /// abiPageSize - the abi page size of the target machine, and we set it to 4K
  /// here. If target favors the different size, please override this function
  virtual uint64_t abiPageSize() const { return 0x1000; }

  /// stubGroupSize - the default group size to place stubs between sections.
  virtual unsigned stubGroupSize() const { return 0x10000; }

 protected:
  const llvm::Triple& m_Triple;
};

}  // namespace mcld

#endif  // MCLD_TARGET_GNUINFO_H_