From 68bf49df0a588705dc891e1c79b6557a13dc9628 Mon Sep 17 00:00:00 2001
From: dd86k
Date: Sat, 12 Oct 2024 09:42:27 -0400
Subject: [PATCH] dumper: Fix 32-bit Windows build
---
dumper/format/elf.d | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/dumper/format/elf.d b/dumper/format/elf.d
index 8a735c2..ad4a443 100644
--- a/dumper/format/elf.d
+++ b/dumper/format/elf.d
@@ -225,12 +225,12 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
// NOTE: 8-byte aligned
// NOTE: A note program segment contains multiple notes
- void *nbuffer = malloc(phdr.p_filesz);
+ void *nbuffer = malloc(cast(size_t)phdr.p_filesz);
if (nbuffer == null)
panic_crt();
scope(exit) free(nbuffer);
- if (adbg_object_read_at(o, phdr.p_offset, nbuffer, phdr.p_filesz))
+ if (adbg_object_read_at(o, phdr.p_offset, nbuffer, cast(size_t)phdr.p_filesz))
panic_adbg();
uint index;
@@ -238,7 +238,7 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
void *maxlength = nbuffer + phdr.p_filesz;
for (; current < maxlength; ) {
Elf64_Nhdr *note = cast(Elf64_Nhdr*)current;
- if (adbg_bits_ptrbounds(note, Elf64_Nhdr.sizeof, nbuffer, phdr.p_filesz))
+ if (adbg_bits_ptrbounds(note, Elf64_Nhdr.sizeof, nbuffer, cast(size_t)phdr.p_filesz))
panic(2, "Elf64_Nhdr header does not fit note");
// NOTE: Note names
@@ -249,7 +249,7 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
return;
const(char)* name = cast(const(char)*)note + Elf64_Nhdr.sizeof;
- if (adbg_bits_ptrbounds(cast(void*)name, note.n_namesz, nbuffer, phdr.p_filesz))
+ if (adbg_bits_ptrbounds(cast(void*)name, note.n_namesz, nbuffer, cast(size_t)phdr.p_filesz))
panic(2, "Elf64_Nhdr:n_namesz points outside of note bounds");
print_section(++index, name, note.n_namesz);
@@ -263,7 +263,7 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
switch (note.n_type) {
case ELF_NT_PRSTATUS:
- if (adbg_bits_ptrbounds(data, elf_prstatus64.sizeof, nbuffer, phdr.p_filesz))
+ if (adbg_bits_ptrbounds(data, elf_prstatus64.sizeof, nbuffer, cast(size_t)phdr.p_filesz))
return;
elf_prstatus64 *prstatus = cast(elf_prstatus64*)data;
print_u32("pr_info.si_signo", prstatus.pr_info.si_signo);
@@ -315,7 +315,7 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
break;
case ELF_NT_PRPSINFO:
elf_prpsinfo64 *prpsinfo = cast(elf_prpsinfo64*)data;
- if (adbg_bits_ptrbounds(data, elf_prpsinfo64.sizeof + prpsinfo.pr_sname, nbuffer, phdr.p_filesz))
+ if (adbg_bits_ptrbounds(data, elf_prpsinfo64.sizeof + prpsinfo.pr_sname, nbuffer, cast(size_t)phdr.p_filesz))
return;
char[4] pr_sname = void;
int l = realchar(pr_sname.ptr, 4, prpsinfo.pr_sname);
@@ -337,7 +337,7 @@ void dump_elf_coredump64(adbg_object_t *o, Elf64_Phdr *phdr) {
// NOTE: SI_MAX_SIZE is defined with 128, must be same size
goto default;
case ELF_NT_FPREGSET:
- if (adbg_bits_ptrbounds(data, user_i387_struct64.sizeof, nbuffer, phdr.p_filesz))
+ if (adbg_bits_ptrbounds(data, user_i387_struct64.sizeof, nbuffer, cast(size_t)phdr.p_filesz))
return;
user_i387_struct64 *fregset = cast(user_i387_struct64*)data;
print_x16("cwd", fregset.cwd);
@@ -548,11 +548,11 @@ void dump_elf_disasm(adbg_object_t *o) {
case ELF_CLASS_64:
for (Elf64_Shdr *s = void; (s = adbg_object_elf_shdr64(o, i)) != null; ++i) {
if (all || s.sh_flags & ELF_SHF_EXECINSTR) {
- buffer = malloc(s.sh_size);
+ buffer = malloc(cast(size_t)s.sh_size);
if (buffer == null)
panic_crt();
- if (adbg_object_read_at(o, s.sh_offset, buffer, s.sh_size))
+ if (adbg_object_read_at(o, s.sh_offset, buffer, cast(size_t)s.sh_size))
panic_adbg();
dump_disassemble_object(o,