File indexing completed on 2026-05-10 08:43:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CODEGEN_MACHORELOCATION_H
0015 #define LLVM_CODEGEN_MACHORELOCATION_H
0016
0017 #include "llvm/Support/DataTypes.h"
0018
0019 namespace llvm {
0020
0021
0022
0023
0024 class MachORelocation {
0025 uint32_t r_address;
0026 uint32_t r_symbolnum;
0027 bool r_pcrel;
0028 uint8_t r_length;
0029 bool r_extern;
0030 uint8_t r_type;
0031 bool r_scattered;
0032 int32_t r_value;
0033
0034 public:
0035 uint32_t getPackedFields() const {
0036 if (r_scattered)
0037 return (1 << 31) | (r_pcrel << 30) | ((r_length & 3) << 28) |
0038 ((r_type & 15) << 24) | (r_address & 0x00FFFFFF);
0039 else
0040 return (r_symbolnum << 8) | (r_pcrel << 7) | ((r_length & 3) << 5) |
0041 (r_extern << 4) | (r_type & 15);
0042 }
0043 uint32_t getAddress() const { return r_scattered ? r_value : r_address; }
0044 uint32_t getRawAddress() const { return r_address; }
0045
0046 MachORelocation(uint32_t addr, uint32_t index, bool pcrel, uint8_t len,
0047 bool ext, uint8_t type, bool scattered = false,
0048 int32_t value = 0) :
0049 r_address(addr), r_symbolnum(index), r_pcrel(pcrel), r_length(len),
0050 r_extern(ext), r_type(type), r_scattered(scattered), r_value(value) {}
0051 };
0052
0053 }
0054
0055 #endif