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

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

Open
1 of 3 tasks
vijaydhanraj opened this issue Oct 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@vijaydhanraj
Copy link
Contributor

vijaydhanraj commented Oct 13, 2024

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.

@stefano-garzarella
Copy link
Member

@vijaydhanraj IIUC you are working on them, so I assigned this issue to you. Please let me know if it is not the case.

@stefano-garzarella stefano-garzarella added the bug Something isn't working label Nov 22, 2024
@vijaydhanraj
Copy link
Contributor Author

For issue 1, fix is part of #539. Not pursuing issue 3, please see discussion in here, #510 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants