RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
location.h
1#ifndef LOCATION_H
2#define LOCATION_H
3
4#include <iostream>
5#include <memory>
6#include "../common.h"
7#include "position.h"
8
9namespace Linker
10{
11 class Section;
12
17 {
18 public:
22 std::shared_ptr<Section> section;
26 offset_t offset;
27
31 Location(std::shared_ptr<Section> section, offset_t offset = 0)
33 {
34 }
35
39 Location(offset_t offset = 0)
40 : section(nullptr), offset(offset)
41 {
42 }
43
51 bool Displace(const Displacement& displacement);
52
61 Position GetPosition(bool segment_of = false) const;
62
63 bool operator==(const Location& other) const;
64
65 Location& operator+=(offset_t value);
66
67 Location& operator-=(offset_t value);
68 };
69
70 Location operator+(Location a, offset_t b);
71 Location operator-(Location a, offset_t b);
72 std::ostream& operator<<(std::ostream& out, const Location& location);
73}
74
75#endif /* LOCATION_H */
Represents a single offset within a section, or an absolute location in memory if the section is null...
Definition location.h:17
offset_t offset
The offset of the symbol within a section, or the absolute address.
Definition location.h:26
std::shared_ptr< Section > section
The section the symbol is located in, or null for an absolute location.
Definition location.h:22
Location(std::shared_ptr< Section > section, offset_t offset=0)
Creates a location within a section.
Definition location.h:31
Location(offset_t offset=0)
Creates an absolute location.
Definition location.h:39
Position GetPosition(bool segment_of=false) const
Calculates the address.
Definition location.cc:22
bool Displace(const Displacement &displacement)
Recalculates location after a section has moved.
Definition location.cc:8
Stores an absolute address along with the containing segment or address space.
Definition position.h:17