From d56efc772df4a126865574bbbac62fbdaba5646e Mon Sep 17 00:00:00 2001 From: Jean-Paul Mari Date: Wed, 10 Apr 2019 21:37:56 -0400 Subject: [PATCH] Added ELF sections check so a potential unknown section will stop, or not stop, the decoding --- docs/vj_HistoryNotes.txt | 1 + src/debugger/DWARFManager.cpp | 2 +- src/debugger/debuggertab.cpp | 6 ++++++ src/debugger/debuggertab.h | 2 ++ src/file.cpp | 15 +++++++-------- src/gui/mainwin.cpp | 3 +++ src/settings.h | 4 +++- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/vj_HistoryNotes.txt b/docs/vj_HistoryNotes.txt index d3e65c2..a12910d 100644 --- a/docs/vj_HistoryNotes.txt +++ b/docs/vj_HistoryNotes.txt @@ -82,6 +82,7 @@ Git commit: TBD 44) Debugger sources code clean-up 45) Fix a crash when emulator, in non-debugger mode, opens the breakpoint UIs at launch 46) Fix crash with potential missing DWARF structure tag's type name +47) Added ELF sections check so a potential unknown section won't stop the reading Release 3 (13th November 2017) ------------------------------ diff --git a/src/debugger/DWARFManager.cpp b/src/debugger/DWARFManager.cpp index acfe387..fed680a 100644 --- a/src/debugger/DWARFManager.cpp +++ b/src/debugger/DWARFManager.cpp @@ -28,7 +28,7 @@ // Definitions for debugging -//#define DEBUG_NumCU 0xf // CU number to debug or undefine it +//#define DEBUG_NumCU 0x4d // CU number to debug or undefine it //#define DEBUG_VariableName "sound_death" // Variable name to look for or undefine it //#define DEBUG_TypeName "Cbuf_Execute" // Type name to look for or undefine it //#define DEBUG_TypeDef DW_TAG_typedef // Type def to look for or undefine it (not supported) diff --git a/src/debugger/debuggertab.cpp b/src/debugger/debuggertab.cpp index d6135e8..0b4bd46 100644 --- a/src/debugger/debuggertab.cpp +++ b/src/debugger/debuggertab.cpp @@ -9,6 +9,7 @@ // --- ---------- ------------------------------------------------------------ // JPM Sept./2016 Created this file, and added Soft debugger support // JPM 10/09/2018 Added source file search paths +// JPM 04/06/2019 Added ELF sections check // #include "debuggertab.h" @@ -52,13 +53,16 @@ DebuggerTab::DebuggerTab(QWidget * parent/*= 0*/): QWidget(parent) displayHWlabels = new QCheckBox(tr("Display HW labels")); disasmopcodes = new QCheckBox(tr("Display M68000 opcodes")); displayFullSourceFilename = new QCheckBox(tr("Display source filename")); + ELFSectionsCheck = new QCheckBox(tr("ELF sections check")); disasmopcodes->setDisabled(false); displayHWlabels->setDisabled(false); displayFullSourceFilename->setDisabled(false); + ELFSectionsCheck->setDisabled(false); layout4->addWidget(disasmopcodes); layout4->addWidget(displayHWlabels); layout4->addWidget(displayFullSourceFilename); + layout4->addWidget(ELFSectionsCheck); setLayout(layout4); } @@ -81,6 +85,7 @@ void DebuggerTab::SetSettings(void) vjs.displayHWlabels = displayHWlabels->isChecked(); vjs.disasmopcodes = disasmopcodes->isChecked(); vjs.displayFullSourceFilename = displayFullSourceFilename->isChecked(); + vjs.ELFSectionsCheck = ELFSectionsCheck->isChecked(); } @@ -93,6 +98,7 @@ void DebuggerTab::GetSettings(void) displayHWlabels->setChecked(vjs.displayHWlabels); disasmopcodes->setChecked(vjs.disasmopcodes); displayFullSourceFilename->setChecked(vjs.displayFullSourceFilename); + ELFSectionsCheck->setChecked(vjs.ELFSectionsCheck); } diff --git a/src/debugger/debuggertab.h b/src/debugger/debuggertab.h index f9e1b8a..583dd30 100644 --- a/src/debugger/debuggertab.h +++ b/src/debugger/debuggertab.h @@ -5,6 +5,7 @@ // --- ---------- ------------------------------------------------------------ // JPM Sept./2016 Created this file, and added Soft debugger support // JPM 10/09/2018 Added the source file search paths +// JPM 04/06/2019 Added ELF sections check // #ifndef __DEBUGGERTAB_H__ @@ -31,6 +32,7 @@ class DebuggerTab: public QWidget QCheckBox *displayHWlabels; QCheckBox *disasmopcodes; QCheckBox *displayFullSourceFilename; + QCheckBox *ELFSectionsCheck; }; #endif // __DEBUGGERTAB_H__ diff --git a/src/file.cpp b/src/file.cpp index c1cf88a..a296bd0 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -11,13 +11,11 @@ // Who When What // --- ---------- ------------------------------------------------------------ // JLH 01/16/2010 Created this log ;-) -// JLH 02/28/2010 Added functions to look inside .ZIP files and handle -// contents +// JLH 02/28/2010 Added functions to look inside .ZIP files and handle contents // JLH 06/01/2012 Added function to check ZIP file CRCs against file DB -// JPM 06/06/2016 Visual Studio support -// JPM 06/15/2016 ELF format support -// JPM 06/19/2016 Soft debugger support +// JPM June/2016 Visual Studio support, ELF format support and Soft debugger support // JPM 07/15/2016 DWARF format support +// JPM 04/06/2019 Added ELF sections check // #include "file.h" @@ -40,6 +38,7 @@ #include "libdwarf.h" #include "debugger/ELFManager.h" #include "debugger/DBGManager.h" +#include "settings.h" // Private function prototypes @@ -222,11 +221,11 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress else { NameSection = elf_strptr(ElfMem, PtrGElfEhdr->e_shstrndx, (size_t)PtrGElfShdr->sh_name); - WriteLog("FILE: ELF Section name: %s\n", NameSection); + WriteLog("FILE: ELF Section %s found\n", NameSection); - if ((ElfSectionNameType = ELFManager_GetSectionType(NameSection)) == ELF_NO_TYPE) + if (((ElfSectionNameType = ELFManager_GetSectionType(NameSection)) == ELF_NO_TYPE) && vjs.ELFSectionsCheck) { - WriteLog("FILE: ELF Section not listed\n"); + WriteLog("FILE: ELF Section %s not recognized\n", NameSection); error = true; } else diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index a941d48..1b547e2 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -22,6 +22,7 @@ // JPM Sept./2018 Added the new Models and BIOS handler, a screenshot feature and source code files browsing // JPM Oct./2018 Added search paths in the settings, breakpoints feature, cartdridge view menu // JPM 11/18/2018 Fix crash with non-debugger mode +// JPM 04/06/2019 Added ELF sections check // // FIXED: @@ -1846,6 +1847,7 @@ void MainWin::ReadSettings(void) vjs.disasmopcodes = settings.value("DisasmOpcodes", true).toBool(); vjs.displayHWlabels = settings.value("DisplayHWLabels", true).toBool(); vjs.displayFullSourceFilename = settings.value("displayFullSourceFilename", true).toBool(); + vjs.ELFSectionsCheck = settings.value("ELFSectionsCheck", false).toBool(); vjs.nbrmemory1browserwindow = settings.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow).toUInt(); settings.endGroup(); @@ -2149,6 +2151,7 @@ void MainWin::WriteSettings(void) settings.setValue("NbrDisasmLines", vjs.nbrdisasmlines); settings.setValue("DisasmOpcodes", vjs.disasmopcodes); settings.setValue("displayFullSourceFilename", vjs.displayFullSourceFilename); + settings.setValue("ELFSectionsCheck", vjs.ELFSectionsCheck); settings.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs.nbrmemory1browserwindow); settings.setValue("DefaultROM", vjs.debuggerROMPath); settings.setValue("SourceFileSearchPaths", vjs.sourcefilesearchPaths); diff --git a/src/settings.h b/src/settings.h index e81d57d..8b7ca16 100644 --- a/src/settings.h +++ b/src/settings.h @@ -7,7 +7,8 @@ // --- ---------- ------------------------------------------------------------ // JPM 06/19/2016 Soft debugger support // JPM Sept./2018 Added the new Models and BIOS handler, and a screenshot settings -// JPM 10/10/2018 Added search paths in settings +// JPM 10/10/2018 Added search paths in settings +// JPM 04/06/2019 Added ELF sections check // #ifndef __SETTINGS_H__ @@ -83,6 +84,7 @@ struct VJSettings bool displayHWlabels; bool useFastBlitter; bool displayFullSourceFilename; + bool ELFSectionsCheck; size_t nbrmemory1browserwindow; // Number of memory browser windows size_t DRAM_size; // DRAM size -- 2.20.1