238 bool Displace(
const Displacement& displacement);
337 std::ostream& operator<<(std::ostream& out,
const Relocation& relocation);
Represents a single offset within a section, or an absolute location in memory if the section is null...
Definition location.h:17
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
A representation of a value within some binary data that has to be fixed up once the exact position o...
Definition relocation.h:28
static Relocation Paragraph(Location source, Target target, uint64_t addend=0)
Creates a relocation that stores the 16-bit paragraph (shifted right by 4) of the target (Intel 8086 ...
Definition relocation.cc:56
static Relocation GOTEntryOffset(size_t size, Location source, SymbolName target, uint64_t addend, EndianType endiantype)
Creates a relocation that references the offset of a GOT entry from the start of the GOT.
Definition relocation.cc:90
Location source
The location where the value of the symbol should be stored.
Definition relocation.h:90
bool Resolve(Module &object, Resolution &resolution)
If the target and reference symbols can be resolved, return the value with some additional informatio...
Definition relocation.cc:125
static Relocation Offset(size_t size, Location source, Target target, uint64_t addend, EndianType endiantype)
Creates a relocation that references the offset of a target within its preferred segment (Intel 8086 ...
Definition relocation.cc:24
enum Linker::Relocation::reference_kind kind
Specifies the way the target is used to derive the resolved value, typically Direct.
static Relocation Relative(size_t size, Location source, Target target, uint64_t addend, EndianType endiantype)
Creates a relocation that references the offset of a target from the source.
Definition relocation.cc:46
void AddCurrentValue()
Updates the addend with the value stored in the section data.
Definition relocation.cc:208
reference_kind
Definition relocation.h:31
@ SegmentIndex
The 8-bit segment of value is used, obtained via shifting it by 16 to the right.
Definition relocation.h:45
@ TransitionVector
A transition vector in a transition vector table is used instead of the actual value.
Definition relocation.h:73
@ GOTEntry
An entry in the Global Offset Table is used instead of the actual value.
Definition relocation.h:55
@ FarTableEntry
A far entry in an entry table is used instead of the actual value.
Definition relocation.h:67
@ ParagraphAddress
The paragraph of value is used, obtained via shifting it by 4 to the right.
Definition relocation.h:39
@ SelectorIndex
A selector index is used to reference this target.
Definition relocation.h:51
@ PLTEntry
An entry in the Procedure Linkage Table is used instead of the actual value.
Definition relocation.h:59
@ Direct
The value of the target is used.
Definition relocation.h:33
@ TableEntry
An entry in an entry table is used instead of the actual value.
Definition relocation.h:63
@ SizeOf
Size of the target.
Definition relocation.h:77
Relocation & SetSubtract(bool to_subtract=true)
The value stored in the word must be negated before adding the addend and storing.
Definition relocation.cc:108
bool Combine(const Relocation &other)
Attempts to combine two relocations.
Definition relocation.cc:278
EndianType endiantype
The endianness of the stored value.
Definition relocation.h:110
bool adjusted_shift
Add 1 to the value if the last shifted bit is set, used for PowerPC "high adjusted" relocation types.
Definition relocation.h:118
int64_t ReadSigned()
Accesses the value within the section data.
Definition relocation.cc:181
Target target
The symbol or location referenced by the relocation.
Definition relocation.h:94
static Relocation ParagraphDifference(Location source, Target target, Target reference, uint64_t addend=0)
Creates a relocation that stores the 16-bit paragraph difference (shifted right by 4) between the tar...
Definition relocation.cc:74
static Relocation Absolute(size_t size, Location source, Target target, uint64_t addend, EndianType endiantype)
Creates a relocation referencing the absolute address of a target.
Definition relocation.cc:14
static Relocation GOTEntryRelative(size_t size, Location source, SymbolName target, uint64_t addend, EndianType endiantype)
Creates a relocation that references the offset of a GOT entry from the source.
Definition relocation.cc:85
void ConvertToTransitionVector(Target target_code, Target target_data)
Modifies the relocation to point to a transition vector consisting of a code and data address.
Definition relocation.cc:272
Relocation & SetMask(uint64_t new_mask)
Instead of the full word, only modify the following bits.
Definition relocation.cc:95
uint64_t addend
A value to be added.
Definition relocation.h:106
void ConvertToSegment(bool protected_mode, Target segment_target)
Modifies the relocation to be a reference to a paragraph address or selector index (x86)
Definition relocation.cc:262
Target reference
The symbol or location whose value is subtracted from the final value, used for self-relative and seg...
Definition relocation.h:98
uint64_t mask
The bitmask of the value within the word.
Definition relocation.h:122
static Relocation GOTEntryAbsolute(size_t size, Location source, SymbolName target, uint64_t addend, EndianType endiantype)
Creates a relocation referencing the absolute address of a GOT entry.
Definition relocation.cc:80
Relocation & SetShift(int new_shift, bool adjusted=false)
The value stored in the word must be shifted by this to give the actual value.
Definition relocation.cc:101
bool Displace(const Displacement &displacement)
Recalculates the source, target and reference locations after a section has moved.
Definition relocation.cc:114
void WriteWord(uint64_t value)
Accesses the value within the section data.
Definition relocation.cc:192
bool IsAbsolute() const
Determines if a relocation is an absolute relocation whose reference is the absolute 0 address.
Definition relocation.cc:223
std::optional< Target > secondary_target
The symbol or location for a secondary target, used for the data address of a transition vector.
Definition relocation.h:102
static Relocation OffsetFrom(size_t size, Location source, Target target, Target reference, uint64_t addend, EndianType endiantype)
Creates a relocation that references the offset of a target from a specific reference point.
Definition relocation.cc:36
bool IsOffset() const
Determines if a relocation is an offset relocation whose reference is their preferred segment.
Definition relocation.cc:228
bool subtract
Set to true if value must be negated first.
Definition relocation.h:126
static Relocation Empty()
Creates an empty relocation.
Definition relocation.cc:9
void ReplaceTarget(Target new_target)
Modifies the relocation to have a different target.
Definition relocation.cc:233
bool IsRelative() const
Determines if a relocation is self-relative.
Definition relocation.cc:214
uint64_t ReadUnsigned()
Accesses the value within the section data.
Definition relocation.cc:170
size_t size
The size of the value when stored at the source, in bytes (for example, 2 for 16-bit,...
Definition relocation.h:86
int shift
The amount of bits the value should be shifted by.
Definition relocation.h:114
void ConvertTo(reference_kind new_kind, Target new_target)
Modifies the relocation to be a reference of the specified kind.
Definition relocation.cc:247
void ConvertToParagraphDifference(Target new_target, Target new_reference)
Modifies the relocation to be a paragraph difference between new_target and new_reference.
Definition relocation.cc:267
Representing a resolved relocation.
Definition resolution.h:17
A class representing a sequence of sections that must be written to the output file as a group.
Definition segment.h:25
Represents an (imported or internal) symbol name, which can be more complex than a string.
Definition symbol_name.h:18
Represents a possible target or reference frame of a relocation.
Definition target.h:24