I’m compiling a rust project, and want to include some static with a value not known at compile time, which will only later be linked into a final executable.
I figured I should be able to create some type of ELF object file which holds the entire linked binary except for my static which is waiting to be linked.
I wrote a main.rs
file which has l:
extern "C" {
static MY_STATIC: u8;
}
I tried using cargo rustc -- --emit obj=out.o
, and it rightfully complains that MY_STATIC
is undefined. In generated out.o
so I tried linking that to some .o
which has MY_STATIC
to see what happens, and it seems out.so
has a lot if std
stuff still unlinked.