Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging failures during elf loading #340

Open
christian-herber-nxp opened this issue Dec 10, 2024 · 4 comments
Open

Debugging failures during elf loading #340

christian-herber-nxp opened this issue Dec 10, 2024 · 4 comments

Comments

@christian-herber-nxp
Copy link

I am currently facing a fail during loading of an elf file, and I have a hard time understanding what the issue could be.
In general, slightly more explicit error messages would be nice, but for that one has to understand the code.
My error is thrown on that condition in pk/elf.c:

size_t phdr_size = eh.e_phnum * sizeof(Elf_Phdr);
if (phdr_size > info->phdr_size)

I would appreciate if somebody has input as to what this indicates.

@aswaterman
Copy link
Collaborator

There's a data structure that holds the program headers and is statically sized:

static long phdrs[128]; // avoid large stack allocation

You could probably increase it without consequence. But I agree the error message could be clearer in this case, since this error is not about a malformed ELF, but about a pk constraint.

@christian-herber-nxp
Copy link
Author

If the size of the header is anyway discovered dynamically, why is the memory to store it not allocated dynamically?
As the headers can be arbitrarily large, it seems difficult to hardcode this.

@aswaterman
Copy link
Collaborator

I agree that would be better, but it is not a priority--you're the first person to have raised this issue. If you submit a PR to that end, I'd be happy to review it.

@christian-herber-nxp
Copy link
Author

I will put it in the back burner.

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

No branches or pull requests

2 participants