blob: e727a839b40a34f869d07a43fbc2c2d7a099bbe9 (
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
73
74
75
76
77
|
//===- lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.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_HEXAGON_HEXAGON_LINKING_CONTEXT_H
#define LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_LINKING_CONTEXT_H
#include "OutputELFWriter.h"
#include "lld/ReaderWriter/ELFLinkingContext.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"
namespace lld {
namespace elf {
typedef llvm::object::ELFType<llvm::support::little, 2, false> HexagonELFType;
class HexagonLinkingContext final : public ELFLinkingContext {
public:
static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
HexagonLinkingContext(llvm::Triple triple);
void addPasses(PassManager &) override;
bool isDynamicRelocation(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false;
switch (r.kindValue()) {
case llvm::ELF::R_HEX_RELATIVE:
case llvm::ELF::R_HEX_GLOB_DAT:
return true;
default:
return false;
}
}
bool isPLTRelocation(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false;
switch (r.kindValue()) {
case llvm::ELF::R_HEX_JMP_SLOT:
return true;
default:
return false;
}
}
/// \brief Hexagon has only one relative relocation
/// a) for supporting relative relocs - R_HEX_RELATIVE
bool isRelativeReloc(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false;
switch (r.kindValue()) {
case llvm::ELF::R_HEX_RELATIVE:
return true;
default:
return false;
}
}
};
template <class ELFT> void setHexagonELFHeader(ELFHeader<ELFT> &elfHeader) {
elfHeader.e_ident(llvm::ELF::EI_VERSION, 1);
elfHeader.e_ident(llvm::ELF::EI_OSABI, 0);
elfHeader.e_version(1);
elfHeader.e_flags(0x3);
}
} // elf
} // lld
#endif // LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_LINKING_CONTEXT_H
|