Skip to content

Commit

Permalink
build/elf: add Builder
Browse files Browse the repository at this point in the history
The Builder can be created from an existing ELF file, modified,
and then written out again.

Also replace the elfcopy example with a rewrite example that
uses Builder, and add some more options.
  • Loading branch information
philipc committed Feb 20, 2024
1 parent 09d8d57 commit 7fdc88b
Show file tree
Hide file tree
Showing 27 changed files with 16,190 additions and 1,225 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
run: |
rustup install ${{matrix.rust_channel}}
rustup default ${{matrix.rust_channel}}
- name: Check
run: |
cargo check --all-targets --features all
cargo check --all-targets -p object-rewrite
- name: Test debug
run: |
cargo test --verbose --features all
Expand All @@ -39,8 +43,9 @@ jobs:
submodules: true
- run: cargo test --no-default-features --features read
- run: cargo test --no-default-features --features write
- run: cargo test --no-default-features --features build
- run: cargo test --no-default-features --features read_core,write_core,coff
- run: cargo test --no-default-features --features read_core,write_core,elf
- run: cargo test --no-default-features --features build_core,elf
- run: cargo test --no-default-features --features read_core,write_core,macho
- run: cargo test --no-default-features --features read_core,write_core,pe
- run: cargo test --no-default-features --features read_core,wasm
Expand Down
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ write_core = ["dep:crc32fast", "dep:indexmap", "dep:hashbrown"]
write_std = ["write_core", "std", "indexmap?/std", "crc32fast?/std"]
# Write support for all file formats, including libstd features.
write = ["write_std", "coff", "elf", "macho", "pe", "xcoff"]
# Core builder support. You will need to enable some file formats too.
build_core = ["read_core", "write_core"]
# Builder support for all file formats.
build = ["build_core", "write_std", "elf"]

#=======================================
# Misc features.
Expand Down Expand Up @@ -75,7 +79,7 @@ default = ["read", "compression"]
#=======================================
# Umbrella feature for enabling all user-facing features of this crate. Does not
# enable internal features like `rustc-dep-of-std`.
all = ["read", "write", "std", "compression", "wasm"]
all = ["read", "write", "build", "std", "compression", "wasm"]

# Use of --all-features is not supported.
# This is a dummy feature to detect when --all-features is used.
Expand All @@ -84,7 +88,7 @@ cargo-all = []
#=======================================
# Documentation should be generated with everything in "all" except for "unaligned".
doc = [
"read_core", "write_std",
"read_core", "write_std", "build_core",
"std", "compression",
"archive", "coff", "elf", "macho", "pe", "wasm", "xcoff",
]
Expand All @@ -100,6 +104,6 @@ unstable-all = ["all", "unstable"]
rustc-dep-of-std = ['core', 'compiler_builtins', 'alloc', 'memchr/rustc-dep-of-std']

[workspace]
members = ["crates/examples"]
members = ["crates/*"]
default-members = [".", "crates/examples"]
resolver = "2"
4 changes: 0 additions & 4 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ required-features = ["object/read_core", "object/archive"]
name = "dyldcachedump"
required-features = ["object/read"]

[[bin]]
name = "elfcopy"
required-features = ["object/read_core", "object/write_core", "object/elf", "object/std"]

[[bin]]
name = "elftoefi"
required-features = ["object/read_core", "object/write_core", "object/elf", "object/pe", "object/std"]
Expand Down

0 comments on commit 7fdc88b

Please sign in to comment.