Skip to content

Commit

Permalink
Add a README entry about full static linking. (#18)
Browse files Browse the repository at this point in the history
Also, expose the c-gull "todo" feature.
  • Loading branch information
sunfishcode authored Oct 31, 2023
1 parent 414f57e commit 571e43f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = ["/.github", "ci"]
keywords = ["linux"]

[dependencies]
c-gull = { version = "0.15.10", default-features = false, features = ["eyra"] }
c-gull = { version = "0.15.14", default-features = false, features = ["eyra"] }

[dev-dependencies]
assert_cmd = "2.0.12"
Expand Down Expand Up @@ -53,3 +53,6 @@ experimental-relocate = ["c-gull/experimental-relocate"]

# Have eyra do `use std::*;` so that it can be used as `std`.
be-std = []

# Enable `todo!()` stubs for unimplemented functions.
todo = ["c-gull/todo"]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ Other examples include
[using min-sized-rust technique to produce small binaries]: https://github.com/sunfishcode/eyra/tree/main/example-crates/hello-world-small#readme
[adding Eyra as an optional dependency]: https://github.com/sunfishcode/eyra/tree/main/example-crates/eyra-optional-example#readme

## Fully static linking

Eyra executables don't depend on any dynamic libraries, however by default they
do still depend on a dynamic linker (eg. "/lib64/ld-linux-x86-64.so.2").

For fully static linking, there are currently two options:

- Build with
`RUSTFLAGS=-C target-feature=+crt-static -C relocation-model=static`. This
disables Position-Independent Executable (PIE) mode, which is
straightforward, however it loses the security benefits of
Address-Space Layout Randomization (ASLR).

- Build with `RUSTFLAGS=-C target-feature=+crt-static` and enable the
`experimental-relocate` feature. This allows PIE mode and ASLR to work,
however it does so by enabling an experimental implementation of
relocations. This code seems to be working in practice so far, however it
involves Rust code patching itself as it runs, which is outside of any Rust
semantics.

## Optional logging

Eyra has a `log` feature to enable Rust `log` tracing of program and thread
Expand Down

0 comments on commit 571e43f

Please sign in to comment.