Hello I am working on an OS for fun and have ran into some issues.
My kernel first gets mapped at the address the ELF header wants (0x200000 I think) and then gets remapped to a high address. This works except for when a GOT function or vtable function is called. Both of these contain absolute addresses. Since my final executable is statically linked I don't see any reason why both of these couldn't be offsets. Seems weird that "Position Independent" still contains absolute addresses, but maybe my understanding is lacking"
in my .cargo/config.toml:
rustflags = ["-Crelocation-model=pic"]
My target looks like:
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float",
"static_position_independent_executables": true
}
I have seen that in the rust codegen code it will promote PIC to PIE if all crates are executables, which since I am using other crates (spin, core, alloc, etc) this is not the case. I don't see why this should stop something from being PIE. But also I am not even sure that promoting to PIE is the solution.
Any ideas or suggestions?
Thanks!
