Skip to content

in place binary patching for runtime rust hotreloading

Notifications You must be signed in to change notification settings

jkelleyrtp/ipbp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipbp.rs - in place binary patching

it works

Patch rust functions at runtime with magic and linker hacks.

how it works

roughly:

  • diff object files
  • figure out what exactly changed
  • combine the changed object files using the dep map
  • figure out affected symbols and functions
  • package the .o files together into a single cursed dylib that tricks dlopen
  • disable a bunch of stuff like ASLR
  • dlopen that dylib at the same address as the program root itself such that our pic/pie code can work properly
  • resolve missing symbols against the running binary
  • tell the app that we've patched it and it should maybe try to do new stuff

and voila you have in-place binary patching for a running rust app.

Not only does completely circumvent the typical close, rebuild, relink, restart, reinitialize, resume flow, but it uses rust's incremental compiler WITHOUT LINKING - the only unnecessary cost we pay here is the compiler frontend + macro expansion. This is faster than pretty much anything else you could design.**

** currently uses the linker in a sort of pass-thru mode. we still need to handle compilation-level relocations. eventually will drop this entirely.

Notes

ummmmmmmmmmmmmmmm

can't we just define the existing symbols - except for the target - from the already resolved symbols in space?

About

in place binary patching for runtime rust hotreloading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages