So I don't know if this is a bug with rust codegen or if this is a bug in my code. I recently upgraded to rustc 1.59.0-nightly (b60e32c82 2021-12-30) and switched my kernel to use the x86_64-uknown-none target. I also upgraded some dependencies (I don't think I upgraded log though...). But when it boots now, when it tries to set the logger via log::set_logger or log::set_logger_racy, it immediately triple-faults. Setting the logger is the very first thing the kernel does (its first function call) after taking control of the system and entering kmain, so I'm extremely confused on why this is happening. The disassembly of the code is equally as strange:
Looks like the target spec uses the pic instead of pie relocation model. In that case the GOT needs to be initialized before any code that may attempt to use it runs. This should probably changed to use the pie reloc model.
Also, how do you override the relocation model? I tried to set rustflags in .cargo/config.toml but it doesn't appear like its being respected. I don't want to make my own custom target definition -- I just want to override this one setting.