mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Mess with build parameters to make component binary smaller
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
[unstable]
|
||||||
|
build-std = ["core", "std"]
|
||||||
|
build-std-features = ["optimize_for_size"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
cargo-features = ["trim-paths"]
|
cargo-features = ["trim-paths", "panic-immediate-abort"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "client"
|
name = "client"
|
||||||
@@ -21,6 +21,6 @@ strip = true # Strip symbols from the binary
|
|||||||
opt-level = "s" # Optimize for size
|
opt-level = "s" # Optimize for size
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "immediate-abort"
|
||||||
debug = false
|
debug = false
|
||||||
trim-paths = "all"
|
trim-paths = "all"
|
||||||
|
|||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
OBFUSCATION_KEY=abc123abc \
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
export BINARY=./target/release/libclient.so
|
||||||
|
|
||||||
|
|
||||||
|
declare -a headers=(
|
||||||
|
".gnu_debuglink" # - Debug information link
|
||||||
|
".comment" #- Compiler version info
|
||||||
|
".shstrtab" #- Section header string table (only needed by tools like readelf)
|
||||||
|
".note.gnu.bu" ".note.gnu.build-id" # - Build ID note
|
||||||
|
".eh_frame" ".eh_frame_hdr" # Exception handling info (can break C++ exceptions if removed)
|
||||||
|
".gnu.version" ".gnu.version_r" # Symbol versioning (may be needed for some shared libraries)
|
||||||
|
".gnu.hash" # Hash table for symbol lookup optimization
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: Implement FAKE section header comments and information
|
||||||
|
# Shuffle order of headers??
|
||||||
|
|
||||||
|
for section in "${headers[@]}"
|
||||||
|
do
|
||||||
|
strip --remove-section="$section" $BINARY
|
||||||
|
echo "Removed section header $section"
|
||||||
|
done
|
||||||
@@ -58,10 +58,11 @@ fn start_runtime(config: &'static RuntimeConfig) -> Result<Box<dyn ModuleRuntime
|
|||||||
Ok(Box::new(ClientRuntime::new(config)?))
|
Ok(Box::new(ClientRuntime::new(config)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn get_named_component() -> NamedComponent {
|
#[unsafe(no_mangle)]
|
||||||
NamedComponent {
|
pub fn get_components() -> Vec<NamedComponent> {
|
||||||
|
vec![NamedComponent {
|
||||||
name: MODULE_NAME,
|
name: MODULE_NAME,
|
||||||
get_interface: &get_interface,
|
get_interface: &get_interface,
|
||||||
start_runtime: &start_runtime,
|
start_runtime: &start_runtime,
|
||||||
}
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[unstable]
|
||||||
|
build-std = ["core", "std"]
|
||||||
|
build-std-features = ["optimize_for_size"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
cargo-features = ["trim-paths"]
|
cargo-features = ["trim-paths", "panic-immediate-abort"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "server"
|
name = "server"
|
||||||
@@ -20,6 +20,6 @@ strip = true # Strip symbols from the binary
|
|||||||
opt-level = "s" # Optimize for size
|
opt-level = "s" # Optimize for size
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "immediate-abort"
|
||||||
debug = false
|
debug = false
|
||||||
trim-paths = "all"
|
trim-paths = "all"
|
||||||
|
|||||||
@@ -1,7 +1,24 @@
|
|||||||
OBFUSCATION_KEY=abc123abc \
|
OBFUSCATION_KEY=abc123abc \
|
||||||
RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" \
|
cargo build --release
|
||||||
cargo +nightly bloat \
|
|
||||||
-Z build-std=std,panic_abort \
|
export BINARY=./target/release/libserver.so
|
||||||
-Z build-std-features="optimize_for_size" \
|
|
||||||
$@ \
|
|
||||||
--profile release
|
declare -a headers=(
|
||||||
|
".gnu_debuglink" # - Debug information link
|
||||||
|
".comment" #- Compiler version info
|
||||||
|
".shstrtab" #- Section header string table (only needed by tools like readelf)
|
||||||
|
".note.gnu.bu" ".note.gnu.build-id" # - Build ID note
|
||||||
|
".eh_frame" ".eh_frame_hdr" # Exception handling info (can break C++ exceptions if removed)
|
||||||
|
".gnu.version" ".gnu.version_r" # Symbol versioning (may be needed for some shared libraries)
|
||||||
|
".gnu.hash" # Hash table for symbol lookup optimization
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO: Implement FAKE section header comments and information
|
||||||
|
// Shuffle order of headers??
|
||||||
|
|
||||||
|
for section in "${headers[@]}"
|
||||||
|
do
|
||||||
|
strip --remove-section="$section" $BINARY
|
||||||
|
echo "Removed section header $section"
|
||||||
|
done
|
||||||
|
|||||||
Generated
+2
-2
@@ -494,9 +494,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.20"
|
version = "1.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
checksum = "62049b2877bf12821e8f9ad256ee38fdc31db7387ec2d3b3f403024de2034aea"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ chrono = "0.4.42"
|
|||||||
|
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = "1.0.145"
|
serde_json = "1.0.145"
|
||||||
|
|
||||||
libc = "0.2.177"
|
libc = "0.2.177"
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
crossbeam-channel = "0.5.15"
|
crossbeam-channel = "0.5.15"
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ use crate::config::RuntimeConfig;
|
|||||||
#[derive(Clone, Debug, Encode, Decode)]
|
#[derive(Clone, Debug, Encode, Decode)]
|
||||||
pub enum Announcement {
|
pub enum Announcement {
|
||||||
TestAnnouncement(String),
|
TestAnnouncement(String),
|
||||||
|
// GetRuntimes,
|
||||||
|
// GetRuntimesAck(usize),
|
||||||
|
|
||||||
GetRuntimes,
|
// StartRuntime(RuntimeConfig),
|
||||||
GetRuntimesAck(usize),
|
// StartRuntimeAck(bool),
|
||||||
|
|
||||||
StartRuntime(RuntimeConfig),
|
|
||||||
StartRuntimeAck(bool),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard();
|
const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub struct PayloadConfig {
|
|||||||
pub runtime_config: Vec<RuntimeConfig>,
|
pub runtime_config: Vec<RuntimeConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Encode, Decode)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RuntimeConfig {
|
pub struct RuntimeConfig {
|
||||||
pub parent_component: String,
|
pub parent_component: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|||||||
Generated
+2
@@ -667,6 +667,8 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
"rand",
|
||||||
|
"static_init",
|
||||||
"syn 2.0.109",
|
"syn 2.0.109",
|
||||||
"unshell-crypt",
|
"unshell-crypt",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" \
|
|||||||
cargo +nightly build \
|
cargo +nightly build \
|
||||||
-Z build-std=std,panic_abort \
|
-Z build-std=std,panic_abort \
|
||||||
-Z build-std-features="optimize_for_size" \
|
-Z build-std-features="optimize_for_size" \
|
||||||
--profile release $@
|
$@ \
|
||||||
|
--profile release
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ extern crate unshell_lib;
|
|||||||
#[dynamic]
|
#[dynamic]
|
||||||
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
||||||
id: symbol!("Test ID"),
|
id: symbol!("Test ID"),
|
||||||
components: unshell_lib::get_components(),
|
components: Vec::new(),
|
||||||
runtime_config: vec![RuntimeConfig {
|
runtime_config: vec![RuntimeConfig {
|
||||||
parent_component: symbol!("client").to_string(),
|
parent_component: symbol!("client").to_string(),
|
||||||
name: symbol!("client runtime").to_string(),
|
name: symbol!("client runtime").to_string(),
|
||||||
@@ -52,6 +52,8 @@ fn main() {
|
|||||||
// // modules.push(Module::new(&arg)?)
|
// // modules.push(Module::new(&arg)?)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// let modules = vec
|
||||||
|
|
||||||
// Run the manager, this is blocking.
|
// Run the manager, this is blocking.
|
||||||
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
|
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user