Skip to content

Commit 2ac3315

Browse files
author
Calvin Lee
authored
Merge pull request #33 from ahmedcharles/bitflags
Update to the 1.0.0 version of bitflags.
2 parents d02190e + 484e501 commit 2ac3315

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ authors = ["Philipp Oppermann <[email protected]>", "Calvin Lee <[email protected]
55
license = "MIT/Apache-2.0"
66
description = "An experimental Multiboot 2 crate for ELF-64/32 kernels."
77

8-
[dependencies.bitflags]
9-
version = "0.4.0"
10-
features = ["no_std"]
8+
[dependencies]
9+
bitflags = "1.0.0"

src/elf_sections.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl ElfSection {
173173
}
174174

175175
pub fn is_allocated(&self) -> bool {
176-
self.flags().contains(ELF_SECTION_ALLOCATED)
176+
self.flags().contains(ElfSectionFlags::ALLOCATED)
177177
}
178178

179179
fn get(&self) -> &ElfSectionInner {
@@ -269,10 +269,10 @@ pub enum ElfSectionType {
269269
}
270270

271271
bitflags! {
272-
flags ElfSectionFlags: u32 {
273-
const ELF_SECTION_WRITABLE = 0x1,
274-
const ELF_SECTION_ALLOCATED = 0x2,
275-
const ELF_SECTION_EXECUTABLE = 0x4,
272+
pub struct ElfSectionFlags: u32 {
273+
const WRITABLE = 0x1;
274+
const ALLOCATED = 0x2;
275+
const EXECUTABLE = 0x4;
276276
// plus environment-specific use at 0x0F000000
277277
// plus processor-specific use at 0xF0000000
278278
}

src/lib.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use core::fmt;
55
use header::{Tag, TagIter};
66
pub use boot_loader_name::BootLoaderNameTag;
77
pub use elf_sections::{ElfSectionsTag, ElfSection, ElfSectionIter, ElfSectionType, ElfSectionFlags};
8-
pub use elf_sections::{ELF_SECTION_WRITABLE, ELF_SECTION_ALLOCATED, ELF_SECTION_EXECUTABLE};
98
pub use memory_map::{MemoryMapTag, MemoryArea, MemoryAreaIter};
109
pub use module::{ModuleTag, ModuleIter};
1110
pub use command_line::CommandLineTag;
@@ -143,8 +142,7 @@ impl fmt::Debug for BootInformation {
143142
#[cfg(test)]
144143
mod tests {
145144
use super::load;
146-
use super::{ElfSectionFlags, ELF_SECTION_EXECUTABLE, ELF_SECTION_ALLOCATED, ELF_SECTION_WRITABLE};
147-
use super::ElfSectionType;
145+
use super::{ElfSectionFlags, ElfSectionType};
148146

149147
#[test]
150148
fn no_tags() {
@@ -513,35 +511,35 @@ mod tests {
513511
assert_eq!(0xFFFF_8000_0010_0000, s1.start_address());
514512
assert_eq!(0xFFFF_8000_0010_3000, s1.end_address());
515513
assert_eq!(0x0000_0000_0000_3000, s1.size());
516-
assert_eq!(ELF_SECTION_ALLOCATED, s1.flags());
514+
assert_eq!(ElfSectionFlags::ALLOCATED, s1.flags());
517515
assert_eq!(ElfSectionType::ProgramSection, s1.section_type());
518516
let s2 = s.next().unwrap();
519517
assert_eq!(".text", s2.name());
520518
assert_eq!(0xFFFF_8000_0010_3000, s2.start_address());
521519
assert_eq!(0xFFFF_8000_0010_C000, s2.end_address());
522520
assert_eq!(0x0000_0000_0000_9000, s2.size());
523-
assert_eq!(ELF_SECTION_EXECUTABLE | ELF_SECTION_ALLOCATED, s2.flags());
521+
assert_eq!(ElfSectionFlags::EXECUTABLE | ElfSectionFlags::ALLOCATED, s2.flags());
524522
assert_eq!(ElfSectionType::ProgramSection, s2.section_type());
525523
let s3 = s.next().unwrap();
526524
assert_eq!(".data", s3.name());
527525
assert_eq!(0xFFFF_8000_0010_C000, s3.start_address());
528526
assert_eq!(0xFFFF_8000_0010_E000, s3.end_address());
529527
assert_eq!(0x0000_0000_0000_2000, s3.size());
530-
assert_eq!(ELF_SECTION_ALLOCATED | ELF_SECTION_WRITABLE, s3.flags());
528+
assert_eq!(ElfSectionFlags::ALLOCATED | ElfSectionFlags::WRITABLE, s3.flags());
531529
assert_eq!(ElfSectionType::ProgramSection, s3.section_type());
532530
let s4 = s.next().unwrap();
533531
assert_eq!(".bss", s4.name());
534532
assert_eq!(0xFFFF_8000_0010_E000, s4.start_address());
535533
assert_eq!(0xFFFF_8000_0011_3000, s4.end_address());
536534
assert_eq!(0x0000_0000_0000_5000, s4.size());
537-
assert_eq!(ELF_SECTION_ALLOCATED | ELF_SECTION_WRITABLE, s4.flags());
535+
assert_eq!(ElfSectionFlags::ALLOCATED | ElfSectionFlags::WRITABLE, s4.flags());
538536
assert_eq!(ElfSectionType::Uninitialized, s4.section_type());
539537
let s5 = s.next().unwrap();
540538
assert_eq!(".data.rel.ro", s5.name());
541539
assert_eq!(0xFFFF_8000_0011_3000, s5.start_address());
542540
assert_eq!(0xFFFF_8000_0011_3000, s5.end_address());
543541
assert_eq!(0x0000_0000_0000_0000, s5.size());
544-
assert_eq!(ELF_SECTION_ALLOCATED | ELF_SECTION_WRITABLE, s5.flags());
542+
assert_eq!(ElfSectionFlags::ALLOCATED | ElfSectionFlags::WRITABLE, s5.flags());
545543
assert_eq!(ElfSectionType::ProgramSection, s5.section_type());
546544
let s6 = s.next().unwrap();
547545
assert_eq!(".symtab", s6.name());

0 commit comments

Comments
 (0)