RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
target.h
1#ifndef TARGET_H
2#define TARGET_H
3
4#include <iostream>
5#include <variant>
6#include "../common.h"
7#include "location.h"
8#include "symbol.h"
9
10namespace Linker
11{
12 class Module;
13
23 class Target
24 {
25 public:
29 std::variant<Location, SymbolName> target;
34
35 Target(std::variant<Location, SymbolName> target = Location(), bool segment_of = false)
37 {
38 }
39
40 Target(Location location, bool segment_of = false)
41 : target(location), segment_of(segment_of)
42 {
43 /* Note: when resolved, the segment starts at the location section start */
44 }
45
46 Target(SymbolName symbol, bool segment_of = false)
47 : target(symbol), segment_of(segment_of)
48 {
49 }
50
56 Target GetSegment();
57
64 bool Displace(const Displacement& displacement);
65
71 bool ResolveLocals(Module& object);
72
80 bool Lookup(Module& object, Position& position);
81 };
82
83 bool operator==(const Target& a, const Target& b);
84
85 bool operator!=(const Target& a, const Target& b);
86
87 std::ostream& operator<<(std::ostream& out, const Target& target);
88}
89
90#endif /* TARGET_H */
Represents a single offset within a section, or an absolute location in memory if the section is null...
Definition location.h:17
Represents a possible target or reference frame of a relocation.
Definition target.h:24
bool ResolveLocals(Module &object)
If the target refers to an internal symbol, it gets resolved to a location.
Definition target.cc:21
bool segment_of
Whether the target is the segment, rather than the offset, of the location or symbol.
Definition target.h:33
std::variant< Location, SymbolName > target
The actual target, either an internal/absolute location, or an imported symbol.
Definition target.h:29
Target GetSegment()
Creates a new target that references the segment of this target.
Definition target.cc:7
bool Displace(const Displacement &displacement)
Recalculates target after a section has moved.
Definition target.cc:12
bool Lookup(Module &object, Position &position)
Returns a Position object for locations and internal symbols, if possible.
Definition target.cc:42