Skip to content

Much better support for ELF files #755

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

Merged
merged 9 commits into from
Mar 31, 2025
Merged

Conversation

bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Mar 31, 2025

This now uses symbols rather than debuginfo as source of truth of which functions exist. This allows analyzing binaries which don't have debuginfo and ensures symbols for which rustc doesn't generate debuginfo for whatever reason are still accounted for.

For ELF files we now take the runtime allocated size rather than the file size into account. When developing for microcontrollers the runtime allocated size is what matters, not the file size as only the runtime allocated segments actually get flashed onto the device. The rest of the ELF file is ignored.

This also adds support for getting the graph of references between symbols. This is done asking the user to compile with --emit-relocs and then reading the resulting relocations. Unlike the twiggy backend for WASM this supports both references originating from functions as well as references originating from data objects. So it will handle vtables and references in statics just fine.

This contains three commits regenerating hello_elf to see step by step how the command outputs improve by these changes. The regenerations should probably be squashed together into a single commit before merging to save a couple of MB in repo size.

bjorn3 added 8 commits March 26, 2025 10:34
If you care about binary size you are probably going to strip all
debuginfo and symbols anyway. Unlike wasm, for elf twiggy requires
debuginfo so people can't strip the executable before running twiggy on
it and as such using the file size as total is misleading.
This allows functioning without debuginfo. Some standard library crates
are intentionally compiled without debuginfo and as such previously
didn't show up in the report at all or without function name. Same for
the main function. This also adds statics and anonymous allocations as a
side effect by not filtering their symbols out.
This also nicely handles edges involving statics and anonymous
allocations too.
@AlexEne
Copy link
Collaborator

AlexEne commented Mar 31, 2025

Hi, it seems the CI is totally broken somehow :(.
Just to double-check have you ran tests locally to confirm things work?

@bjorn3
Copy link
Collaborator Author

bjorn3 commented Mar 31, 2025

Yeah, locally tests pass.

@AlexEne AlexEne merged commit 739cd04 into rustwasm:master Mar 31, 2025
1 of 5 checks passed
@AlexEne
Copy link
Collaborator

AlexEne commented Mar 31, 2025

Thanks for this. I also added you to maintainers so you don't have to wait on me for other PRs

@bjorn3 bjorn3 deleted the elf_calls2 branch March 31, 2025 13:41
@bjorn3
Copy link
Collaborator Author

bjorn3 commented Mar 31, 2025

Thanks!

@bjorn3
Copy link
Collaborator Author

bjorn3 commented Mar 31, 2025

Fixed CI in #756.

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