1 //===-- llvm/Target/TargetELFWriterInfo.h - ELF Writer Info -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the TargetELFWriterInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
15 #define LLVM_TARGET_TARGETELFWRITERINFO_H
22 //===--------------------------------------------------------------------===//
23 // TargetELFWriterInfo
24 //===--------------------------------------------------------------------===//
26 class TargetELFWriterInfo {
28 // EMachine - This field is the target specific value to emit as the
29 // e_machine member of the ELF header.
30 unsigned short EMachine;
32 bool is64Bit, isLittleEndian;
35 // Machine architectures
37 EM_NONE = 0, // No machine
38 EM_M32 = 1, // AT&T WE 32100
39 EM_SPARC = 2, // SPARC
40 EM_386 = 3, // Intel 386
41 EM_68K = 4, // Motorola 68000
42 EM_88K = 5, // Motorola 88000
43 EM_486 = 6, // Intel 486 (deprecated)
44 EM_860 = 7, // Intel 80860
45 EM_MIPS = 8, // MIPS R3000
46 EM_PPC = 20, // PowerPC
48 EM_ALPHA = 41, // DEC Alpha
49 EM_SPARCV9 = 43, // SPARC V9
50 EM_X86_64 = 62 // AMD64
55 ELFCLASS32 = 1, // 32-bit object file
56 ELFCLASS64 = 2 // 64-bit object file
61 ELFDATA2LSB = 1, // Little-endian object file
62 ELFDATA2MSB = 2 // Big-endian object file
65 explicit TargetELFWriterInfo(TargetMachine &tm);
66 virtual ~TargetELFWriterInfo();
68 unsigned short getEMachine() const { return EMachine; }
69 unsigned getEFlags() const { return 0; }
70 unsigned getEIClass() const { return is64Bit ? ELFCLASS64 : ELFCLASS32; }
71 unsigned getEIData() const {
72 return isLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
75 /// ELF Header and ELF Section Header Info
76 unsigned getHdrSize() const { return is64Bit ? 64 : 52; }
77 unsigned getSHdrSize() const { return is64Bit ? 64 : 40; }
80 unsigned getSymTabEntrySize() const { return is64Bit ? 24 : 16; }
81 unsigned getSymTabAlignment() const { return is64Bit ? 8 : 4; }
83 /// getFunctionAlignment - Returns the alignment for function 'F', targets
84 /// with different alignment constraints should overload this method
85 virtual unsigned getFunctionAlignment(const Function *F) const;
88 } // end llvm namespace
90 #endif // LLVM_TARGET_TARGETELFWRITERINFO_H