summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/X86/X86LinkingContext.h
blob: a1af12f6595507ec0d9b31cf6c4611c9c70e5475 (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
//===- lib/ReaderWriter/ELF/X86/X86LinkingContext.h -----------------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_READER_WRITER_ELF_X86_TARGETINFO_H
#define LLD_READER_WRITER_ELF_X86_TARGETINFO_H

#include "lld/ReaderWriter/ELFLinkingContext.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"

namespace lld {
namespace elf {
class X86LinkingContext final : public ELFLinkingContext {
public:
  X86LinkingContext(llvm::Triple);

  /// \brief X86 has only two relative relocation
  /// a) for supporting IFUNC relocs - R_386_IRELATIVE
  /// b) for supporting relative relocs - R_386_RELATIVE
  bool isRelativeReloc(const Reference &r) const override {
    if (r.kindNamespace() != Reference::KindNamespace::ELF)
      return false;
    assert(r.kindArch() == Reference::KindArch::x86);
    switch (r.kindValue()) {
    case llvm::ELF::R_386_IRELATIVE:
    case llvm::ELF::R_386_RELATIVE:
      return true;
    default:
      return false;
    }
  }
};
} // end namespace elf
} // end namespace lld
#endif
OpenPOWER on IntegriCloud