diff options
author | Oxore <oxore@protonmail.com> | 2023-06-04 21:58:39 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-06-04 23:26:13 +0300 |
commit | a3f3fb052678b9cf1f80bbdc72c42afc3705ac0b (patch) | |
tree | f45953c256f4e463f073afcdc920c916afc4c0d1 /common.h | |
parent | b5c24afbc10a36f65e73d5ef2100da4ff173a109 (diff) |
Add initial support of ELF files
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,7 +1,16 @@ +#pragma once + /* SPDX-License-Identifier: Unlicense */ -#pragma once +#include <cstddef> +#include <cstdint> + +enum class BFDTarget { + kAuto, + kBinary, + kELF, +}; struct Settings { bool raw_data_comment{}; @@ -16,6 +25,7 @@ struct Settings { bool xrefs_to{}; bool xrefs_from{}; bool imm_hex{}; + BFDTarget bfd{}; const char *indent{"\t"}; }; @@ -54,17 +64,17 @@ constexpr size_t kDisasmMapSizeElements = kRomSizeBytes / kInstructionSizeStepBy static inline constexpr size_t Min(size_t a, size_t b) { return a < b ? a : b; } -static inline constexpr uint16_t GetU16BE(uint8_t *buffer) +static inline constexpr uint16_t GetU16BE(const uint8_t *buffer) { return (static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]); } -static inline constexpr int16_t GetI16BE(uint8_t *buffer) +static inline constexpr int16_t GetI16BE(const uint8_t *buffer) { return (static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]); } -static inline constexpr int32_t GetI32BE(uint8_t *buffer) +static inline constexpr int32_t GetI32BE(const uint8_t *buffer) { return (static_cast<uint32_t>(buffer[0]) << 24) | (static_cast<uint32_t>(buffer[1]) << 16) | |