Skip to content

Commit

Permalink
copy/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 change the elfcopy example to use Builder, and add some
more options.
  • Loading branch information
philipc committed Jan 15, 2024
1 parent 69d3879 commit ac21aaf
Show file tree
Hide file tree
Showing 12 changed files with 2,462 additions and 1,026 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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 copy
- 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 copy_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 Expand Up @@ -92,7 +93,7 @@ jobs:
with:
submodules: true
- name: Install rust
run: rustup update 1.65.0 && rustup default 1.65.0
run: rustup update 1.70.0 && rustup default 1.70.0
- name: Test
run: cargo test --verbose --features all

Expand Down
8 changes: 6 additions & 2 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 copy support. You will need to enable some file formats too.
copy_core = ["read_core", "write_core"]
# Copy support for all file formats.
copy = ["copy_core", "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", "copy", "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", "copy_core",
"std", "compression",
"archive", "coff", "elf", "macho", "pe", "wasm", "xcoff",
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Changes to MSRV are considered breaking changes. We are conservative about chang
but sometimes are required to due to dependencies. The MSRV is:

* 1.60.0 for the `read` feature and its dependencies.
* 1.65.0 for other features.
* 1.70.0 for other features.

## License

Expand Down
8 changes: 6 additions & 2 deletions crates/examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.0.0"
edition = "2018"

[dependencies]
anyhow = "1.0.79"
bumpalo = "3.14.0"
clap = { version = "4.3.24", optional = true }
memmap2 = "0.7.1"
object = { path = "../..", default-features = false }

Expand All @@ -13,9 +16,10 @@ glob = "0.3"
[features]
read = ["object/read"]
write = ["object/write"]
copy = ["object/copy", "dep:clap"]
wasm = ["object/wasm"]
xcoff = ["object/xcoff"]
all = ["read", "write", "wasm", "xcoff"]
all = ["read", "write", "copy", "wasm", "xcoff"]
unstable-all = ["all"]
default = ["read"]

Expand All @@ -29,7 +33,7 @@ required-features = ["object/read"]

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

[[bin]]
name = "elftoefi"
Expand Down
Loading

0 comments on commit ac21aaf

Please sign in to comment.