Skip to content

Commit

Permalink
Merge #38
Browse files Browse the repository at this point in the history
38: handle no units in linker script parser r=jonas-schievink a=japaric



Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
  • Loading branch information
bors[bot] and japaric authored May 21, 2021
2 parents 49a506e + 2bb4609 commit ce08b4c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ fn find_ram_in_linker_script(linker_script: &str) -> Option<MemoryEntry> {
total_length += length * 1024;
} else if unit == Some('M') {
total_length += length * 1024 * 1024;
} else if unit == None {
total_length += length;
}
}
return Some(MemoryEntry {
Expand All @@ -329,6 +331,32 @@ mod tests {
RAM : ORIGIN = 0x20000000, LENGTH = 64K
}
INCLUDE device.x
";

assert_eq!(
find_ram_in_linker_script(LINKER_SCRIPT),
Some(MemoryEntry {
line: 3,
origin: 0x20000000,
length: 64 * 1024,
})
);

assert_eq!(
get_includes_from_linker_script(LINKER_SCRIPT),
vec!["device.x"]
);
}

#[test]
fn parse_no_units() {
const LINKER_SCRIPT: &str = "MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 262144
RAM : ORIGIN = 0x20000000, LENGTH = 65536
}
INCLUDE device.x
";

Expand Down

0 comments on commit ce08b4c

Please sign in to comment.