Skip to content

Conversation

@m-wkr
Copy link

@m-wkr m-wkr commented Dec 11, 2025

Added a few extra goto error messages relating to elf headers, program headers, and note headers have been added in relation to #396.

Copy link
Contributor

@reynir reynir left a comment

Choose a reason for hiding this comment

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

Thanks!

I think this adds a lot of gotos (and labels!) which maybe goes a bit off from the current style. Since most of the labels are warnx("..."); goto mem_cleanup I wonder if it could be rewritten so the source locations of the gotos instead call warnx("...") and then goto mem_cleanup? Then we have fewer locations we goto.

@m-wkr
Copy link
Author

m-wkr commented Dec 17, 2025

Thank you for the feedback, I'll adjust the relevant lines immediately to reduce the bloating.

if (ehdr->e_entry < p_min_loadaddr || ehdr->e_entry >= mem_size)
goto out_invalid;
if (ehdr->e_entry < p_min_loadaddr || ehdr->e_entry >= mem_size) {
warnx("%s: e_entry does not fall within the memory allocation range", bin_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this again this error message is very specific and perhaps lacks a bit of context. So if the executable seems invalid or unsupported we say so and then go into further detail rather than diving deep into details. I think for people not deep into ELF will have a hard time understand why the program fails with such a message.

Suggested change
warnx("%s: e_entry does not fall within the memory allocation range", bin_name);
warnx("%s: Invalid or unsupported executable: e_entry does not fall within the memory allocation range", bin_name);

Copy link
Author

Choose a reason for hiding this comment

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

Hi @reynir, thank you for your feedback. I had a look at the rest of the error messages, in particular do you think that the messages listed below will benefit from these changes as well?

  • "p_vaddr_start is outside of memory range"
  • "note does not fall within valid size"

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.

3 participants