Open bahorn opened 2 months ago
I merged some partial work where i got stage2
and stage1-uefi-bootservices-hook
merged together as two object files that get linked together, and removed the one symbol we needed to pass to the kshelf-loader during build.
The kshelf-loader can't generally be linked in as another .o, but not really a big deal.
Main problem I have now is I want to define all the symbols stage2
and stage1-uefi-bootservices-hook
and just search+replace them into the binaries, but that doesn't seem simple to do. Parsing relocations and manually resolving them? Really want to generate a R_X86_64_COPY
or something.
You can't just define them in a seperate .o and link against that, as we copy stage2 into various locations.
This is also a blocker on making the testing script parallel, as a unique runtime needs to be built for each kernel image.
src/runtime
uses a very adhoc aproach for building the payload:src/scripts
which process kalllsyms and the kernel binary to find symbols and space.stage1-uefi-bootservices-hook
, which means we have to search and find the bios patch inside that. (origin forsrc/runtime/fill_in.py
)I think I need to replace badlink with something better, and just compile each stage to ELFs or something and do another step to merge them together in a way that they can be modified at patching time.
The end goal is to be able to merge everything into a single python script / executable.
What we are using scripts for right now:
In
src/runtime/stage1-uefi-bootservices-hook/Makefile
:These are only used in the direct patching approach (avoiding the runtime hook). Unsure if I want to remove direct patching as I like the option in newer kernels to apply it.
In
src/runtime/stage2/Makefile
:In
src/runtime/kshelf-loader/Makefile
:Used to work out the relative offset from
.text
, which stage2 passes to it via an argument.In
src/skp.sh
:To use a offset to place the payload.
What is badlink being used for
Badlink kinda sucks and only has 6 character symbol names...
uefi_e
, our new uefi entrypointbios_e
, our new bios entrypointuefi_o
, our original uefi entrypointcode32
, offset to our code32 hooko_dest
, offset to the destination where the code32 hook shoo_bios
, offset to our bios_entry?o_tocp
, offset to copy?o_ptch
, offset to patch?