summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-12-19 11:12:20 -0800
committerMark Rowe <mark@vector35.com>2025-12-20 21:34:49 -0800
commited0f3b1b8593f6b76fbb64c53a0885073c1c1979 (patch)
tree5d22d77ccea8bffc0619a32ed886d79d14daccf1
parentba13f6ec7d0ce9a18a03a1c895fb72d18e03014a (diff)
Fix many of the warnings that show up when compiling with GCC 15.2
-rw-r--r--arch/arm64/disassembler/decode_scratchpad.c9
-rw-r--r--arch/arm64/disassembler/format.c3
-rw-r--r--arch/arm64/disassembler/pcode.c40
-rw-r--r--arch/arm64/il.cpp56
-rw-r--r--arch/armv7/CMakeLists.txt7
-rw-r--r--arch/armv7/il.cpp2
-rw-r--r--arch/mips/arch_mips.cpp3
-rw-r--r--arch/mips/il.cpp2
-rw-r--r--arch/mips/mips/mips.c3
-rw-r--r--arch/mips/mips/test.c13
-rw-r--r--arch/powerpc/arch_ppc.cpp6
-rw-r--r--arch/powerpc/disassembler.cpp7
-rw-r--r--examples/background_task/src/backgroundtask.cpp2
-rw-r--r--examples/cmdline_disasm/src/disasm.cpp1
-rw-r--r--lang/c/pseudoc.cpp60
-rw-r--r--objectivec/objc.cpp2
-rw-r--r--plugins/efi_resolver/src/Resolver.cpp36
-rw-r--r--plugins/efi_resolver/src/TypePropagation.cpp4
-rw-r--r--plugins/rtti/itanium.cpp32
-rw-r--r--plugins/rtti/microsoft.cpp40
-rw-r--r--view/kernelcache/core/KernelCache.cpp2
-rw-r--r--view/kernelcache/core/KernelCacheView.cpp2
-rw-r--r--view/kernelcache/core/KernelCacheView.h2
-rw-r--r--view/kernelcache/core/MachO.cpp6
-rw-r--r--view/macho/machoview.cpp2
-rw-r--r--view/sharedcache/core/SharedCacheController.cpp3
-rw-r--r--view/sharedcache/core/SharedCacheController.h4
-rw-r--r--view/sharedcache/core/SharedCacheView.cpp2
-rw-r--r--view/sharedcache/core/SharedCacheView.h2
29 files changed, 175 insertions, 178 deletions
diff --git a/arch/arm64/disassembler/decode_scratchpad.c b/arch/arm64/disassembler/decode_scratchpad.c
index f869889f..d1160980 100644
--- a/arch/arm64/disassembler/decode_scratchpad.c
+++ b/arch/arm64/disassembler/decode_scratchpad.c
@@ -1086,9 +1086,12 @@ static const char* const reg_lookup_c[16] = {"c0", "c1", "c2", "c3", "c4", "c5",
i++;
#define ADD_OPERAND_FLOAT32(VALUE) \
- instr->operands[i].operandClass = FIMM32; \
- *(float*)&(instr->operands[i].immediate) = VALUE; \
- i++;
+ do { \
+ float value = VALUE; \
+ instr->operands[i].operandClass = FIMM32; \
+ memcpy(&instr->operands[i].immediate, &value, sizeof(float)); \
+ i++; \
+ } while (0)
#define ADD_OPERAND_CONST ADD_OPERAND_IMM64(const_, 0)
#define ADD_OPERAND_FBITS ADD_OPERAND_IMM32(fbits, 0)
diff --git a/arch/arm64/disassembler/format.c b/arch/arm64/disassembler/format.c
index 0db5ffbc..73f82a6f 100644
--- a/arch/arm64/disassembler/format.c
+++ b/arch/arm64/disassembler/format.c
@@ -383,7 +383,8 @@ uint32_t get_shifted_immediate(const InstructionOperand *instructionOperand, cha
}
if (type == FIMM32)
{
- float f = *(const float*)&instructionOperand->immediate;
+ float f = 0.0f;
+ memcpy(&f, &instructionOperand->immediate, sizeof(float));
if (snprintf(outBuffer, outBufferSize, "#%.08f%s", f, shiftBuff) >= outBufferSize)
return FAILED_TO_DISASSEMBLE_OPERAND;
}
diff --git a/arch/arm64/disassembler/pcode.c b/arch/arm64/disassembler/pcode.c
index 7993e312..46ffdcec 100644
--- a/arch/arm64/disassembler/pcode.c
+++ b/arch/arm64/disassembler/pcode.c
@@ -584,37 +584,29 @@ uint64_t Replicate(uint64_t val, uint8_t times, uint64_t width)
https://github.com/Siguza/iometa/blob/master/src/a64.c */
uint64_t AdvSIMDExpandImm(uint8_t op, uint8_t cmode, uint64_t imm8)
{
- uint64_t imm64;
switch ((cmode >> 1) & 0b111)
{
case 0b000:
- imm64 = Replicate(imm8, 2, 32);
- break;
+ return Replicate(imm8, 2, 32);
case 0b001:
- imm64 = Replicate(imm8 << 8, 2, 32);
- break;
+ return Replicate(imm8 << 8, 2, 32);
case 0b010:
- imm64 = Replicate(imm8 << 16, 2, 32);
- break;
+ return Replicate(imm8 << 16, 2, 32);
case 0b011:
- imm64 = Replicate(imm8 << 24, 2, 32);
- break;
+ return Replicate(imm8 << 24, 2, 32);
case 0b100:
- imm64 = Replicate(imm8, 4, 16);
- break;
+ return Replicate(imm8, 4, 16);
case 0b101:
- imm64 = Replicate(imm8 << 8, 4, 16);
- break;
+ return Replicate(imm8 << 8, 4, 16);
case 0b110:
- imm64 = Replicate(imm8 << (8 << (cmode & 0b1)), 2, 32);
- break;
+ return Replicate(imm8 << (8 << (cmode & 0b1)), 2, 32);
case 0b111:
switch (((cmode & 0b1) << 1) | op)
{
case 0b00:
- imm64 = Replicate(imm8, 8, 8);
- break;
+ return Replicate(imm8, 8, 8);
case 0b01:
+ {
#if 0
imm8a = Replicate((imm8 >> 7) & 0b1, 8, 1);
imm8b = Replicate((imm8 >> 6) & 0b1, 8, 1);
@@ -626,26 +618,24 @@ uint64_t AdvSIMDExpandImm(uint8_t op, uint8_t cmode, uint64_t imm8)
imm8h = Replicate((imm8 ) & 0b1, 8, 1);
imm64 = (imm8a << 0x38) | (imm8b << 0x30) | (imm8c << 0x28) | (imm8d << 0x20) | (imm8e << 0x18) | (imm8f << 0x10) | (imm8g << 0x08) | imm8h;
#else
- imm64 = imm8 | (imm8 << (0x08 - 1)) | (imm8 << (0x10 - 2)) | (imm8 << (0x18 - 3)) |
+ uint64_t imm64 = imm8 | (imm8 << (0x08 - 1)) | (imm8 << (0x10 - 2)) | (imm8 << (0x18 - 3)) |
(imm8 << (0x20 - 4)) | (imm8 << (0x28 - 5)) | (imm8 << (0x30 - 6)) |
(imm8 << (0x38 - 7));
imm64 &= 0x0101010101010101;
- imm64 = Replicate(imm64, 8, 1);
+ return Replicate(imm64, 8, 1);
#endif
- break;
+ }
case 0b10:
- imm64 = Replicate((((imm8 & 0xc0) ^ 0x80) << 24) |
+ return Replicate((((imm8 & 0xc0) ^ 0x80) << 24) |
(Replicate((imm8 >> 6) & 0b1, 5, 1) << 25) | ((imm8 & 0x3f) << 19),
2, 32);
- break;
case 0b11:
- imm64 = (((imm8 & 0xc0) ^ 0x80) << 56) | (Replicate((imm8 >> 6) & 0b1, 8, 1) << 54) |
+ return (((imm8 & 0xc0) ^ 0x80) << 56) | (Replicate((imm8 >> 6) & 0b1, 8, 1) << 54) |
((imm8 & 0x3f) << 48);
- break;
}
break;
}
- return imm64;
+ return 0;
}
bool BTypeCompatible_BTI(uint8_t hintcode, uint8_t pstate_btype)
diff --git a/arch/arm64/il.cpp b/arch/arm64/il.cpp
index bbec5959..f02cdd2d 100644
--- a/arch/arm64/il.cpp
+++ b/arch/arm64/il.cpp
@@ -174,9 +174,9 @@ static ExprId GetFloat(LowLevelILFunction& il, InstructionOperand& operand, int
case 2:
return il.FloatConstRaw(2, operand.immediate);
case 4:
- return il.FloatConstSingle(*(float*)&(operand.immediate));
+ return il.FloatConstSingle(std::bit_cast<float>(static_cast<uint32_t>(operand.immediate)));
case 8:
- return il.FloatConstDouble(*(float*)&(operand.immediate));
+ return il.FloatConstDouble(std::bit_cast<double>(operand.immediate));
default:
break;
}
@@ -851,7 +851,7 @@ static void LoadStoreVector(
for (int i = 0; i < regs_n; ++i)
{
int reg_spec_base = (oper0.reg[0] + i - REG_V0) * (16 / arrspec_size) + lane;
- Register reg;
+ Register reg = REG_NONE;
switch (arrspec_size)
{
case 1:
@@ -1343,7 +1343,7 @@ bool GetLowLevelILForInstruction(
case ENC_ADD_Z_ZZ_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
default: break;
}
case ARM64_ADDS:
@@ -1372,7 +1372,7 @@ bool GetLowLevelILForInstruction(
case ENC_ANDS_P_P_PP_Z:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
default: break;
}
il.AddInstruction(
@@ -1387,7 +1387,7 @@ bool GetLowLevelILForInstruction(
case ENC_ADR_Z_AZ_D_U32_SCALED:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
default: break;
}
case ARM64_ADRP:
@@ -1403,7 +1403,7 @@ bool GetLowLevelILForInstruction(
case ENC_ASR_Z_ZW_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
default: break;
}
il.AddInstruction(ILSETREG_O(operand1, il.ArithShiftRight(REGSZ_O(operand2), ILREG_O(operand2),
@@ -1415,7 +1415,7 @@ bool GetLowLevelILForInstruction(
case ENC_AESD_Z_ZZ_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
default: break;
}
il.AddInstruction(il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_AESD,
@@ -1427,8 +1427,8 @@ bool GetLowLevelILForInstruction(
case ENC_AESE_Z_ZZ_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
- default: break;
+ return true;
+ default: break;
}
il.AddInstruction(il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_AESE,
{ILREG_O(operand1), ILREG_O(operand2)}));
@@ -1439,8 +1439,8 @@ bool GetLowLevelILForInstruction(
case ENC_AESIMC_Z_Z_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
- default: break;
+ return true;
+ default: break;
}
il.AddInstruction(il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_AESIMC,
{ILREG_O(operand1), ILREG_O(operand2)}));
@@ -1451,8 +1451,8 @@ bool GetLowLevelILForInstruction(
case ENC_AESMC_Z_Z_:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
- default: break;
+ return true;
+ default: break;
}
il.AddInstruction(il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_AESMC,
{ILREG_O(operand1), ILREG_O(operand2)}));
@@ -1571,7 +1571,7 @@ bool GetLowLevelILForInstruction(
case ENC_BICS_P_P_PP_Z:
if (!preferIntrinsics())
il.AddInstruction(il.Unimplemented());
- return true;
+ return true;
case ENC_BIC_ASIMDIMM_L_HL:
case ENC_BIC_ASIMDIMM_L_SL:
il.AddInstruction(ILSETREG_O(operand1,
@@ -2962,9 +2962,9 @@ bool GetLowLevelILForInstruction(
case ENC_NEG_ASIMDMISC_R:
case ENC_NEG_Z_P_Z_M:
case ENC_NEG_Z_P_Z_Z:
- if (!preferIntrinsics())
- il.AddInstruction(il.Unimplemented());
- return true;
+ if (!preferIntrinsics())
+ il.AddInstruction(il.Unimplemented());
+ return true;
default: break;
}
case ARM64_NEGS:
@@ -3098,8 +3098,8 @@ bool GetLowLevelILForInstruction(
{
case ENC_ORN_Z_ZI__ORR_Z_ZI_:
case ENC_ORN_P_P_PP_Z:
- if (!preferIntrinsics())
- il.AddInstruction(il.Unimplemented());
+ if (!preferIntrinsics())
+ il.AddInstruction(il.Unimplemented());
return true;
default: break;
}
@@ -3588,11 +3588,11 @@ bool GetLowLevelILForInstruction(
case ARM64_STR:
switch (instr.encoding)
{
- case ENC_STR_P_BI_:
- case ENC_STR_Z_BI_:
- case ENC_STR_ZA_RI_:
- if (!preferIntrinsics())
- il.AddInstruction(il.Unimplemented());
+ case ENC_STR_P_BI_:
+ case ENC_STR_Z_BI_:
+ case ENC_STR_ZA_RI_:
+ if (!preferIntrinsics())
+ il.AddInstruction(il.Unimplemented());
return true;
default: break;
}
@@ -3619,9 +3619,9 @@ bool GetLowLevelILForInstruction(
case ENC_SUB_Z_P_ZZ_:
case ENC_SUB_Z_ZI_:
case ENC_SUB_Z_ZZ_:
- if (!preferIntrinsics())
- il.AddInstruction(il.Unimplemented());
- return true;
+ if (!preferIntrinsics())
+ il.AddInstruction(il.Unimplemented());
+ return true;
default: break;
}
case ARM64_SUBS:
diff --git a/arch/armv7/CMakeLists.txt b/arch/armv7/CMakeLists.txt
index 802bcf6a..25847dfe 100644
--- a/arch/armv7/CMakeLists.txt
+++ b/arch/armv7/CMakeLists.txt
@@ -43,3 +43,10 @@ if(BN_INTERNAL_BUILD)
LIBRARY_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR}
RUNTIME_OUTPUT_DIRECTORY ${BN_CORE_PLUGIN_DIR})
endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_options(arch_armv7 PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
+ )
+endif()
+
diff --git a/arch/armv7/il.cpp b/arch/armv7/il.cpp
index 0d79bcf6..5e2ee010 100644
--- a/arch/armv7/il.cpp
+++ b/arch/armv7/il.cpp
@@ -906,7 +906,7 @@ bool GetLowLevelILForArmInstruction(Architecture* arch, uint64_t addr, LowLevelI
}
if (op1.flags.wb)
{
- ExprId wb;
+ ExprId wb = BN_INVALID_OPERAND;
switch (instr.operation)
{
case ARMV7_LDM:
diff --git a/arch/mips/arch_mips.cpp b/arch/mips/arch_mips.cpp
index 0853f9fb..83d7a98d 100644
--- a/arch/mips/arch_mips.cpp
+++ b/arch/mips/arch_mips.cpp
@@ -811,6 +811,7 @@ public:
if (operation_name == NULL)
return false;
strncpy(operation, operation_name, sizeof(operation));
+ operation[sizeof(operation) - 1] = '\0';
if (instr.operands[0].operandClass == V_DEST)
{
@@ -3574,7 +3575,7 @@ public:
break;
default:
result[i].type = UnhandledRelocation;
- LogWarn("Unsupported relocation type: %llu (%s) @0x%llX", result[i].nativeType,
+ LogWarn("Unsupported relocation type: %" PRIu64 " (%s) @0x%" PRIx64, result[i].nativeType,
GetRelocationString((ElfMipsRelocationType)result[i].nativeType), result[i].address);
}
}
diff --git a/arch/mips/il.cpp b/arch/mips/il.cpp
index 5700acbc..1d10d9dd 100644
--- a/arch/mips/il.cpp
+++ b/arch/mips/il.cpp
@@ -3176,7 +3176,7 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
case MIPS_LDC2:
case MIPS_LDC3:
{
- unsigned cop;
+ unsigned cop = 0;
switch (instr.operation)
{
case MIPS_LDC1: cop = 1; break;
diff --git a/arch/mips/mips/mips.c b/arch/mips/mips/mips.c
index ee323f9d..37c56513 100644
--- a/arch/mips/mips/mips.c
+++ b/arch/mips/mips/mips.c
@@ -3580,6 +3580,7 @@ uint32_t mips_disassemble(
const char* reg = NULL;
strncpy(operation, OperationStrings[instruction->operation], sizeof(operation));
+ operation[sizeof(operation) - 1] = '\0';
if (instruction->operands[0].operandClass == V_DEST)
{
char* p = dest;
@@ -3744,7 +3745,7 @@ uint32_t mips_decompose(
const uint32_t* instructionValue,
size_t size,
Instruction* restrict instruction,
- uint32_t version,
+ MipsVersion version,
uint64_t address,
uint32_t endianBig,
uint32_t flags)
diff --git a/arch/mips/mips/test.c b/arch/mips/mips/test.c
index 339126e0..00034142 100644
--- a/arch/mips/mips/test.c
+++ b/arch/mips/mips/test.c
@@ -110,11 +110,11 @@ int main(int ac, char **av)
baseaddr = 0;
if (0 == disassemble(insword, baseaddr, version, flags, instxt))
{
- printf("%08llX: %08X %s\n", baseaddr, insword, instxt);
+ printf("%08" PRIX64 ": %08X %s\n", baseaddr, insword, instxt);
}
else
{
- printf("%08llX: %08X ??\n", baseaddr, insword);
+ printf("%08" PRIX64 ": %08X ??\n", baseaddr, insword);
}
// disassemble(0x14E00003, 0, version, flags, instxt);
if (version < MIPS_32)
@@ -124,11 +124,11 @@ int main(int ac, char **av)
baseaddr = 0x405a58;
if (0 == disassemble(insword, baseaddr, version, flags, instxt))
{
- printf("%08llX: %08X %s\n", baseaddr, insword, instxt);
+ printf("%08" PRIX64 ": %08X %s\n", baseaddr, insword, instxt);
}
else
{
- printf("%08llX: %08X ??\n", baseaddr, insword);
+ printf("%08" PRIX64 ": %08X ??\n", baseaddr, insword);
}
// disassemble(0x14E00003, 4, version, flags, instxt);
if (version < MIPS_32)
@@ -186,11 +186,11 @@ int main(int ac, char **av)
#endif
if (0 == disassemble(insword, baseaddr, version, flags, instxt))
{
- printf("%08llX: %08X %s\n", baseaddr, insword, instxt);
+ printf("%08" PRIX64 ": %08X %s\n", baseaddr, insword, instxt);
}
else
{
- printf("%08llX: %08X ??\n", baseaddr, insword);
+ printf("%08" PRIX64 ": %08X ??\n", baseaddr, insword);
}
baseaddr += 4;
p += 8;
@@ -202,3 +202,4 @@ int main(int ac, char **av)
cleanup:
return result;
}
+
diff --git a/arch/powerpc/arch_ppc.cpp b/arch/powerpc/arch_ppc.cpp
index f10757d5..a1605923 100644
--- a/arch/powerpc/arch_ppc.cpp
+++ b/arch/powerpc/arch_ppc.cpp
@@ -517,14 +517,14 @@ class PowerpcArchitecture: public Architecture
case PPC_OP_SIMM:
if (op->simm < 0 && op->simm > -0x10000)
- snprintf(buf, sizeof(buf), "-0x%llx", -op->simm);
+ snprintf(buf, sizeof(buf), "-0x%" PRIx64, -op->simm);
else
- snprintf(buf, sizeof(buf), "0x%llx", op->simm);
+ snprintf(buf, sizeof(buf), "0x%" PRIx64, op->simm);
result.emplace_back(IntegerToken, buf, op->simm, 4);
break;
case PPC_OP_LABEL:
- snprintf(buf, sizeof(buf), "0x%llx", op->label);
+ snprintf(buf, sizeof(buf), "0x%" PRIx64, op->label);
result.emplace_back(CodeRelativeAddressToken, buf, op->label, 4);
break;
diff --git a/arch/powerpc/disassembler.cpp b/arch/powerpc/disassembler.cpp
index 54e3c87c..e24f273b 100644
--- a/arch/powerpc/disassembler.cpp
+++ b/arch/powerpc/disassembler.cpp
@@ -1,7 +1,6 @@
#include <string>
-#include <vector>
#include "binaryninjaapi.h"
@@ -98,14 +97,14 @@ bool PushOperandTokens(string& result, const Operand* op)
case PPC_OP_SIMM:
if (op->simm < 0 && op->simm > -0x10000)
- snprintf(buf, sizeof(buf), "-0x%llx", -op->simm);
+ snprintf(buf, sizeof(buf), "-0x%" PRIx64, -op->simm);
else
- snprintf(buf, sizeof(buf), "0x%llx", op->simm);
+ snprintf(buf, sizeof(buf), "0x%" PRIx64, op->simm);
result += buf;
break;
case PPC_OP_LABEL:
- snprintf(buf, sizeof(buf), "0x%llx", op->label);
+ snprintf(buf, sizeof(buf), "0x%" PRIx64, op->label);
result += buf;
break;
diff --git a/examples/background_task/src/backgroundtask.cpp b/examples/background_task/src/backgroundtask.cpp
index 9b0a17be..29a1cf05 100644
--- a/examples/background_task/src/backgroundtask.cpp
+++ b/examples/background_task/src/backgroundtask.cpp
@@ -33,7 +33,7 @@ uint64_t InspireWriteCallback(uint8_t *data, uint64_t len, void *ctxt)
std::this_thread::sleep_for(std::chrono::seconds(3));
}
}
- } catch (Json::Exception e)
+ } catch (const Json::Exception& e)
{
LogError("JSON exception! %s", e.m_message.c_str());
inspireBackgroundTask->Cancel();
diff --git a/examples/cmdline_disasm/src/disasm.cpp b/examples/cmdline_disasm/src/disasm.cpp
index cd119dee..58e3a82b 100644
--- a/examples/cmdline_disasm/src/disasm.cpp
+++ b/examples/cmdline_disasm/src/disasm.cpp
@@ -1,7 +1,6 @@
#include <cstdio>
#include <cstdlib>
#include <cstdint>
-#include <cstdbool>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp
index 48763804..5a67eb40 100644
--- a/lang/c/pseudoc.cpp
+++ b/lang/c/pseudoc.cpp
@@ -430,27 +430,27 @@ PseudoCFunction::FieldDisplayType PseudoCFunction::GetFieldDisplayType(
std::optional<PseudoCFunction::TernaryInfo> PseudoCFunction::CanSimplifyToTernary(const BinaryNinja::HighLevelILInstruction &instr) const
{
- // Only handle if-statements
- if (instr.operation != HLIL_IF)
- return std::nullopt;
+ // Only handle if-statements
+ if (instr.operation != HLIL_IF)
+ return std::nullopt;
- auto conditionExpr = instr.GetConditionExpr<HLIL_IF>();
- auto trueExpr = instr.GetTrueExpr<HLIL_IF>();
- auto falseExpr = instr.GetFalseExpr<HLIL_IF>();
+ auto conditionExpr = instr.GetConditionExpr<HLIL_IF>();
+ auto trueExpr = instr.GetTrueExpr<HLIL_IF>();
+ auto falseExpr = instr.GetFalseExpr<HLIL_IF>();
if (GetHighLevelILFunction()->HasSideEffects(conditionExpr))
return std::nullopt;
- // Both branches must be assignment operations
- if (trueExpr.operation != HLIL_ASSIGN || falseExpr.operation != HLIL_ASSIGN)
- return std::nullopt;
+ // Both branches must be assignment operations
+ if (trueExpr.operation != HLIL_ASSIGN || falseExpr.operation != HLIL_ASSIGN)
+ return std::nullopt;
- // Get the destination expressions of the assignments
- auto trueDestExpr = trueExpr.GetDestExpr<HLIL_ASSIGN>();
- auto falseDestExpr = falseExpr.GetDestExpr<HLIL_ASSIGN>();
+ // Get the destination expressions of the assignments
+ auto trueDestExpr = trueExpr.GetDestExpr<HLIL_ASSIGN>();
+ auto falseDestExpr = falseExpr.GetDestExpr<HLIL_ASSIGN>();
- // Verify that the destination expressions are variable references
- if (trueDestExpr.operation != HLIL_VAR || falseDestExpr.operation != HLIL_VAR)
- return std::nullopt;
+ // Verify that the destination expressions are variable references
+ if (trueDestExpr.operation != HLIL_VAR || falseDestExpr.operation != HLIL_VAR)
+ return std::nullopt;
auto trueExprDestExpr = trueExpr.GetDestExpr<HLIL_ASSIGN>();
auto falseExprDestExpr = falseExpr.GetDestExpr<HLIL_ASSIGN>();
@@ -467,22 +467,22 @@ std::optional<PseudoCFunction::TernaryInfo> PseudoCFunction::CanSimplifyToTernar
if (GetHighLevelILFunction()->HasSideEffects(trueExprSourceExpr) || GetHighLevelILFunction()->HasSideEffects(falseExprSourceExpr))
return std::nullopt;
- // Avoid folding for "else if" cases
- for (auto parent = instr; parent.HasParent(); parent = parent.GetParent())
- {
- if (parent.operation != HLIL_IF)
- break;
- auto parentFalse = parent.GetFalseExpr<HLIL_IF>();
- if (parentFalse.operation == HLIL_IF)
- return std::nullopt;
- }
+ // Avoid folding for "else if" cases
+ for (auto parent = instr; parent.HasParent(); parent = parent.GetParent())
+ {
+ if (parent.operation != HLIL_IF)
+ break;
+ auto parentFalse = parent.GetFalseExpr<HLIL_IF>();
+ if (parentFalse.operation == HLIL_IF)
+ return std::nullopt;
+ }
- TernaryInfo info;
- info.conditional = conditionExpr;
- info.assignDest = trueDestExpr;
- info.trueAssign = trueExprSourceExpr;
- info.falseAssign = falseExprSourceExpr;
- return info;
+ TernaryInfo info;
+ info.conditional = conditionExpr;
+ info.assignDest = trueDestExpr;
+ info.trueAssign = trueExprSourceExpr;
+ info.falseAssign = falseExprSourceExpr;
+ return info;
}
bool PseudoCFunction::TryEmitSimplifiedTernary(
diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp
index 170cd78a..2a9a9439 100644
--- a/objectivec/objc.cpp
+++ b/objectivec/objc.cpp
@@ -218,7 +218,7 @@ std::vector<QualifiedNameOrType> ObjCProcessor::ParseEncodedType(const std::stri
std::string namedType;
int readingStructDepth = 0;
std::string structType;
- char last;
+ char last = 0;
for (char c : encodedType)
{
diff --git a/plugins/efi_resolver/src/Resolver.cpp b/plugins/efi_resolver/src/Resolver.cpp
index 9699b043..e501f35b 100644
--- a/plugins/efi_resolver/src/Resolver.cpp
+++ b/plugins/efi_resolver/src/Resolver.cpp
@@ -177,7 +177,7 @@ bool Resolver::parseUserGuidIfExists(const string& filePath)
auto guidBytes = element.value();
if (guidBytes.size() != 11)
{
- LogError("Error: GUID array size is incorrect for %s", guidName.c_str());
+ LogErrorF("Error: GUID array size is incorrect for {}", guidName);
return false;
}
EFI_GUID guid;
@@ -208,7 +208,7 @@ void Resolver::initProtocolMapping()
return;
auto fileName = GetBundledEfiPath();
if (!parseProtocolMapping(fileName))
- LogAlert("Binary Ninja Version Too Low. Please upgrade to a new version.");
+ LogAlertF("Binary Ninja Version Too Low. Please upgrade to a new version.");
fileName = GetUserGuidPath();
parseUserGuidIfExists(fileName);
@@ -223,7 +223,7 @@ bool Resolver::setModuleEntry(EFIModuleType fileType)
auto entryFunc = m_view->GetAnalysisFunction(m_view->GetDefaultPlatform(), entry);
if (!entryFunc)
{
- LogDebug("Entry func Not found... ");
+ LogDebugF("Entry func Not found... ");
return false;
}
@@ -232,14 +232,14 @@ bool Resolver::setModuleEntry(EFIModuleType fileType)
// Note: we only adjust the callsite in entry function, this is just a temp fix and it cannot cover all cases
auto callsites = entryFunc->GetCallSites();
- LogDebug("Checking callsites at 0x%llx", entryFunc->GetStart());
- LogDebug("callsite count : %zu", callsites.size());
+ LogDebugF("Checking callsites at {:#x}", entryFunc->GetStart());
+ LogDebugF("callsite count : {}", callsites.size());
for (auto callsite : entryFunc->GetCallSites())
{
auto mlil = entryFunc->GetMediumLevelIL();
size_t mlilIdx = mlil->GetInstructionStart(m_view->GetDefaultArchitecture(), callsite.addr);
auto instr = mlil->GetInstruction(mlilIdx);
- LogDebug("Checking Callsite at 0x%llx", callsite.addr);
+ LogDebugF("Checking Callsite at {:#x}", callsite.addr);
if (instr.operation == MLIL_CALL || instr.operation == MLIL_TAILCALL)
{
auto params = instr.GetParameterExprs();
@@ -255,16 +255,16 @@ bool Resolver::setModuleEntry(EFIModuleType fileType)
m_view->UpdateAnalysisAndWait();
}
else
- LogDebug("Operation not ConstPtr: %d", constantPtr.operation);
+ LogDebugF("Operation not ConstPtr: {}", constantPtr.operation);
}
else
- LogDebug("param size not zero");
+ LogDebugF("param size not zero");
}
}
string errors;
QualifiedNameAndType result;
- bool ok;
+ bool ok = false;
string typeString;
switch (fileType)
@@ -285,7 +285,7 @@ bool Resolver::setModuleEntry(EFIModuleType fileType)
case UNKNOWN:
{
- LogAlert("Could not identify EFI module type");
+ LogAlertF("Could not identify EFI module type");
return false;
}
}
@@ -467,7 +467,7 @@ bool Resolver::resolveGuidInterface(Ref<Function> func, uint64_t addr, int guidP
if (!found)
continue;
- LogInfo("Found EFI Protocol wrapper at 0x%llx, checking reference to this function", addr);
+ LogInfoF("Found EFI Protocol wrapper at {:#x}, checking reference to this function", addr);
auto refs = m_view->GetCodeReferences(func->GetStart());
for (auto& ref : refs)
@@ -503,7 +503,7 @@ bool Resolver::resolveGuidInterface(Ref<Function> func, uint64_t addr, int guidP
else
{
// use UnknownProtocol as defult
- LogWarn("Unknown EFI Protocol referenced at 0x%llx", addr);
+ LogWarnF("Unknown EFI Protocol referenced at {:#x}", addr);
guidName = nonConflictingName("UnknownProtocolGuid");
}
}
@@ -524,7 +524,7 @@ bool Resolver::resolveGuidInterface(Ref<Function> func, uint64_t addr, int guidP
if (protocol_name.empty())
{
- LogWarn("Found unknown protocol at 0x%llx", addr);
+ LogWarnF("Found unknown protocol at {:#x}", addr);
protocol_name = "VOID*";
}
@@ -617,7 +617,7 @@ bool Resolver::defineTypeAtCallsite(
ok = m_view->ParseTypeString(typeName, result, errors);
if (!ok)
{
- LogError("Cannot parse type %s when trying to define type at 0x%llx", typeName.c_str(), addr);
+ LogErrorF("Cannot parse type {} when trying to define type at {:#x}", typeName, addr);
return false;
}
@@ -721,9 +721,9 @@ pair<string, string> Resolver::defineAndLookupGuid(uint64_t addr)
if (readSize != 16)
return make_pair(string(), string());
}
- catch (ReadException)
+ catch (const ReadException&)
{
- LogError("Read GUID failed at 0x%llx", addr);
+ LogErrorF("Read GUID failed at {:#x}", addr);
return make_pair(string(), string());
}
auto namePair = lookupGuid(guidBytes);
@@ -741,12 +741,12 @@ pair<string, string> Resolver::defineAndLookupGuid(uint64_t addr)
if (guidName.empty())
{
m_view->DefineUserSymbol(new Symbol(DataSymbol, nonConflictingName("UnknownGuid"), addr));
- LogDebug("Found UnknownGuid at 0x%llx", addr);
+ LogDebugF("Found UnknownGuid at {:#x}", addr);
}
else
{
m_view->DefineUserSymbol(new Symbol(DataSymbol, guidName, addr));
- LogDebug("Define %s at 0x%llx", guidName.c_str(), addr);
+ LogDebugF("Define {} at {:#x}", guidName.c_str(), addr);
}
return namePair;
diff --git a/plugins/efi_resolver/src/TypePropagation.cpp b/plugins/efi_resolver/src/TypePropagation.cpp
index ff0d43b9..68bc06f2 100644
--- a/plugins/efi_resolver/src/TypePropagation.cpp
+++ b/plugins/efi_resolver/src/TypePropagation.cpp
@@ -16,7 +16,7 @@ bool TypePropagation::propagateFuncParamTypes(Function* func)
{
m_queue.push_back(func->GetStart());
- LogDebug("Start Type propagation from 0x%llx", func->GetStart());
+ LogDebugF("Start Type propagation from {:#x}", func->GetStart());
while (!m_queue.empty())
{
@@ -190,7 +190,7 @@ bool TypePropagation::propagateFuncParamTypes(Function* func, SSAVariable ssa_va
}
default:
- LogInfo("Not handled case during type propagation. At %llx: %d", instr.address, instr.operation);
+ LogInfoF("Not handled case during type propagation. At {:#x}: {}", instr.address, instr.operation);
break;
}
}
diff --git a/plugins/rtti/itanium.cpp b/plugins/rtti/itanium.cpp
index 34fd0f71..47525d65 100644
--- a/plugins/rtti/itanium.cpp
+++ b/plugins/rtti/itanium.cpp
@@ -480,7 +480,7 @@ std::optional<ClassInfo> ItaniumRTTIProcessor::ProcessRTTI(uint64_t objectAddr)
auto externTypeName = nameFromTypeInfoSymbol(siClassTypeInfo.base_type);
if (!externTypeName.has_value())
return std::nullopt;
- m_logger->LogDebug("Non-backed external subtype for %llx", objectAddr);
+ m_logger->LogDebugF("Non-backed external subtype for {:#x}", objectAddr);
subTypeName = externTypeName.value();
}
else
@@ -492,7 +492,7 @@ std::optional<ClassInfo> ItaniumRTTIProcessor::ProcessRTTI(uint64_t objectAddr)
auto baseClassName = DemangleNameItanium(m_view, allowMangledClassNames, subTypeName);
if (!baseClassName.has_value())
{
- m_logger->LogWarn("Skipping base class with mangled name %llx", siClassTypeInfo.base_type);
+ m_logger->LogWarnF("Skipping base class with mangled name {:#x}", siClassTypeInfo.base_type);
return std::nullopt;
}
// NOTE: The base class offset is not able to be resolved here.
@@ -516,7 +516,7 @@ std::optional<ClassInfo> ItaniumRTTIProcessor::ProcessRTTI(uint64_t objectAddr)
auto externTypeName = nameFromTypeInfoSymbol(baseInfo.base_type);
if (!externTypeName.has_value())
return std::nullopt;
- m_logger->LogDebug("Non-backed external subtype for %llx", objectAddr);
+ m_logger->LogDebugF("Non-backed external subtype for {:#x}", objectAddr);
subTypeName = externTypeName.value();
}
else
@@ -527,7 +527,7 @@ std::optional<ClassInfo> ItaniumRTTIProcessor::ProcessRTTI(uint64_t objectAddr)
auto baseClassName = DemangleNameItanium(m_view, allowMangledClassNames, subTypeName);
if (!baseClassName.has_value())
{
- m_logger->LogWarn("Skipping base class with mangled name %llx", baseInfo.base_type);
+ m_logger->LogWarnF("Skipping base class with mangled name {:#x}", baseInfo.base_type);
continue;
}
// Shift off the flag bits.
@@ -591,7 +591,7 @@ std::optional<VirtualFunctionTableInfo> ItaniumRTTIProcessor::ProcessVFT(uint64_
else
{
// TODO: Is likely a function check here?
- m_logger->LogDebug("Discovered function from virtual function table... %llx", vFuncAddr);
+ m_logger->LogDebugF("Discovered function from virtual function table... {:#x}", vFuncAddr);
auto vftPlatform = m_view->GetDefaultPlatform()->GetAssociatedPlatformByAddress(vFuncAddr);
m_view->AddFunctionForAnalysis(vftPlatform, vFuncAddr, true);
}
@@ -602,7 +602,7 @@ std::optional<VirtualFunctionTableInfo> ItaniumRTTIProcessor::ProcessVFT(uint64_
if (virtualFunctions.empty())
{
- m_logger->LogDebug("Skipping empty virtual function table... %llx", vftAddr);
+ m_logger->LogDebugF("Skipping empty virtual function table... {:#x}", vftAddr);
return std::nullopt;
}
@@ -648,7 +648,7 @@ std::optional<VirtualFunctionTableInfo> ItaniumRTTIProcessor::ProcessVFT(uint64_
}
else
{
- LogWarn("Skipping adjustments for base VFT with more functions than sub VFT... %llx", vftAddr);
+ LogWarnF("Skipping adjustments for base VFT with more functions than sub VFT... {:#x}", vftAddr);
}
}
@@ -668,7 +668,7 @@ std::optional<VirtualFunctionTableInfo> ItaniumRTTIProcessor::ProcessVFT(uint64_
bool foundDv = m_view->GetDataVariableAtAddress(vFunc.funcAddr, dv);
if (!foundDv)
{
- m_logger->LogWarn("Skipping vfunc with no type... %llx", vFunc.funcAddr);
+ m_logger->LogWarnF("Skipping vfunc with no type... {:#x}", vFunc.funcAddr);
return std::nullopt;
}
vFuncType = dv.type.GetValue();
@@ -676,7 +676,7 @@ std::optional<VirtualFunctionTableInfo> ItaniumRTTIProcessor::ProcessVFT(uint64_
vFuncSym = m_view->GetSymbolByAddress(vFunc.funcAddr);
if (vFuncSym == nullptr)
{
- m_logger->LogWarn("Skipping vfunc with no symbol... %llx", vFunc.funcAddr);
+ m_logger->LogWarnF("Skipping vfunc with no symbol... {:#x}", vFunc.funcAddr);
return std::nullopt;
}
}
@@ -752,12 +752,12 @@ void ItaniumRTTIProcessor::ProcessRTTI()
{
if (failedAttempts++; failedAttempts > MAX_FAILED_SCAN_ATTEMPTS)
break;
- m_logger->LogWarnForException(e, "Failed to process object at %llx... skipping", currAddr);
+ m_logger->LogWarnForExceptionF(e, "Failed to process object at {:#x}... skipping", currAddr);
}
}
if (failedAttempts > MAX_FAILED_SCAN_ATTEMPTS)
- m_logger->LogWarn("Too many failed scans for section %llx... skipping", section->GetStart());
+ m_logger->LogWarnF("Too many failed scans for section {:#x}... skipping", section->GetStart());
};
BulkSymbolModification bulkSymbolModification(m_view);
@@ -773,12 +773,12 @@ void ItaniumRTTIProcessor::ProcessRTTI()
// If a malformed binary makes the binary view set up unbacked sections we should not attempt to read in them.
if (m_view->ReadBuffer(section->GetStart(), 4).GetLength() == 4)
{
- m_logger->LogDebug("Attempting to find RTTI in section %llx", section->GetStart());
+ m_logger->LogDebugF("Attempting to find RTTI in section {:#x}", section->GetStart());
scan(section);
}
else
{
- m_logger->LogDebug("Unbacked start for section %llx... skipping", section->GetStart());
+ m_logger->LogDebugF("Unbacked start for section {:#x}... skipping", section->GetStart());
}
}
}
@@ -829,7 +829,7 @@ void ItaniumRTTIProcessor::ProcessRTTI()
bgTask->Finish();
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_time = end_time - start_time;
- m_logger->LogDebug("ProcessRTTI took %f seconds", elapsed_time.count());
+ m_logger->LogDebugF("ProcessRTTI took {} seconds", elapsed_time.count());
}
@@ -921,5 +921,5 @@ void ItaniumRTTIProcessor::ProcessVFT()
bgTask->Finish();
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_time = end_time - start_time;
- m_logger->LogDebug("ProcessVFT took %f seconds", elapsed_time.count());
-} \ No newline at end of file
+ m_logger->LogDebugF("ProcessVFT took {} seconds", elapsed_time.count());
+}
diff --git a/plugins/rtti/microsoft.cpp b/plugins/rtti/microsoft.cpp
index ad9eb2e4..beb333b9 100644
--- a/plugins/rtti/microsoft.cpp
+++ b/plugins/rtti/microsoft.cpp
@@ -362,14 +362,14 @@ std::vector<BaseClassInfo> MicrosoftRTTIProcessor::ProcessClassHierarchyDescript
if (baseClassTypeDescAddr == 0)
{
// Fixes issue https://github.com/Vector35/binaryninja-api/issues/6837
- m_logger->LogWarn("Skipping BaseClassDescriptor with null pTypeDescriptor %llx", baseClassDescAddr);
+ m_logger->LogWarnF("Skipping BaseClassDescriptor with null pTypeDescriptor {:#x}", baseClassDescAddr);
continue;
}
auto baseClassTypeDesc = TypeDescriptor(m_view, baseClassTypeDescAddr);
auto baseClassName = DemangleNameMS(m_view, allowMangledClassNames, baseClassTypeDesc.name);
if (!baseClassName.has_value())
{
- m_logger->LogWarn("Skipping BaseClassDescriptor with mangled name %llx", baseClassTypeDescAddr);
+ m_logger->LogWarnF("Skipping BaseClassDescriptor with mangled name {:#x}", baseClassTypeDescAddr);
continue;
}
@@ -422,7 +422,7 @@ std::optional<ClassInfo> MicrosoftRTTIProcessor::ProcessRTTI(uint64_t coLocatorA
{
if (!allowAnonymousClassNames)
{
- m_logger->LogDebug("Skipping CompleteObjectorLocator with anonymous name %llx", coLocatorAddr);
+ m_logger->LogDebugF("Skipping CompleteObjectorLocator with anonymous name {:#x}", coLocatorAddr);
return std::nullopt;
}
className = fmt::format("anonymous_{:#x}", coLocatorAddr);
@@ -437,7 +437,7 @@ std::optional<ClassInfo> MicrosoftRTTIProcessor::ProcessRTTI(uint64_t coLocatorA
reader.Seek(classHierarchyDescAddr);
if (auto signature = reader.Read32(); signature != 0)
{
- m_logger->LogWarn("Skipping CompleteObjectorLocator with non-zero hierarchy descriptor signature %llx", coLocatorAddr);
+ m_logger->LogWarnF("Skipping CompleteObjectorLocator with non-zero hierarchy descriptor signature {:#x}", coLocatorAddr);
return std::nullopt;
}
@@ -501,7 +501,7 @@ std::optional<VirtualFunctionTableInfo> MicrosoftRTTIProcessor::ProcessVFT(uint6
break;
}
// TODO: Is likely a function check here?
- m_logger->LogDebug("Discovered function from virtual function table... %llx", vFuncAddr);
+ m_logger->LogDebugF("Discovered function from virtual function table... {:#x}", vFuncAddr);
auto vftPlatform = m_view->GetDefaultPlatform()->GetAssociatedPlatformByAddress(vFuncAddr);
auto vFunc = m_view->AddFunctionForAnalysis(vftPlatform, vFuncAddr, true);
virtualFunctions.emplace_back(vFuncAddr, vFunc ? std::optional(vFunc) : std::nullopt);
@@ -515,7 +515,7 @@ std::optional<VirtualFunctionTableInfo> MicrosoftRTTIProcessor::ProcessVFT(uint6
if (virtualFunctions.empty())
{
- m_logger->LogDebug("Skipping empty virtual function table... %llx", vftAddr);
+ m_logger->LogDebugF("Skipping empty virtual function table... {:#x}", vftAddr);
return std::nullopt;
}
@@ -563,10 +563,10 @@ std::optional<VirtualFunctionTableInfo> MicrosoftRTTIProcessor::ProcessVFT(uint6
}
else
{
- LogWarn("Skipping adjustments for base VFT with more functions than sub VFT... %llx", vftAddr);
+ LogWarnF("Skipping adjustments for base VFT with more functions than sub VFT... {:#x}", vftAddr);
}
}
-
+
for (auto &&[_, vFunc]: virtualFunctions)
{
auto vFuncName = fmt::format("vFunc_{}", vFuncIdx);
@@ -697,22 +697,22 @@ void MicrosoftRTTIProcessor::ProcessRTTI()
// If a malformed binary makes the binary view set up unbacked segments we should not attempt to read in them.
if (m_view->ReadBuffer(segment->GetStart(), 4).GetLength() != 4)
{
- m_logger->LogInfo("Unbacked start for segment %llx... skipping", segment->GetStart());
+ m_logger->LogInfoF("Unbacked start for segment {:#x}... skipping", segment->GetStart());
continue;
}
- m_logger->LogDebug("Attempting to find RTTI in segment %llx", segment->GetStart());
+ m_logger->LogDebugF("Attempting to find RTTI in segment {:#x}", segment->GetStart());
try
{
scan(segment);
}
catch (std::exception &e)
{
- m_logger->LogWarn("Unhandled exception in segment scan %llx %s", segment->GetStart(), e.what());
+ m_logger->LogWarnF("Unhandled exception in segment scan {:#x} {}", segment->GetStart(), e.what());
}
}
else if (checkWritableRData && rdataSection && rdataSection->GetStart() == segment->GetStart())
{
- m_logger->LogDebug("Attempting to find RTTI in writable rdata segment %llx",
+ m_logger->LogDebugF("Attempting to find RTTI in writable rdata segment {:#x}",
segment->GetStart());
try
{
@@ -720,7 +720,7 @@ void MicrosoftRTTIProcessor::ProcessRTTI()
}
catch (std::exception &e)
{
- m_logger->LogWarn("Unhandled exception in writable segment scan %llx %s", segment->GetStart(), e.what());
+ m_logger->LogWarnF("Unhandled exception in writable segment scan {:#x} {}", segment->GetStart(), e.what());
}
}
}
@@ -728,7 +728,7 @@ void MicrosoftRTTIProcessor::ProcessRTTI()
bgTask->Finish();
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_time = end_time - start_time;
- m_logger->LogDebug("ProcessRTTI took %f seconds", elapsed_time.count());
+ m_logger->LogDebugF("ProcessRTTI took {} seconds", elapsed_time.count());
}
@@ -776,19 +776,19 @@ void MicrosoftRTTIProcessor::ProcessVFT()
break;
if (segment->GetFlags() == (SegmentReadable | SegmentContainsData))
{
- m_logger->LogDebug("Attempting to find VirtualFunctionTables in segment %llx", segment->GetStart());
+ m_logger->LogDebugF("Attempting to find VirtualFunctionTables in segment {:#x}", segment->GetStart());
try
{
scan(segment);
}
catch (std::exception &e)
{
- m_logger->LogWarn("Unhandled exception in vtable segment scan %llx %s", segment->GetStart(), e.what());
+ m_logger->LogWarnF("Unhandled exception in vtable segment scan {:#x} {}", segment->GetStart(), e.what());
}
}
else if (checkWritableRData && rdataSection && rdataSection->GetStart() == segment->GetStart())
{
- m_logger->LogDebug("Attempting to find VirtualFunctionTables in writable rdata segment %llx",
+ m_logger->LogDebugF("Attempting to find VirtualFunctionTables in writable rdata segment {:#x}",
segment->GetStart());
try
{
@@ -796,7 +796,7 @@ void MicrosoftRTTIProcessor::ProcessVFT()
}
catch (std::exception &e)
{
- m_logger->LogWarn("Unhandled exception in vtable writable segment scan %llx %s", segment->GetStart(), e.what());
+ m_logger->LogWarnF("Unhandled exception in vtable writable segment scan {:#x} {}", segment->GetStart(), e.what());
}
}
}
@@ -860,5 +860,5 @@ void MicrosoftRTTIProcessor::ProcessVFT()
bgTask->Finish();
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_time = end_time - start_time;
- m_logger->LogDebug("ProcessVFT took %f seconds", elapsed_time.count());
-} \ No newline at end of file
+ m_logger->LogDebugF("ProcessVFT took {} seconds", elapsed_time.count());
+}
diff --git a/view/kernelcache/core/KernelCache.cpp b/view/kernelcache/core/KernelCache.cpp
index ef5fd8a5..6ff88ad1 100644
--- a/view/kernelcache/core/KernelCache.cpp
+++ b/view/kernelcache/core/KernelCache.cpp
@@ -305,7 +305,7 @@ void KernelCache::ProcessRelocations(Ref<BinaryView> view, linkedit_data_command
if (!bind)
{
- uint64_t entryOffset;
+ uint64_t entryOffset = 0;
switch (starts.pointer_format)
{
case DYLD_CHAINED_PTR_ARM64E:
diff --git a/view/kernelcache/core/KernelCacheView.cpp b/view/kernelcache/core/KernelCacheView.cpp
index 8e942268..82f3ce7f 100644
--- a/view/kernelcache/core/KernelCacheView.cpp
+++ b/view/kernelcache/core/KernelCacheView.cpp
@@ -9,7 +9,7 @@
using namespace BinaryNinja;
using namespace BinaryNinja::KC;
-[[maybe_unused]] KernelCacheViewType* g_kcViewType;
+static KernelCacheViewType* g_kcViewType;
KernelCacheViewType::KernelCacheViewType() : BinaryViewType(KC_VIEW_NAME, KC_VIEW_NAME) {}
diff --git a/view/kernelcache/core/KernelCacheView.h b/view/kernelcache/core/KernelCacheView.h
index 9a2baf6f..bfe12502 100644
--- a/view/kernelcache/core/KernelCacheView.h
+++ b/view/kernelcache/core/KernelCacheView.h
@@ -7,8 +7,6 @@
#include <binaryninjaapi.h>
-static const char* VIEW_METADATA_KEY = "shared_cache_view";
-
class KernelCacheView : public BinaryNinja::BinaryView
{
bool m_parseOnly;
diff --git a/view/kernelcache/core/MachO.cpp b/view/kernelcache/core/MachO.cpp
index 9eabf086..01b5da74 100644
--- a/view/kernelcache/core/MachO.cpp
+++ b/view/kernelcache/core/MachO.cpp
@@ -483,9 +483,9 @@ std::vector<CacheSymbol> KernelCacheMachOHeader::ReadSymbolTable(Ref<BinaryView>
if (nlist.n_strx >= stringInfo.entries)
{
// TODO: where logger?
- LogError(
- "Symbol entry at index %llu has a string offset of %u which is outside the strings buffer of size %llu "
- "for symbol table %x",
+ LogErrorF(
+ "Symbol entry at index {} has a string offset of {} which is outside the strings buffer of size {} "
+ "for symbol table {:#x}",
entryIndex, nlist.n_strx, stringInfo.address, stringInfo.entries);
continue;
}
diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp
index 3c558963..2ff15f0e 100644
--- a/view/macho/machoview.cpp
+++ b/view/macho/machoview.cpp
@@ -3484,7 +3484,7 @@ void MachoView::ParseChainedStarts(MachOHeader& header, section_64 chainedStarts
}
else if (!bind)
{
- uint64_t entryOffset;
+ uint64_t entryOffset = 0;
switch (pointerFormat)
{
case DYLD_CHAINED_PTR_ARM64E:
diff --git a/view/sharedcache/core/SharedCacheController.cpp b/view/sharedcache/core/SharedCacheController.cpp
index ce3fde2c..d300017e 100644
--- a/view/sharedcache/core/SharedCacheController.cpp
+++ b/view/sharedcache/core/SharedCacheController.cpp
@@ -8,7 +8,8 @@ using namespace BinaryNinja::DSC;
// Unique ID for a given Binary View.
typedef uint64_t ViewId;
-std::shared_mutex GlobalControllersMutex;
+static std::shared_mutex GlobalControllersMutex;
+static const char* METADATA_KEY = "shared_cache";
std::map<ViewId, DSCRef<SharedCacheController>>& GlobalControllers()
{
diff --git a/view/sharedcache/core/SharedCacheController.h b/view/sharedcache/core/SharedCacheController.h
index cda3653c..cb381cbd 100644
--- a/view/sharedcache/core/SharedCacheController.h
+++ b/view/sharedcache/core/SharedCacheController.h
@@ -11,10 +11,6 @@ DECLARE_DSC_API_OBJECT(BNSharedCacheController, SharedCacheController);
void RegisterSharedCacheControllerDestructor();
namespace BinaryNinja::DSC {
- static const char* METADATA_KEY = "shared_cache";
- static const char* OLD_METADATA_KEY_COUNT = "SHAREDCACHE-ModifiedState-Count";
- static const char* OLD_METADATA_KEY_PREFIX = "SHAREDCACHE-ModifiedState-";
-
// Represents the view state for a given `DSCache`
class SharedCacheController : public DSCRefCountObject
{
diff --git a/view/sharedcache/core/SharedCacheView.cpp b/view/sharedcache/core/SharedCacheView.cpp
index a1428eab..dac39278 100644
--- a/view/sharedcache/core/SharedCacheView.cpp
+++ b/view/sharedcache/core/SharedCacheView.cpp
@@ -10,6 +10,8 @@
using namespace BinaryNinja;
using namespace BinaryNinja::DSC;
+static const char* VIEW_METADATA_KEY = "shared_cache_view";
+
SharedCacheViewType::SharedCacheViewType() : BinaryViewType(VIEW_NAME, VIEW_NAME) {}
// We register all our one-shot stuff here, such as the object destructor.
diff --git a/view/sharedcache/core/SharedCacheView.h b/view/sharedcache/core/SharedCacheView.h
index 9318c66c..5f916b30 100644
--- a/view/sharedcache/core/SharedCacheView.h
+++ b/view/sharedcache/core/SharedCacheView.h
@@ -7,8 +7,6 @@
#include <binaryninjaapi.h>
-static const char* VIEW_METADATA_KEY = "shared_cache_view";
-
class SharedCacheView : public BinaryNinja::BinaryView
{
bool m_parseOnly;