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

Feature - Strict ELF parser #624

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

Lichtso
Copy link

@Lichtso Lichtso commented Oct 22, 2024

Alternative implementation of #605 for SIMD-0189

@Lichtso Lichtso force-pushed the feature/stricter_elf_parser branch 2 times, most recently from 095fff9 to d5a97fc Compare October 25, 2024 11:26
} else {
aligned = AlignedMemory::<{ HOST_ALIGN }>::from_slice(bytes);
aligned.as_slice()
match e_flags {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mapping will be updated in #602.

@Lichtso Lichtso force-pushed the feature/stricter_elf_parser branch 3 times, most recently from 893f914 to e1fd3c8 Compare October 30, 2024 14:51
@Lichtso Lichtso marked this pull request as ready for review October 30, 2024 14:56
let aligned;
let bytes = if is_memory_aligned(bytes.as_ptr() as usize, HOST_ALIGN) {
bytes
let e_flags = LittleEndian::read_u32(bytes.get(48..52).ok_or(ElfParserError::OutOfBounds)?);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a comment explaining these hardcoded numbers (48..52).

src/elf.rs Show resolved Hide resolved
src/elf.rs Show resolved Hide resolved
src/elf.rs Show resolved Hide resolved
src/elf.rs Show resolved Hide resolved
src/elf.rs Show resolved Hide resolved
tests/elfs/elf.ld Show resolved Hide resolved
types::{Elf64Ehdr, Elf64Shdr, Elf64Sym},
};

let aligned_memory = AlignedMemory::<{ HOST_ALIGN }>::from_slice(bytes);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still copying the ELF, ins't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, one is still required because of loader-v3 misalignment.

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