| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_CODEGEN_MACHORELOCATION_H |
| 15 |
#define LLVM_CODEGEN_MACHORELOCATION_H |
| 16 |
|
| 17 |
#include "llvm/Support/DataTypes.h" |
| 18 |
|
| 19 |
namespace llvm { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
class MachORelocation { |
| 25 |
uint32_t r_address; |
| 26 |
uint32_t r_symbolnum; |
| 27 |
bool r_pcrel; |
| 28 |
uint8_t r_length; |
| 29 |
bool r_extern; |
| 30 |
uint8_t r_type; |
| 31 |
bool r_scattered; |
| 32 |
int32_t r_value; |
| 33 |
|
| 34 |
public: |
| 35 |
uint32_t getPackedFields() const { |
| 36 |
if (r_scattered) |
| 37 |
return (1 << 31) | (r_pcrel << 30) | ((r_length & 3) << 28) | |
| 38 |
((r_type & 15) << 24) | (r_address & 0x00FFFFFF); |
| 39 |
else |
| 40 |
return (r_symbolnum << 8) | (r_pcrel << 7) | ((r_length & 3) << 5) | |
| 41 |
(r_extern << 4) | (r_type & 15); |
| 42 |
} |
| 43 |
uint32_t getAddress() const { return r_scattered ? r_value : r_address; } |
| 44 |
uint32_t getRawAddress() const { return r_address; } |
| 45 |
|
| 46 |
MachORelocation(uint32_t addr, uint32_t index, bool pcrel, uint8_t len, |
| 47 |
bool ext, uint8_t type, bool scattered = false, |
| 48 |
int32_t value = 0) : |
| 49 |
r_address(addr), r_symbolnum(index), r_pcrel(pcrel), r_length(len), |
| 50 |
r_extern(ext), r_type(type), r_scattered(scattered), r_value(value) {} |
| 51 |
}; |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
#endif |