From: Jean-Paul Mari Date: Sun, 15 Mar 2020 09:27:59 +0000 (-0400) Subject: Added ELF section types check and new error messages X-Git-Tag: v2.1.3-R5^2~39 X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/commitdiff_plain/7575ebee4ba6ee000f735dd6e0884fbbc220fc89?ds=sidebyside Added ELF section types check and new error messages --- diff --git a/docs/vj_HistoryNotes.txt b/docs/vj_HistoryNotes.txt index 8f788cb..745fc4b 100644 --- a/docs/vj_HistoryNotes.txt +++ b/docs/vj_HistoryNotes.txt @@ -13,6 +13,7 @@ Release 5 (TBA) 6) Fix potential emulator freeze after an exception has occured 7) Fix a random crash when reading the source lines information 8) Added ELF & DWARF .debug* types +9) Added ELF section types check and new error messages Release 4a (15th August 2019) ----------------------------- diff --git a/src/file.cpp b/src/file.cpp index a296bd0..73d255e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -16,6 +16,7 @@ // 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 +// JPM 03/12/2020 Added ELF section types check and new error messages // #include "file.h" @@ -232,10 +233,10 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress { switch (PtrGElfShdr->sh_type) { - case SHT_NULL: + case SHT_NULL: break; - case SHT_PROGBITS: + case SHT_PROGBITS: if ((PtrGElfShdr->sh_flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR))) { if (PtrGElfShdr->sh_addr >= 0x800000) @@ -252,14 +253,19 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress { switch (ElfSectionNameType) { + case ELF_debug_TYPE: + case ELF_debug_abbrev_TYPE: case ELF_debug_aranges_TYPE: + case ELF_debug_frame_TYPE: case ELF_debug_info_TYPE: - case ELF_debug_abbrev_TYPE: case ELF_debug_line_TYPE: - case ELF_debug_frame_TYPE: + case ELF_debug_loc_TYPE: + case ELF_debug_macinfo_TYPE: + case ELF_debug_pubnames_TYPE: + case ELF_debug_pubtypes_TYPE: case ELF_debug_ranges_TYPE: case ELF_debug_str_TYPE: - case ELF_debug_loc_TYPE: + case ELF_debug_types_TYPE: break; case ELF_heap_TYPE: @@ -269,27 +275,30 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress break; default: + WriteLog("FILE: ELF section %s is not recognized\n", NameSection); error = true; break; } } break; - case SHT_NOBITS: + case SHT_NOBITS: break; - case SHT_STRTAB: - case SHT_SYMTAB: + case SHT_STRTAB: + case SHT_SYMTAB: while ((error == false) && ((PtrElfData = elf_getdata(PtrElfScn, PtrElfData)) != NULL)) { if (!ELFManager_AddTab(PtrElfData, ElfSectionNameType)) { + WriteLog("FILE: ELF tab cannot be allocated\n"); error = true; } } break; default: + WriteLog("FILE: ELF SHT type %i not recognized\n", PtrGElfShdr->sh_type); error = true; break; } @@ -297,6 +306,7 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress } } + // Set the executable address jaguarRunAddress = (uint32_t)PtrGElfEhdr->e_entry; WriteLog("FILE: Setting up ELF 32bits... Run address: %08X\n", jaguarRunAddress); } @@ -307,6 +317,7 @@ WriteLog("FILE: Cartridge run address is reported as $%X...\n", jaguarRunAddress } else { + WriteLog("FILE: Cannot get the number of the ELF sections\n"); error = true; } }