|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
use memory::Frame;
|
|
|
|
|
use multiboot2::ElfSection;
|
|
|
|
|
|
|
|
|
|
pub struct Entry(u64);
|
|
|
|
|
|
|
|
|
@ -45,3 +46,26 @@ bitflags! {
|
|
|
|
|
const NO_EXECUTE = 1 << 63,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl EntryFlags {
|
|
|
|
|
pub fn from_elf_section_flags(section: &ElfSection) -> EntryFlags {
|
|
|
|
|
use multiboot2::{ELF_SECTION_ALLOCATED, ELF_SECTION_WRITABLE,
|
|
|
|
|
ELF_SECTION_EXECUTABLE};
|
|
|
|
|
|
|
|
|
|
let mut flags = EntryFlags::empty();
|
|
|
|
|
|
|
|
|
|
if section.flags().contains(ELF_SECTION_ALLOCATED) {
|
|
|
|
|
// section is loaded to memory
|
|
|
|
|
flags = flags | PRESENT;
|
|
|
|
|
}
|
|
|
|
|
if section.flags().contains(ELF_SECTION_WRITABLE) {
|
|
|
|
|
flags = flags | WRITABLE;
|
|
|
|
|
}
|
|
|
|
|
if !section.flags().contains(ELF_SECTION_EXECUTABLE) {
|
|
|
|
|
flags = flags | NO_EXECUTE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flags
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|