Skip to content

[Bug] Parsing elf notes does not use the System V ABI spec recommended alignment #71

@iulianbarbu

Description

@iulianbarbu

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions