diff --git a/src/emucore/CartELF.cxx b/src/emucore/CartELF.cxx index 2ca5d9cfa..1d6618753 100644 --- a/src/emucore/CartELF.cxx +++ b/src/emucore/CartELF.cxx @@ -16,10 +16,7 @@ //============================================================================ #include - -#ifdef DUMP_ELF -#include -#endif +#include #include "System.hxx" #include "ElfLinker.hxx" @@ -31,8 +28,6 @@ #include "CartELF.hxx" -#define DUMP_ELF - using namespace elfEnvironment; namespace { @@ -40,7 +35,6 @@ namespace { constexpr uInt32 ARM_RUNAHED_MIN = 3; constexpr uInt32 ARM_RUNAHED_MAX = 6; -#ifdef DUMP_ELF void dumpElf(const ElfFile& elf) { cout << "\nELF sections:\n\n"; @@ -174,7 +168,6 @@ namespace { cout << "wrote executable image to " << IMAGE_FILE_NAME << '\n'; } -#endif SystemType determineSystemType(const Properties* props) { @@ -470,15 +463,15 @@ inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeELF::parseAndLinkElf() { + const bool dump = mySettings.getBool("elf.dump"); + try { myElfParser.parse(myImage.get(), myImageSize); } catch (ElfParser::ElfParseError& e) { throw runtime_error("failed to initialize ELF: " + string(e.what())); } -#ifdef DUMP_ELF - dumpElf(myElfParser); -#endif + if (dump) dumpElf(myElfParser); myLinker = make_unique(ADDR_TEXT_BASE, ADDR_DATA_BASE, ADDR_RODATA_BASE, myElfParser); try { @@ -502,16 +495,16 @@ void CartridgeELF::parseAndLinkElf() if (myLinker->getSegmentSize(ElfLinker::SegmentType::rodata) > RODATA_SIZE) throw runtime_error("rodata segment too large"); -#ifdef DUMP_ELF - dumpLinkage(myElfParser, *myLinker); + if (dump) { + dumpLinkage(myElfParser, *myLinker); - cout - << "\nARM entrypoint: 0x" - << std::hex << std::setw(8) << std::setfill('0') << myArmEntrypoint - << std::dec << '\n'; + cout + << "\nARM entrypoint: 0x" + << std::hex << std::setw(8) << std::setfill('0') << myArmEntrypoint + << std::dec << '\n'; - writeDebugBinary(*myLinker); -#endif + writeDebugBinary(*myLinker); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 601189222..438163620 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -318,6 +318,8 @@ Settings::Settings() setPermanent("dev.thumb.chiptype", "0"); // = LPC2103 setPermanent("dev.thumb.mammode", "2"); #endif + + setTemporary("elf.dump", false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -818,7 +820,8 @@ void Settings::usage() << " -dev.tia.pfscoreglitch <1|0> Enable PF score mode color glitch\n" << " -dev.tia.delaybkcolor <1|0> Enable extra delay cycle for background color\n" << " -dev.tia.delayplswap <1|0> Enable extra delay cycle for VDELP0/1 swap\n" - << " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n\n"; + << " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n" + << " -elf.dump <1|0> Dump ELF linkage information and write elf_executable_image.bin\n\n"; #ifdef BSPF_WINDOWS // int height = 25;