Skip to content

Added elf library for elf code.#290

Open
an-owl wants to merge 1 commit intorust-osdev:mainfrom
an-owl:main
Open

Added elf library for elf code.#290
an-owl wants to merge 1 commit intorust-osdev:mainfrom
an-owl:main

Conversation

@an-owl
Copy link

@an-owl an-owl commented Mar 20, 2026

I needed to get the full ELF header I figured I'd implement #247 in the process.

  • In the front end everything is basically the same except I've added a method to get the whole section header.
  • In the backend I've removed all the magic numbers and replaced them with constants from ::elf::abi
  • I've added a helper for the section header pointer, it handles offsetting and fetching the section header, it uses an intermediate type so callers can eliminate separate code paths.
  • I removed the "strlen" code in favour of using core::ffi::CStr to handle it. Originally I wanted to use CStr to store the section name in ElfSection however it doesn't implement Copy
  • ElfSection::string_table never needed to be unsafe, it is no longer unsafe
  • ELF defines a program/user defined block of section header values which I've added.
  • The ElfSectionInner trait is no longer needed because it now uses elf::section::SectionHeader for both ELF32 and ELF64. I've left it in solely for familiarity of others. I can remove it if you want.
  • ElfSection now copies the section header instead of maintaining a pointer to it. I can revert this behavior if you want.

@phip1611
Copy link
Member

awesome, thanks! I don't think I have to look into this in the next week, but let's see.

@phip1611 phip1611 self-requested a review March 20, 2026 17:51
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