blob: 3329fabe7c0378047b5c057dddf6a9cbb9633b0d (
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
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_MC_MCFIXUP_H
#define RCC_MC_MCFIXUP_H
#include "rcc/MC/MCExpr.h"
#include "rcc/Support/Error.h"
#include <cstdint>
namespace rcc::mc {
using MCFixupKind = std::uint16_t;
namespace fixup_kind {
inline constexpr MCFixupKind None = 0;
inline constexpr MCFixupKind Data1 = 1;
inline constexpr MCFixupKind Data2 = 2;
inline constexpr MCFixupKind Data4 = 3;
inline constexpr MCFixupKind Data8 = 4;
inline constexpr MCFixupKind PCRelative4 = 5;
inline constexpr MCFixupKind FirstTarget = 256;
} // namespace fixup_kind
struct MCFixup final {
std::uint64_t Offset = 0;
MCExprRef Value;
MCFixupKind Kind = fixup_kind::None;
bool PCRelative = false;
bool LinkerRelaxable = false;
[[nodiscard]] Expected<void> verify() const;
};
struct MCValue final {
MCSymbolRef AddSymbol;
MCSymbolRef SubtractSymbol;
std::int64_t Addend = 0;
std::uint32_t TargetKind = 0;
[[nodiscard]] bool isAbsolute() const noexcept {
return !AddSymbol && !SubtractSymbol;
}
};
[[nodiscard]] Expected<MCValue> evaluateAsRelocatable(const MCExpr &Expression);
} // namespace rcc::mc
#endif // RCC_MC_MCFIXUP_H
|