llvm/lld/MachO/Relocations.h

//===- Relocations.h --------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLD_MACHO_RELOCATIONS_H
#define LLD_MACHO_RELOCATIONS_H

#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Endian.h"

#include <cstddef>
#include <cstdint>

namespace lld::macho {
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();

class Symbol;
class InputSection;

enum class RelocAttrBits {};
// Note: SUBTRACTOR always pairs with UNSIGNED (a delta between two symbols).

struct RelocAttrs {};

struct Reloc {};

bool validateSymbolRelocation(const Symbol *, const InputSection *,
                              const Reloc &);

/*
 * v: The value the relocation is attempting to encode
 * bits: The number of bits actually available to encode this relocation
 */
void reportRangeError(void *loc, const Reloc &, const llvm::Twine &v,
                      uint8_t bits, int64_t min, uint64_t max);

struct SymbolDiagnostic {};

void reportRangeError(void *loc, SymbolDiagnostic, const llvm::Twine &v,
                      uint8_t bits, int64_t min, uint64_t max);

template <typename Diagnostic>
inline void checkInt(void *loc, Diagnostic d, int64_t v, int bits) {}

template <typename Diagnostic>
inline void checkUInt(void *loc, Diagnostic d, uint64_t v, int bits) {}

inline void writeAddress(uint8_t *loc, uint64_t addr, uint8_t length) {}

InputSection *offsetToInputSection(uint64_t *);

extern const RelocAttrs invalidRelocAttrs;

} // namespace lld::Macho

#endif