~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Target/TargetELFWriterInfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===-- llvm/Target/TargetELFWriterInfo.h - ELF Writer Info -----*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
//
10
 
// This file defines the TargetELFWriterInfo class.
11
 
//
12
 
//===----------------------------------------------------------------------===//
13
 
 
14
 
#ifndef LLVM_TARGET_TARGETELFWRITERINFO_H
15
 
#define LLVM_TARGET_TARGETELFWRITERINFO_H
16
 
 
17
 
namespace llvm {
18
 
  class Function;
19
 
  class TargetData;
20
 
  class TargetMachine;
21
 
 
22
 
  //===--------------------------------------------------------------------===//
23
 
  //                          TargetELFWriterInfo
24
 
  //===--------------------------------------------------------------------===//
25
 
 
26
 
  class TargetELFWriterInfo {
27
 
  protected:
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;
31
 
    TargetMachine &TM;
32
 
    bool is64Bit, isLittleEndian;
33
 
  public:
34
 
 
35
 
    // Machine architectures
36
 
    enum MachineType {
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
47
 
      EM_ARM = 40,     // ARM
48
 
      EM_ALPHA = 41,   // DEC Alpha
49
 
      EM_SPARCV9 = 43, // SPARC V9
50
 
      EM_X86_64 = 62   // AMD64
51
 
    };
52
 
 
53
 
    // ELF File classes
54
 
    enum {
55
 
      ELFCLASS32 = 1, // 32-bit object file
56
 
      ELFCLASS64 = 2  // 64-bit object file
57
 
    };
58
 
 
59
 
    // ELF Endianess
60
 
    enum {
61
 
      ELFDATA2LSB = 1, // Little-endian object file
62
 
      ELFDATA2MSB = 2  // Big-endian object file
63
 
    };
64
 
 
65
 
    explicit TargetELFWriterInfo(TargetMachine &tm);
66
 
    virtual ~TargetELFWriterInfo();
67
 
 
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;
73
 
    }
74
 
 
75
 
    /// ELF Header and ELF Section Header Info
76
 
    unsigned getHdrSize() const { return is64Bit ? 64 : 52; }
77
 
    unsigned getSHdrSize() const { return is64Bit ? 64 : 40; }
78
 
 
79
 
    /// Symbol Table Info
80
 
    unsigned getSymTabEntrySize() const { return is64Bit ? 24 : 16; }
81
 
 
82
 
    /// getPrefELFAlignment - Returns the preferred alignment for ELF. This
83
 
    /// is used to align some sections.
84
 
    unsigned getPrefELFAlignment() const { return is64Bit ? 8 : 4; }
85
 
 
86
 
    /// getRelocationEntrySize - Entry size used in the relocation section
87
 
    unsigned getRelocationEntrySize() const {
88
 
      return is64Bit ? (hasRelocationAddend() ? 24 : 16)
89
 
                     : (hasRelocationAddend() ? 12 : 8);
90
 
    }
91
 
 
92
 
    /// getRelocationType - Returns the target specific ELF Relocation type.
93
 
    /// 'MachineRelTy' contains the object code independent relocation type
94
 
    virtual unsigned getRelocationType(unsigned MachineRelTy) const = 0;
95
 
 
96
 
    /// hasRelocationAddend - True if the target uses an addend in the
97
 
    /// ELF relocation entry.
98
 
    virtual bool hasRelocationAddend() const = 0;
99
 
 
100
 
    /// getDefaultAddendForRelTy - Gets the default addend value for a
101
 
    /// relocation entry based on the target ELF relocation type.
102
 
    virtual long int getDefaultAddendForRelTy(unsigned RelTy,
103
 
                                              long int Modifier = 0) const = 0;
104
 
 
105
 
    /// getRelTySize - Returns the size of relocatable field in bits
106
 
    virtual unsigned getRelocationTySize(unsigned RelTy) const = 0;
107
 
 
108
 
    /// isPCRelativeRel - True if the relocation type is pc relative
109
 
    virtual bool isPCRelativeRel(unsigned RelTy) const = 0;
110
 
 
111
 
    /// getJumpTableRelocationTy - Returns the machine relocation type used
112
 
    /// to reference a jumptable.
113
 
    virtual unsigned getAbsoluteLabelMachineRelTy() const = 0;
114
 
 
115
 
    /// computeRelocation - Some relocatable fields could be relocated
116
 
    /// directly, avoiding the relocation symbol emission, compute the
117
 
    /// final relocation value for this symbol.
118
 
    virtual long int computeRelocation(unsigned SymOffset, unsigned RelOffset,
119
 
                                       unsigned RelTy) const = 0;
120
 
  };
121
 
 
122
 
} // end llvm namespace
123
 
 
124
 
#endif // LLVM_TARGET_TARGETELFWRITERINFO_H