From 340befc3709fb58371445b23e09806d40c5798af Mon Sep 17 00:00:00 2001 From: Sinan KARAKAYA Date: Mon, 17 Aug 2026 18:28:59 +0200 Subject: [PATCH] Warn instead of aborting when no function covers the ELF entry point Not every toolchain points e_entry at an instruction. Metrowerks CodeWarrior for PS2 emits a crt0 data table there -- scratchpad addresses and size words -- with the first real instruction some way past it, so no function covers the entry address and neither entryName nor getFunctionName() resolves. The emitter threw in that case, which aborted the run after every per-function source had already been written but before register_functions.cpp, ps2_recompiled_functions.h and ps2_recompiled_stubs.h were generated, leaving an output directory that looks complete and is not. Skip the entry registration with a warning instead. Synthesizing a name would emit a table reference to a definition that was never generated and fail at link time, and the start address for such a binary has to come from configuration regardless. --- ps2xRecomp/src/lib/function_table_emitter.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ps2xRecomp/src/lib/function_table_emitter.cpp b/ps2xRecomp/src/lib/function_table_emitter.cpp index 27dc9b74c..84d3850ea 100644 --- a/ps2xRecomp/src/lib/function_table_emitter.cpp +++ b/ps2xRecomp/src/lib/function_table_emitter.cpp @@ -95,9 +95,25 @@ namespace ps2recomp } if (entryTarget.empty()) { - throw std::runtime_error("No entry function name available for registration."); + // Not every toolchain points e_entry at code. Metrowerks CodeWarrior + // for PS2 emits a crt0 data table there, so no function covers the + // address and no name resolves. Registering a synthesized name would + // reference a definition that was never emitted, so skip the entry + // instead - the real start address comes from configuration - and + // keep emitting the rest of the table rather than aborting after the + // per-function sources were already written. + if (cg.m_reporter) + { + std::ostringstream oss; + oss << "No function covers the ELF entry point; skipping its table registration. " + << "Set the entry explicitly if the runtime should start here."; + cg.m_reporter->warning("function-table", oss.str()); + } + } + else + { + addEntry(cg.m_bootstrapInfo.entry, entryTarget); } - addEntry(cg.m_bootstrapInfo.entry, entryTarget); } for (const auto &[address, name] : normalFunctions)