Skip to content

Warn instead of aborting when no function covers the ELF entry point - #207

Open
Sinan-Karakaya wants to merge 1 commit into
ran-j:mainfrom
Sinan-Karakaya:fix/entry-point-no-abort
Open

Warn instead of aborting when no function covers the ELF entry point#207
Sinan-Karakaya wants to merge 1 commit into
ran-j:mainfrom
Sinan-Karakaya:fix/entry-point-no-abort

Conversation

@Sinan-Karakaya

Copy link
Copy Markdown
Contributor

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. No function covers the entry address, so neither entryName nor getFunctionName() resolves and FunctionTableEmitter::emit throws:

No entry function name available for registration.

That happens after every per-function source has already been written, but before register_functions.cpp, ps2_recompiled_functions.h and ps2_recompiled_stubs.h are generated — leaving an output directory that looks complete and is not.

This skips the entry registration with a warning instead of aborting.

I considered synthesizing a name (entry_%08X) but that emits a function-table reference to a definition that was never generated, which then fails at link time. For a binary shaped like this the start address has to come from configuration regardless, so recording the situation and continuing seemed the more useful behaviour.

Concretely, on Dragon Quest VIII (NTSC-U) the header entry is 0x00100008, which is 33 words of crt0 data; the first instruction is at 0x0010008C. The run now completes and reports:

[warning] function-table - No function covers the ELF entry point; skipping its
table registration. Set the entry explicitly if the runtime should start here.

Copilot AI lite review requested due to automatic review settings August 17, 2026 16:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts function-table generation to tolerate ELFs whose e_entry points into non-code data (e.g., crt0 tables), avoiding late-stage aborts that leave partially generated output.

Changes:

  • Replace a hard failure when the ELF entry point cannot be resolved to a function name with a warning and continued emission.
  • Skip registering the entry point in the function table when no function covers it, preserving generation of other outputs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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());
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.
@Sinan-Karakaya
Sinan-Karakaya force-pushed the fix/entry-point-no-abort branch from dc45fd3 to 340befc Compare August 17, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants