6#include "../dumper/dumper.h"
7#include "../linker/module.h"
8#include "../linker/options.h"
9#include "../linker/segment.h"
10#include "../linker/segment_manager.h"
11#include "../linker/writer.h"
53 ::EndianType endiantype = ::UndefinedEndian;
164 static constexpr uint16_t MID_UNKNOWN = 0x000;
165 static constexpr uint16_t MID_68010 = 0x001;
166 static constexpr uint16_t MID_68020 = 0x002;
167 static constexpr uint16_t MID_PC386 = 0x064;
168 static constexpr uint16_t MID_I386 = 0x086;
169 static constexpr uint16_t MID_ARM6 = 0x08F;
170 static constexpr uint16_t MID_MIPS1 = 0x097;
171 static constexpr uint16_t MID_MIPS2 = 0x098;
172 static constexpr uint16_t MID_HP200 = 0x0C8;
173 static constexpr uint16_t MID_HP300 = 0x12C;
174 static constexpr uint16_t MID_HPUX800 = 0x20B;
175 static constexpr uint16_t MID_HPUX = 0x20C;
178 static constexpr uint16_t MID_LINUX_OLDSUN2 = 0x000;
179 static constexpr uint16_t MID_LINUX_SPARC = 0x003;
182 static constexpr uint16_t MID_FREEBSD_SPARC = 0x08C;
185 static constexpr uint16_t MID_NETBSD_M68K = 0x087;
186 static constexpr uint16_t MID_NETBSD_M68K4K = 0x088;
187 static constexpr uint16_t MID_NETBSD_NS32532K = 0x089;
188 static constexpr uint16_t MID_NETBSD_SPARC = 0x08A;
189 static constexpr uint16_t MID_NETBSD_PMAX = 0x08B;
190 static constexpr uint16_t MID_NETBSD_VAX1K = 0x08C;
191 static constexpr uint16_t MID_NETBSD_ALPHA = 0x08D;
192 static constexpr uint16_t MID_NETBSD_MIPS = 0x08E;
193 static constexpr uint16_t MID_NETBSD_M680002K = 0x090;
194 static constexpr uint16_t MID_NETBSD_SH3 = 0x091;
195 static constexpr uint16_t MID_NETBSD_POWERPC64 = 0x094;
196 static constexpr uint16_t MID_NETBSD_POWERPC = 0x095;
197 static constexpr uint16_t MID_NETBSD_VAX = 0x096;
198 static constexpr uint16_t MID_NETBSD_M88K = 0x099;
199 static constexpr uint16_t MID_NETBSD_HPPA = 0x09A;
200 static constexpr uint16_t MID_NETBSD_SH5_64 = 0x09B;
201 static constexpr uint16_t MID_NETBSD_SPARC64 = 0x09C;
202 static constexpr uint16_t MID_NETBSD_X86_64 = 0x09D;
203 static constexpr uint16_t MID_NETBSD_SH5_32 = 0x09E;
204 static constexpr uint16_t MID_NETBSD_IA64 = 0x09F;
205 static constexpr uint16_t MID_NETBSD_AARCH64 = 0x0B7;
206 static constexpr uint16_t MID_NETBSD_OR1K = 0x0B8;
207 static constexpr uint16_t MID_NETBSD_RISCV = 0x0B9;
209 static constexpr uint16_t MID_BFD_ARM = 0x067;
251 cpu_type cpu = UNKNOWN;
259 uint32_t code_size = 0;
260 uint32_t data_size = 0;
261 uint32_t bss_size = 0;
262 uint32_t symbol_table_size = 0;
263 uint32_t entry_address = 0;
264 uint32_t code_relocation_size = 0;
265 uint32_t data_relocation_size = 0;
266 std::map<uint32_t, uint32_t> code_relocations, data_relocations;
268 std::shared_ptr<Linker::Image> code, data, bss;
271 bool AttemptFetchMagic(uint8_t signature[4]);
275 bool AttemptReadFile(
Linker::Reader& rd, uint8_t signature[4], offset_t image_size);
282 uint16_t unknown = 0;
283 uint16_t name_offset = 0;
288 std::vector<Symbol> symbols;
290 mutable uint32_t page_size = 0;
292 uint32_t GetPageSize()
const;
293 uint32_t GetTextOffset()
const;
294 uint32_t GetTextAddress()
const;
295 uint32_t GetDataOffsetAlign()
const;
296 uint32_t GetDataAddressAlign()
const;
329 InitializeFields(stub);
336 static std::vector<Linker::OptionDescription<void> *> ParameterNames;
339 std::shared_ptr<Linker::OptionCollector>
GetOptions()
override;
341 void SetOptions(std::map<std::string, std::string>& options)
override;
343 void OnNewSegment(std::shared_ptr<Linker::Segment> segment)
override;
345 void CreateDefaultSegments();
351 std::shared_ptr<Linker::Segment> GetCodeSegment();
353 std::shared_ptr<Linker::Segment> GetDataSegment();
355 std::shared_ptr<Linker::Segment> GetBssSegment();
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:586
Encodes an object module file as a collection of sections, symbols and relocations.
Definition module.h:24
Helper class that contains the options interpreted by the format.
Definition options.h:467
Documents and handles command line options.
Definition options.h:303
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:16
A helper class to collect sections into segments.
Definition segment_manager.h:32
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15