Debian Codegraph @

third_party/rust/object/tests/read/coff.rs

raw
1 use object::{pe, read, Object, ObjectSection};
2 use std::fs;
3 use std::path::PathBuf;
4
5 #[cfg(feature = "coff")]
6 #[test]
7 fn coff_extended_relocations() {
8 let path_to_obj: PathBuf = ["testfiles", "coff", "relocs_overflow.o"].iter().collect();
9 let contents = fs::read(path_to_obj).expect("Could not read relocs_overflow.o");
10 let file =
11 read::coff::CoffFile::<_>::parse(&contents[..]).expect("Could not parse relocs_overflow.o");
12 let code_section = file
13 .section_by_name(".text")
14 .expect("Could not find .text section in relocs_overflow.o");
15 match code_section.flags() {
16 object::SectionFlags::Coff { characteristics } => {
17 assert!(characteristics & pe::IMAGE_SCN_LNK_NRELOC_OVFL != 0)
18 }
19 _ => panic!("Invalid section flags flavour."),
20 };
21 let relocations = code_section.relocations().collect::<Vec<_>>();
22 assert_eq!(relocations.len(), 65536);
23 }