Commit Graph
71 Commits
Author SHA1 Message Date
topjohnwu 66bcdaf4e0 magiskboot: support building on host
Allow magiskboot to be built directly on host platforms (macOS and
Linux) using Cargo:
- Add a binary target to boot module with a no_main entry point that
  directly reuses the C main CLI implementation.
- Compile native C and C++ sources (base, boot, cxx, and lz4) via cc in
  base and boot build.rs when target_os is not Android.
- Platform gate Linux-specific functionality (SELinux xattrs, mount,
  namespaces) in base on Linux and Android, and provide macOS fallback
  for xsendfile.
- Move MountInfo and mount parsing from files to mount module.
- Scope Android-specific LTO rustflags in config.toml to Android
  targets.
- Ensure build.py compiles Rust modules as static libraries (--lib).

Assisted-by: Gemini 3.8 Flash
2026-10-02 17:17:48 -07:00
topjohnwu 89d3100ffc Update cargo dependencies 2026-09-20 02:21:59 -07:00
topjohnwu 584ba3227e Update cargo dependencies 2026-09-04 09:44:49 -07:00
topjohnwu 15062974a3 magiskboot: allow free zImage piggy payload size
Support dynamic zImage piggy payload sizes during repacking by updating
the zImage decompressor stub headers, symbol tables, and GOT entries.

Previously, magiskboot padded repacked zImage files to preserve the
exact original file size. For non-gzip compressed zImages (such as XZ),
repacking with a different payload size broke stub symbol resolution
and resulted in ununpackable or unbootable images.

Key changes:
- Encapsulate zImage parsing and patching in a dedicated struct ZImage
  in Rust with CXX FFI, new_head, and new_tail methods.
- Locate piggy_end using table references or GOT table entries bounded
  by LC0.
- Relocate LC0 table entries, LC1 table, and GOT table entries with
  4-byte padding/alignment when payload size changes.
- Relocate R_ARM_GOTPC PC-relative literal pools in decompressor .text.
- Append uncompressed size for non-gzip algorithms per size_append.
- Remove zopfli compression support across magiskboot as dynamic zImage
  piggy sizing supersedes the need for exact size matching.

Fix #9880

Assisted-by: Gemini 3.7 Flash
2026-08-25 19:09:29 +00:00
topjohnwu de60431a0d magiskboot: port find_dtb_offset to Rust
Port find_dtb_offset from C++ to Rust in dtb.rs, using the fdt crate
for header parsing and root node validation.

Key changes:
- Upgrade fdt crate to 0.2.0-alpha2 and adapt dtb.rs to updated APIs.
- Implement find_dtb_offset using Fdt::new_unaligned_fallible.
- Define MIN_NON_EMPTY_DTB_SIZE (0x48) per Linux kernel ARM zImage
  specification to ignore empty or false positive DTB headers.
- Expose find_dtb_offset to C++ via CXX bridge and clean up legacy
  structs and declarations.

