Skip to content

Fix ELF Parser Alignment Handling, Remove Custom Linker Script, and Improve Handling of .bss Section in Binary Parsing #483

Description

@vijaydhanraj

As suggested by @Freax13 in PR 467, the following fixes and clean-ups need to be done.

  • In the current ELF parser implementation, verify_phdr function returns an error when p_vaddr is not aligned. But since spec doesn't guarantee that p_vaddr must be aligned, our ELF parser needs to be fixed. Current WA is to use a custom linker script to align p_vaddr.

  • Remove the custom linker script for the init and dm once the ELF parser issue is fixed.

  • When parsing the binary, if p_memsz > p_filesz, the range [p_filesz..p_memsz) needs to be zeroed as per spec. This is usually true for .bss section. But we cannot anonymously map just .bss as the segment may contain other sections like .data. To resolve this issue, extend VMFileMapping::new such that if p_filesz is not a multiple of page size, we should make a private copy of the page using .try_cop_page() and zero out the bytes after p_filesz.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions