I have a set of static objects in my library that I need access to from my library_main()
in the example below. In C, I can put it in an ELF section, get the start and end address of the section and use pointer math to walk through the objects. Is there an idiomatic way of doing that in Rust?
Is there either a C-like ELF approach or any other recommended approach to this where I can just get a list / array of static objects in my lib?
fn foo() {
#[link_section = ".early_init"]
static FOO: usize = 10;
}
fn bar() {
#[link_section = ".early_init"]
static BAR: usize = 10;
}
fn library_main() {
// I need to access variables FOO and BAR here and do
// some initializations with them before I do anything else
}