forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrmake.rs
More file actions
47 lines (42 loc) · 1.62 KB
/
rmake.rs
File metadata and controls
47 lines (42 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Test that various Mach-O `#[link_section]` values are parsed and passed on correctly by codegen
//! backends.
//@ only-apple
use run_make_support::{llvm_objdump, rustc};
fn main() {
rustc().input("foo.rs").crate_type("lib").arg("--emit=obj").run();
let stdout =
llvm_objdump().arg("--macho").arg("--private-headers").input("foo.o").run().stdout_utf8();
let expected = [
("__TEXT", "custom_code", "S_REGULAR", "PURE_INSTRUCTIONS"),
("__DATA", "__mod_init_func", "S_MOD_INIT_FUNC_POINTERS", "(none)"),
(
"__DATA",
"all_attributes",
"S_REGULAR",
"PURE_INSTRUCTIONS NO_TOC STRIP_STATIC_SYMS \
NO_DEAD_STRIP LIVE_SUPPORT SELF_MODIFYING_CODE DEBUG",
),
];
for (segment, section, section_type, section_attributes) in expected {
let mut found = false;
// Skip header.
for section_info in stdout.split("Section").skip(1) {
if section_info.contains(&format!("segname {segment}"))
&& section_info.contains(&format!("sectname {section}"))
{
assert!(
section_info.contains(&format!("type {section_type}")),
"should have type {section_type:?}"
);
assert!(
section_info.contains(&format!("attributes {section_attributes}\n")),
"should have attributes {section_attributes:?}"
);
found = true;
}
}
if !found {
panic!("could not find section {section} in binary");
}
}
}