1use std::{
5 fs::File,
6 io::{BufReader, Read},
7 path::Path,
8};
9
10pub fn parse_hex(src: &str) -> u64 {
11 u64::from_str_radix(src.trim_start_matches("0x"), 16).unwrap()
12}
13
14pub fn read_file_contents(file_path: &Path) -> String {
15 let mut file_contents = String::new();
16 let f = File::open(file_path).expect("Could not open input file");
17 BufReader::new(f)
18 .read_to_string(&mut file_contents)
19 .expect("Not able to read the whole contents of the file");
20
21 file_contents
22}
23
24pub fn is_noload_section(section_name: &str) -> bool {
25 if section_name == ".bss" {
26 return true;
27 }
28 if section_name == ".sbss" {
29 return true;
30 }
31 if section_name == "COMMON" {
32 return true;
33 }
34 if section_name == ".scommon" {
35 return true;
36 }
37
38 false
39}