-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile.toml
57 lines (43 loc) · 1.77 KB
/
Makefile.toml
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
48
49
50
51
52
53
54
55
56
57
[config]
skip_core_tasks = true
default_to_workspace = false
[env]
MINGW_X86_PREFIX = "i686-w64-mingw32-"
MINGW_X64_PREFIX = "x86_64-w64-mingw32-"
BOF_NAME = "rustbof"
[tasks.combine-objs]
script = "${MINGW_PREFIX}ld -T linker_script.ld --gc-sections -u ${ENTRY_PREFIX}entrypoint -i target/${RUST_TARGET}/release/deps/*.o -o ${BOF_NAME}.${BOF_ARCH}.o"
dependencies = ["generate-linker-script", "build"]
[tasks.strip-uneeded]
command = "${MINGW_PREFIX}strip"
args = ["--strip-unneeded", "${BOF_NAME}.${BOF_ARCH}.o"]
dependencies = ["combine-objs"]
[tasks.generate-linker-script]
script = "${MINGW_PREFIX}ld -i --verbose | sed -n '/^======/, /^======/p' | grep -v '=======' | sed 's/\\(*(.rdata)\\)/__rdata_start__ = .;\\n\\1\\n*(.rdata$.refptr.*)/' | sed 's/\\(*(.text)\\)/__text_start__ = .;\\n\\1/' | sed 's/\\(*(.data)\\)/__data_start__ = .;\\n\\1/' > linker_script.ld"
[tasks.build]
toolchain = "nightly"
install_crate = { rustup_component_name = "rust-src" }
command = "cargo"
args = ["build", "-p", "${BOF_NAME}", "--target", "${RUST_TARGET}", "--release"]
[tasks.clean-target]
command = "cargo"
args = ["clean"]
[tasks.clean-bof]
script = "rm -rf ${BOF_NAME}.*.o"
[tasks.clean-misc]
command = "rm"
args = ["-rf", "linker_script.ld"]
[tasks.clean]
dependencies = ["clean-target", "clean-bof", "clean-misc"]
[tasks.all]
dependencies = ["strip-uneeded"]
[tasks.cleanall]
dependencies = ["clean", "default"]
[tasks.default]
dependencies = ["build-x86", "build-x64"]
[tasks.build-x86]
env = {"MINGW_PREFIX" = "${MINGW_X86_PREFIX}", "RUST_TARGET" = "i686-pc-windows-gnu", "BOF_ARCH" = "x86", "ENTRY_PREFIX" = "_"}
run_task = "all"
[tasks.build-x64]
env = {"MINGW_PREFIX" = "${MINGW_X64_PREFIX}", "RUST_TARGET" = "x86_64-pc-windows-gnu", "BOF_ARCH" = "x64", "ENTRY_PREFIX" = ""}
run_task = "all"