-
Notifications
You must be signed in to change notification settings - Fork 59
Description
Currently, when parsing elf notes, the code relies on an alignment coming from the program header p_align
[1]. This alignment is used for elf segments alignment [2]. For the elf notes fields alignment the specification/toolchain implementations make use of other alignments [3].
The proposal would be to use the right alignment while parsing through the elf notes. What is right is a complex discussion, which implies approaches which do/or do not entirely follow the System V ABI. An assumption that we can make, that linux also has made, it is to always consider the elf notes alignment to be 4 bytes, but this is very dependent on the build toolchain used to produce the ELF binary. So even if the crate is called linux-loader, it is not necessarily the case to follow how linux kernel/applications handle this problem, but it is definitely a starting point.
[1] https://github.com/rust-vmm/linux-loader/blob/master/src/loader/x86_64/elf/mod.rs#L346-L347 and https://github.com/rust-vmm/linux-loader/blob/master/src/loader/x86_64/elf/mod.rs#L369.
[2] https://man7.org/linux/man-pages/man5/elf.5.html
[3] #70 (comment)