From 8a9dbec05ec1bafabb7d8e46729bd622048f4a21 Mon Sep 17 00:00:00 2001 From: Shane Dabirsiaghi Date: Thu, 11 Dec 2025 18:17:17 -0500 Subject: [PATCH 1/5] - removed redundant cfg - fixed ptrace path - added cargo tests for aarch64 in rust.yml - replaced mod with is_multiple in coredump to address warning --- .github/workflows/rust.yml | 10 ++++++++-- elfcore/src/arch/aarch64.rs | 4 +--- elfcore/src/coredump.rs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2d01a0c..98c6598 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,22 +14,28 @@ jobs: strategy: matrix: features: ["", "--no-default-features"] + target: ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Install deps run: ./ci/install_deps.sh + - name: Add rust target + run: rustup target add ${{ matrix.target }} || true - name: Format run: cargo fmt --all -- --check - name: Check - run: cargo check --all-features --all-targets + run: cargo check --target ${{ matrix.target }} --all-features --all-targets - name: Clippy - run: cargo clippy --all-features --all-targets -- -D warnings + run: cargo clippy --target ${{ matrix.target }} --all-features --all-targets -- -D warnings - name: Build + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: cargo build --verbose ${{ matrix.features }} - name: Run tests + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: cargo test --verbose ${{ matrix.features }} - name: Run basic dump creation test + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: ./ci/test.sh miri: diff --git a/elfcore/src/arch/aarch64.rs b/elfcore/src/arch/aarch64.rs index fea8e41..505d5c7 100644 --- a/elfcore/src/arch/aarch64.rs +++ b/elfcore/src/arch/aarch64.rs @@ -3,14 +3,12 @@ //! Aarch64 specifics for ELF core dump files. -#![cfg(target_arch = "aarch64")] - use super::ArchComponentState; use crate::CoreError; use zerocopy::AsBytes; #[cfg(target_os = "linux")] -use crate::ptrace::ptrace_get_reg_set; +use crate::linux::ptrace::ptrace_get_reg_set; #[cfg(target_os = "linux")] use nix::unistd::Pid; diff --git a/elfcore/src/coredump.rs b/elfcore/src/coredump.rs index 047ebb8..1b276a9 100644 --- a/elfcore/src/coredump.rs +++ b/elfcore/src/coredump.rs @@ -307,7 +307,7 @@ fn round_up(value: usize, alignment: usize) -> usize { return 0; } - if value % alignment != 0 { + if !value.is_multiple_of(alignment) { (value + alignment) / alignment * alignment } else { value From e922efbde76696ffe867c4240e12dfdffdb052fb Mon Sep 17 00:00:00 2001 From: Shane Dabirsiaghi Date: Thu, 11 Dec 2025 18:42:48 -0500 Subject: [PATCH 2/5] run entire build on both x86_64 and arm --- .github/workflows/rust.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 98c6598..a6efd0e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,14 +14,16 @@ jobs: strategy: matrix: features: ["", "--no-default-features"] - target: ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"] - runs-on: ubuntu-latest + include: + - runner: ubuntu-latest + target: x86_64-unknown-linux-gnu + - runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 - name: Install deps run: ./ci/install_deps.sh - - name: Add rust target - run: rustup target add ${{ matrix.target }} || true - name: Format run: cargo fmt --all -- --check - name: Check @@ -29,13 +31,10 @@ jobs: - name: Clippy run: cargo clippy --target ${{ matrix.target }} --all-features --all-targets -- -D warnings - name: Build - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: cargo build --verbose ${{ matrix.features }} - name: Run tests - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: cargo test --verbose ${{ matrix.features }} - name: Run basic dump creation test - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} run: ./ci/test.sh miri: From 8507db0f2a5c8142e9a69be52ad3f103f191ac01 Mon Sep 17 00:00:00 2001 From: Shane Dabirsiaghi Date: Fri, 12 Dec 2025 09:04:41 -0500 Subject: [PATCH 3/5] update tests for architecture register counts --- elfcore/src/coredump.rs | 6 ++++++ elfcore/src/lib.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/elfcore/src/coredump.rs b/elfcore/src/coredump.rs index 1b276a9..868f225 100644 --- a/elfcore/src/coredump.rs +++ b/elfcore/src/coredump.rs @@ -1125,6 +1125,9 @@ mod tests { cmd_line: "".to_string(), arch_state: Box::new(ArchState { + #[cfg(target_arch = "aarch64")] + gpr_state: vec![0; 34], + #[cfg(target_arch = "x86_64")] gpr_state: vec![0; 27], components: vec![], }), @@ -1181,6 +1184,9 @@ mod tests { cmd_line: "".to_string(), arch_state: Box::new(ArchState { + #[cfg(target_arch = "aarch64")] + gpr_state: vec![0; 34], + #[cfg(target_arch = "x86_64")] gpr_state: vec![0; 27], components: vec![], }), diff --git a/elfcore/src/lib.rs b/elfcore/src/lib.rs index 92316ab..56168b5 100644 --- a/elfcore/src/lib.rs +++ b/elfcore/src/lib.rs @@ -125,6 +125,9 @@ pub trait ReadProcessMemory { /// cmd_line: "example".to_string(), /// /// arch_state: Box::new(ArchState { +/// #[cfg(target_arch = "aarch64")] +/// gpr_state: vec![0; 34], +/// #[cfg(not(target_arch = "aarch64"))] /// gpr_state: vec![0; 27], /// components: vec![], /// }), From 33030f8ca2be6628473db8541cf2ca22e03df246 Mon Sep 17 00:00:00 2001 From: Shane Dabirsiaghi Date: Fri, 12 Dec 2025 09:12:29 -0500 Subject: [PATCH 4/5] update build matrix for all combinations --- .github/workflows/rust.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a6efd0e..143836e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,12 +13,19 @@ jobs: build: strategy: matrix: - features: ["", "--no-default-features"] include: - runner: ubuntu-latest target: x86_64-unknown-linux-gnu + features: "" + - runner: ubuntu-latest + target: x86_64-unknown-linux-gnu + features: "--no-default-features" + - runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + features: "" - runner: ubuntu-24.04-arm target: aarch64-unknown-linux-gnu + features: "--no-default-features" runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v3 From fec80078a77dfb46217dbbd6cf3a559b699467ee Mon Sep 17 00:00:00 2001 From: Shane Dabirsiaghi Date: Fri, 12 Dec 2025 11:01:10 -0500 Subject: [PATCH 5/5] simplified test matrix --- .github/workflows/rust.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 143836e..0e43fa4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,16 +15,12 @@ jobs: matrix: include: - runner: ubuntu-latest - target: x86_64-unknown-linux-gnu features: "" - runner: ubuntu-latest - target: x86_64-unknown-linux-gnu features: "--no-default-features" - runner: ubuntu-24.04-arm - target: aarch64-unknown-linux-gnu features: "" - runner: ubuntu-24.04-arm - target: aarch64-unknown-linux-gnu features: "--no-default-features" runs-on: ${{ matrix.runner }} steps: @@ -34,9 +30,9 @@ jobs: - name: Format run: cargo fmt --all -- --check - name: Check - run: cargo check --target ${{ matrix.target }} --all-features --all-targets + run: cargo check --all-features --all-targets - name: Clippy - run: cargo clippy --target ${{ matrix.target }} --all-features --all-targets -- -D warnings + run: cargo clippy --all-features --all-targets -- -D warnings - name: Build run: cargo build --verbose ${{ matrix.features }} - name: Run tests