Skip to content

Commit

Permalink
Merge pull request coconut-svsm#286 from joergroedel/elf-fixes
Browse files Browse the repository at this point in the history
Elf fixes
  • Loading branch information
joergroedel authored Mar 9, 2024
2 parents c836348 + bd2b63c commit 869e2bd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions kernel/src/elf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,11 @@ impl<'a> Elf64File<'a> {
return Err(ElfError::InvalidSectionIndex);
}

let file_range = shdr.file_range();
if file_range.offset_end > elf_file_buf_len {
return Err(ElfError::FileTooShort);
if shdr.sh_type != Elf64Shdr::SHT_NOBITS {
let file_range = shdr.file_range();
if file_range.offset_end > elf_file_buf_len {
return Err(ElfError::FileTooShort);
}
}

Ok(())
Expand Down Expand Up @@ -1196,11 +1198,23 @@ bitflags! {

impl Elf64Phdr {
/// Represents a null program header type
pub const PT_NULL: Elf64Word = 1;
pub const PT_NULL: Elf64Word = 0;
/// Represents a loadable segment program header type
pub const PT_LOAD: Elf64Word = 1;
/// Represents a dynamic segment program header type
pub const PT_DYNAMIC: Elf64Word = 2;
/// Represents a interpreter program header type
pub const PT_INTERP: Elf64Word = 3;
/// Represents a Note program header type
pub const PT_NOTE: Elf64Word = 4;
/// Represents a Shared Library program header type
pub const PT_SHLIB: Elf64Word = 5;
/// Represents the Program Header Table itself
pub const PT_PHDR: Elf64Word = 6;
/// Processor-specific entries lower bound
pub const PT_LOPROC: Elf64Word = 0x70000000;
/// Processor-specific entries upper bound
pub const PT_HIPROC: Elf64Word = 0x7fffffff;

/// Reads a program header from a byte buffer and returns an [`Elf64Phdr`] instance.
///
Expand Down

0 comments on commit 869e2bd

Please sign in to comment.