blob: e534e17f28ab734562a1cd63be6483659772c00a [file] [log] [blame]
Bill Wendling40d77642007-01-27 02:54:30 +00001//===-- X86ELFWriterInfo.h - ELF Writer Info for X86 ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bill Wendling40d77642007-01-27 02:54:30 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements ELF writer information for the X86 backend.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef X86_ELF_WRITER_INFO_H
15#define X86_ELF_WRITER_INFO_H
16
17#include "llvm/Target/TargetELFWriterInfo.h"
18
19namespace llvm {
20
21 class X86ELFWriterInfo : public TargetELFWriterInfo {
Bruno Cardoso Lopes0d3193e2009-06-22 19:16:16 +000022
23 // ELF Relocation types for X86
24 enum X86RelocationType {
25 R_386_NONE = 0,
26 R_386_32 = 1,
27 R_386_PC32 = 2
28 };
29
30 // ELF Relocation types for X86_64
31 enum X86_64RelocationType {
32 R_X86_64_NONE = 0,
33 R_X86_64_64 = 1,
34 R_X86_64_PC32 = 2,
35 R_X86_64_32 = 10,
36 R_X86_64_32S = 11,
37 R_X86_64_PC64 = 24
38 };
39
Bill Wendling40d77642007-01-27 02:54:30 +000040 public:
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000041 X86ELFWriterInfo(TargetMachine &TM);
Bill Wendling0db1f0b2007-01-27 11:40:32 +000042 virtual ~X86ELFWriterInfo();
Bruno Cardoso Lopesc997d452009-06-11 19:16:03 +000043
Bruno Cardoso Lopes0d3193e2009-06-22 19:16:16 +000044 /// getRelocationType - Returns the target specific ELF Relocation type.
45 /// 'MachineRelTy' contains the object code independent relocation type
46 virtual unsigned getRelocationType(unsigned MachineRelTy) const;
47
48 /// hasRelocationAddend - True if the target uses an addend in the
49 /// ELF relocation entry.
50 virtual bool hasRelocationAddend() const { return is64Bit ? true : false; }
51
Bruno Cardoso Lopese2b0ecd2009-07-18 23:24:01 +000052 /// hasCustomJumpTableIndexRelTy - Returns true if the target has a
53 /// specific relocation type for a jump table index.
54 virtual bool hasCustomJumpTableIndexRelTy() const {
55 return is64Bit ? true : false;
56 }
57
58 /// getJumpTableIndexRelTy - Returns the target specific relocation type
59 /// for a jump table index.
60 virtual unsigned getJumpTableIndexRelTy() const { return R_X86_64_32S; }
61
Bruno Cardoso Lopes0d3193e2009-06-22 19:16:16 +000062 /// getAddendForRelTy - Gets the addend value for an ELF relocation entry
63 /// based on the target relocation type
Bruno Cardoso Lopes171375f2009-07-18 19:30:09 +000064 virtual long int getDefaultAddendForRelTy(unsigned RelTy) const;
65
66 /// getRelTySize - Returns the size of relocatable field in bits
67 virtual unsigned getRelocationTySize(unsigned RelTy) const;
68
69 /// getJumpTableRelocationTy - Returns the machine relocation type used
70 /// to reference a jumptable.
Bruno Cardoso Lopes617dd7b2009-07-18 20:52:11 +000071 virtual unsigned getAbsoluteLabelMachineRelTy() const;
Bill Wendling40d77642007-01-27 02:54:30 +000072 };
73
74} // end llvm namespace
75
76#endif // X86_ELF_WRITER_INFO_H