- Rust 98.8%
- TypeScript 1.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
CI / generate-matrix (push) Has been cancelled
CI / FreeBSD / test (stable) (push) Has been cancelled
CI / OpenBSD / test (stable) (push) Has been cancelled
CI / NetBSD / examples (stable) (push) Has been cancelled
CI / DragonFly BSD / examples (stable) (push) Has been cancelled
CI / success (push) Has been cancelled
Big changes: - AIX in link-section - UEFI - Win7/UWP and other windows platforms - Fallback support for other OSes in ctor/dtor (use init_array/fini_array by default) |
||
| .cargo | ||
| .github | ||
| ctor | ||
| docs | ||
| dtor | ||
| link-section | ||
| linktime | ||
| linktime-proc-macro | ||
| macro-magic | ||
| scattered-collect | ||
| scattered-collect-proc-macro | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CHANGELOG.md | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
linktime
Cross-platform libraries for link-time initialization, finalization and collection in Rust.
| crate | docs | version |
|---|---|---|
linktime |
||
ctor |
||
dtor |
||
link-section |
Crates
The linktime project comprises three crates, and the top-level linktime
crate aggregates them all.
Pick-and-choose, or import the top-level crate to get all three.
ctor
Module initialization functions for Rust (like __attribute__((constructor)) in C/C++).
Run code before main to initialize data, external resources, or other state.
[dependencies]
linktime = { version = "...", features = ["ctor"] } # note: already enabled by default
# or
ctor = "..."
use linktime::ctor; // or ctor::ctor
use libc_print::*;
#[ctor(unsafe)]
fn foo() {
libc_println!("Life before main!");
}
dtor
Module shutdown functions for Rust (like __attribute__((destructor))).
Run code after main to clean up resources, or perform other final operations.
[dependencies]
linktime = { version = "...", features = ["dtor"] } # note: already enabled by default
# or
dtor = "..."
use linktime::dtor; // or dtor::dtor
use libc_print::*;
#[dtor(unsafe)]
fn foo() {
libc_println!("Life after main!");
}
link-section
Typed and untyped link section support for Rust.
Collect related items from an entire linked binary into a single link section.
[dependencies]
linktime = { version = "...", features = ["link-section"] } # note: already enabled by default
# or
link-section = "..."
use linktime::link_section::{section, in_section, TypedSection};
use linktime::ctor;
use libc_print::*;
#[section]
static FOO: TypedSection<fn()>;
#[in_section(FOO)]
fn foo() {
libc_println!("Hello, world!");
}
#[ctor(unsafe)]
fn print_numbers() {
for f in FOO {
f();
}
}
Contributing
Contributions are welcome!
License
These projects are dual-licensed under the Apache License, Version 2.0 and the MIT License.