Skip to content

Add elf library for elf_sections.rs#292

Open
an-owl wants to merge 12 commits intorust-osdev:mainfrom
an-owl:elf
Open

Add elf library for elf_sections.rs#292
an-owl wants to merge 12 commits intorust-osdev:mainfrom
an-owl:elf

Conversation

@an-owl
Copy link
Copy Markdown

@an-owl an-owl commented Apr 21, 2026

This is a complete rewrite from #290, using elf::sections::SectionHeaderTable to construct the iterator. Unlike #290 however, I decided not to care about version compatibility. This removes or replaces a number of existing functions.

One change in particular is how to fetch the section name. The existing method in my opinion is flawed, if the ELF sections are relocated then it's not possible to get the name. I've changed this so the string table must be fetched separately, which can then be passed to a helper. This helper returns a &core::ffi::CStr instead of a &str, the ELF specification doesn't define the character encoding so we should not force it to be Unicode.

An important behavioral change that isn't obvious is that "unused" (SHT_NULL) sections are no longer skipped. This threw me for a loop during testing. If they're there it's probably there for a reason, so I think its a bad idea to skip it, especially if you can just use .filter(_).

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.

1 participant