-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathMakefile.toml
81 lines (65 loc) · 3.68 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[config]
skip_core_tasks = true
[env]
# Target platforms
TARGET_GNU = "x86_64-pc-windows-gnu"
TARGET_MSVC = "x86_64-pc-windows-msvc"
# Flags for GNU PIC and EXE builds
RUSTFLAGS_GNU_PIC = "-C link-arg=-nostdlib -C codegen-units=1 -C link-arg=-fno-ident -C link-arg=-fpack-struct=8 -C link-arg=-Wl,--gc-sections -C link-arg=-falign-jumps=1 -C link-arg=-w -C link-arg=-falign-labels=1 -C relocation-model=pic -C link-arg=-Wl,-T./Linker.ld,--build-id=none -C link-arg=-Wl,-s,--no-seh,--enable-stdcall-fixup -C link-arg=-Wl,--subsystem,console -C link-arg=-nostartfiles -C link-arg=-Wl,-e_start"
RUSTFLAGS_GNU_EXE = "-C link-arg=-nostdlib -C link-arg=-Wl,--gc-sections -C link-arg=-Wl,--subsystem,console -C link-arg=-nostartfiles -C link-arg=-Wl,-e_start"
# Flags for MSVC builds
RUSTFLAGS_MSVC_PIC = "-C codegen-units=1 -C strip=symbols -C opt-level=z -C link-arg=/NODEFAULTLIB -C link-arg=/ENTRY:_start -C link-arg=/SUBSYSTEM:CONSOLE -C link-arg=/OPT:REF,ICF -C link-arg=/SAFESEH:NO -C link-arg=/DEBUG:NONE -C link-arg=/FILEALIGN:512 -C link-arg=/ALIGN:16 -C link-arg=/SECTION:.bss,D -C link-arg=/SECTION:.edata,D -C link-arg=/SECTION:.idata,D -C link-arg=/SECTION:.pdata,D -C link-arg=/SECTION:.xdata,D"
[tasks.default]
description = "Default build task: builds the project as a GNU executable."
dependencies = ["build"]
[tasks.build]
description = "Builds the project as a GNU executable, strips unnecessary sections."
dependencies = ["clean", "cargo-build", "strip"]
[tasks.clean]
description = "Cleans the project directory, removing old binaries."
script = [
"cargo clean"
]
[tasks.cargo-build]
description = "Compiles the project for the GNU target (exe)."
command = "rustup"
args = ["run", "nightly-2025-02-13-x86_64-pc-windows-gnu", "cargo", "rustc", "--target", "${TARGET_GNU}", "--release", "--features", "${FEATURES}"]
env = { "RUSTFLAGS" = "${RUSTFLAGS_GNU_EXE}" }
[tasks.strip]
description = "Strips unneeded sections from the GNU binary."
command = "strip"
args = ["-s", "--strip-unneeded", "-x", "-X", "target/${TARGET_GNU}/release/RustiveDump.exe"]
[tasks.pic-gnu]
description = "Builds the project as Shellcode (PIC) for the GNU target."
dependencies = ["cleanpic", "cargo-build-pic-gnu", "strip", "objcopy"]
[tasks.cleanpic]
description = "Cleans the project and removes the old PIC binary."
script = [
"cargo clean",
"rm -f RustiveDump.bin"
]
[tasks.cargo-build-pic-gnu]
description = "Compiles the project as PIC for the GNU target."
command = "rustup"
args = ["run", "nightly-2025-02-13-x86_64-pc-windows-gnu", "cargo", "rustc", "--target", "${TARGET_GNU}", "--release", "--features", "${FEATURES}"]
env = { "RUSTFLAGS" = "${RUSTFLAGS_GNU_PIC}" }
[tasks.objcopy]
description = "Converts the GNU binary to a .bin file using objcopy."
command = "objcopy"
args = ["-O", "binary", "target/${TARGET_GNU}/release/RustiveDump.exe", "RustiveDump.bin"]
[tasks.pic-msvc]
description = "Builds the project as Shellcode (PIC) for the MSVC target."
dependencies = ["clean", "cargo-build-pic-msvc", "strip-msvc", "objcopy-msvc"]
[tasks.cargo-build-pic-msvc]
description = "Compiles the project as PIC for the MSVC target."
command = "rustup"
args = ["run", "nightly-2025-02-13-x86_64-pc-windows-msvc", "cargo", "rustc", "--target", "${TARGET_MSVC}", "--release", "--features", "${FEATURES}"]
env = { "RUSTFLAGS" = "${RUSTFLAGS_MSVC_PIC}" }
[tasks.strip-msvc]
description = "Strips unneeded sections from the MSVC binary."
command = "strip"
args = ["-s", "--strip-unneeded", "-x", "-X", "target/${TARGET_MSVC}/release/RustiveDump.exe"]
[tasks.objcopy-msvc]
description = "Converts the MSVC binary to a .bin file using objcopy."
command = "objcopy"
args = ["-O", "binary", "target/${TARGET_MSVC}/release/RustiveDump.exe", "RustiveDump.bin"]