Assisted-by: Gemini 3.7 Flash
2026-08-25 19:09:29 +00:00
topjohnwu a581038608 Update cargo dependencies 2026-07-31 22:57:41 -07:00
topjohnwu 2f4bb0149e Update cargo dependencies 2026-04-08 05:29:57 +00:00
topjohnwu 74ead75ce8 Update cargo dependencies 2026-02-22 14:39:46 -08:00
topjohnwu 33eaa7c5eb Update cargo dependencies 2025-12-12 11:42:45 -08:00
topjohnwu 8734423cb0 Update to ONDK r29.4 2025-12-12 11:42:45 -08:00
topjohnwu ff4ca74cfe Ban all unwrap usage in codebase 2025-12-08 23:31:04 -08:00
topjohnwu 283fc0f46f Update cargo dependencies 2025-11-28 21:00:48 -08:00
topjohnwu 97c93a1f4d Smaller release binary size 2025-11-27 02:00:54 -08:00
topjohnwu 1599bfc2c5 Update dependencies 2025-11-02 13:52:32 -08:00
topjohnwu 4ee2235961 Update dependencies 2025-10-20 10:30:09 -07:00
topjohnwu b72ba6759e Vendor argh sources
Further customization will come in future commits
2025-10-19 17:15:30 -07:00
topjohnwu 0dc8231585 Make all dependencies workspace = true 2025-10-19 17:15:30 -07:00
topjohnwu bcc6296d94 Build debug without debug-info 2025-10-03 00:16:17 -07:00
topjohnwu ed206c6480 Upgrade cargo dependencies 2025-09-26 23:37:45 -07:00
topjohnwu 5925a71f94 Upgrade cargo dependencies 2025-09-24 03:05:18 -07:00
topjohnwu 0222527a1e Use bitflags macro 2025-09-11 01:17:34 -07:00
topjohnwu ef4e230258 Use nix for libc functions 2025-09-08 23:59:29 -07:00
topjohnwu a75c335261 Update cargo dependencies 2025-09-08 02:24:01 -07:00
topjohnwu d472e9c36e Update cargo dependencies 2025-08-28 22:01:35 -07:00
LoveSy 78f5cd55c7 Use lzma-rust2 for xz and lzma compression and decompression 2025-08-24 00:23:55 -07:00
topjohnwu 466e4bd4e1 Update cargo dependencies 2025-07-11 02:04:33 -07:00
topjohnwu 65d1c5827c Update dependencies 2025-06-10 16:33:06 -07:00
topjohnwu 898580bf90 Update dependencies 2025-06-02 19:51:12 -07:00
topjohnwu 78d1200608 Migrate all compression code to Rust 2025-05-20 03:26:00 -07:00
topjohnwu cb08504fe5 Update cargo dependencies 2025-04-11 14:48:16 -07:00
topjohnwu 1523ed9f78 Always go through rustup proxies 2025-04-01 10:01:35 -07:00
topjohnwu a396abf565 Minor changes
[skip ci]
2025-03-22 01:16:51 -07:00
LoveSy 12a0870bc9 Replace bzip2 with bz2-rs 2025-03-08 14:37:17 -08:00
LoveSy bd0e954fea Replace zlib with zlib-rs 2025-03-07 11:40:02 -08:00
topjohnwu 675471a49e Upgrade argh to stable release 2025-03-07 02:38:36 -08:00
topjohnwu c90e73ccec Migration to Edition 2024 2025-03-07 02:35:25 -08:00
topjohnwu a43c1267d8 Update Cargo.toml 2025-03-07 02:35:25 -08:00
topjohnwu ab86732c89 Implement simple serialization over IPC 2025-02-02 22:08:41 +08:00
topjohnwu 4d4195c02d Migrate prune_su_access to Rust 2025-01-11 00:11:48 +08:00
topjohnwu 9e26b73813 Update rust dependencies 2024-12-09 18:26:39 -08:00
topjohnwu 1701361a73 Update cargo dependencies 2024-08-03 01:49:14 -07:00
topjohnwu 1539cfe888 Support setting custom ABI list
Also stop building riscv64 by default
2024-08-01 14:33:08 -07:00
topjohnwu 606d076251 Build debug with thin lto 2024-07-31 17:00:01 -07:00
LoveSy 6d82515cfc No default features of pb-rs 2024-07-20 20:29:38 -07:00
topjohnwu 92b2e06e57 Increase cgu on debug builds 2024-07-20 04:59:20 -07:00
topjohnwu f57839379a Update RustCrypto dependencies 2024-04-03 21:03:05 -07:00
LoveSy 36bd00a046 Add p521 to magiskboot 2024-04-03 21:03:05 -07:00
topjohnwu 1eddbfd72c Use const_format for const strings 2024-03-26 18:03:40 -07:00
LoveSy 62fc7868ac Use self implemented parse_mount_info 2024-02-27 17:03:22 -08:00
topjohnwu 1a70796339 Replace all parse_mount_info usage with Rust 2024-02-27 03:49:17 -08:00