forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build script to extract a list of registered syscalls
The list is used in cargo-build-bpf to check generated .so modules for undefined symbols that are not known run-time syscalls.
- Loading branch information
Showing
6 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use regex::Regex; | ||
use std::{ | ||
fs::File, | ||
io::{prelude::*, BufWriter, Read}, | ||
path::PathBuf, | ||
process::exit, | ||
str, | ||
}; | ||
|
||
/** | ||
* Extract a list of registered syscall names and save it in a file | ||
* for distribution with the SDK. This file is read by cargo-build-bpf | ||
* to verify undefined symbols in a .so module that cargo-build-bpf has built. | ||
*/ | ||
fn main() { | ||
let path = PathBuf::from("src/syscalls.rs"); | ||
let mut file = match File::open(&path) { | ||
Ok(x) => x, | ||
_ => exit(1), | ||
}; | ||
let mut text = vec![]; | ||
file.read_to_end(&mut text).unwrap(); | ||
let text = str::from_utf8(&text).unwrap(); | ||
let path = PathBuf::from("../../sdk/bpf/syscalls.txt"); | ||
let file = match File::create(&path) { | ||
Ok(x) => x, | ||
_ => exit(1), | ||
}; | ||
let mut out = BufWriter::new(file); | ||
let sysc_re = Regex::new(r#"register_syscall_by_name\([[:space:]]*b"([^"]+)","#).unwrap(); | ||
for caps in sysc_re.captures_iter(&text) { | ||
writeln!(out, "{}", caps[1].to_string()).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/dependencies/bin* | ||
/dependencies/.crates.toml | ||
/dependencies/.crates2.json | ||
/syscalls.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters