From a3f3fb052678b9cf1f80bbdc72c42afc3705ac0b Mon Sep 17 00:00:00 2001 From: Oxore Date: Sun, 4 Jun 2023 21:58:39 +0300 Subject: Add initial support of ELF files --- common.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'common.h') diff --git a/common.h b/common.h index 97dfe7c..dddde52 100644 --- a/common.h +++ b/common.h @@ -1,7 +1,16 @@ +#pragma once + /* SPDX-License-Identifier: Unlicense */ -#pragma once +#include +#include + +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(buffer[0]) << 8) | static_cast(buffer[1]); } -static inline constexpr int16_t GetI16BE(uint8_t *buffer) +static inline constexpr int16_t GetI16BE(const uint8_t *buffer) { return (static_cast(buffer[0]) << 8) | static_cast(buffer[1]); } -static inline constexpr int32_t GetI32BE(uint8_t *buffer) +static inline constexpr int32_t GetI32BE(const uint8_t *buffer) { return (static_cast(buffer[0]) << 24) | (static_cast(buffer[1]) << 16) | -- cgit v1.2.3