debug(fat32,elf): win_read 打印 abs_sector/hidden_sectors/win 前4字节(win[0..1] 被清零);not x86_64 分支 dump ehdr 前20字节(read_len=64 但内容错)

This commit is contained in:
TermiNexus committed 2026-08-27 01:11:05 +08:00
1 parent d0b512f159
commit 364daa111b
2 files changed
+17

No files matched your search

@@ -360,6 +360,13 @@ class volinfo:
res2: DRESULT = diskio.read(self.pdrv, win_addr, t.CUInt32T(abs_sector), 1)
self.lock.unlock()
if res2 != DRESULT.RES_OK: return FRESULT.FR_DISK_ERR
# [DIAG] 定位 win[0..1] 被清零(L271 win=00 00 20...):区分读错扇区
# vs 读后被覆盖——打印 abs_sector 与读后 win 前 4 字节。
_dwr: t.CArray[t.CChar, 96]
viperlib.snprintf(c.Addr(_dwr), 96, "[wr] sec=%lx abs=%lx hid=%lx w0=%02x %02x %02x %02x\n",
sector, abs_sector, t.CUInt64T(self.hidden_sectors),
self.win[0], self.win[1], self.win[2], self.win[3])
serial.puts(c.Addr(_dwr))
self.winsect = sector
return FRESULT.FR_OK
+10
View File
@@ -175,6 +175,16 @@ def load_elf(path: t.CConst | str, do_map: t.CInt = 1) -> t.CVoid | t.CPtr:
if ehdr.e_machine != EM_X86_64:
serial.puts("[elf] not x86_64\n")
# [DIAG] e_machine 错:dump ehdr 前 24 字节(read_len=64 正确但内容错)
_dbg_em: t.CArray[t.CChar, 128]
viperlib.snprintf(c.Addr(_dbg_em), 128,
"[elf] ehdr=%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x rl=%lu\n",
ehdr_buf[0], ehdr_buf[1], ehdr_buf[2], ehdr_buf[3],
ehdr_buf[4], ehdr_buf[5], ehdr_buf[6], ehdr_buf[7],
ehdr_buf[8], ehdr_buf[9], ehdr_buf[10], ehdr_buf[11],
ehdr_buf[12], ehdr_buf[13], ehdr_buf[14], ehdr_buf[15],
ehdr_buf[16], ehdr_buf[17], ehdr_buf[18], ehdr_buf[19], read_len)
serial.puts(c.Addr(_dbg_em))
fat32.close(fp)
return None