A Primer On Dynamic Loading

[Graphitemaster] is helping to┬ádemystifying┬áthe process of tailoring functions for dynamic loading. His tutorial shows how make a dynamic function that prints “Hello World” to the standard output. This is of course rudimentary, but if you have no prior experience with the topic you might be surprised at what actually goes into it.

Normally your compiled code has addresses in it that tell the processor where to go next. The point of dynamic loading is that the code can be put anywhere, and so static addresses simply will not work. The code above shows how a simple printf statement normally compiles. The callq line is a system call that needs to be replaced with something that will play nicely in the registers. [Graphitemaster] takes it slow in showing how to do this. Of course a dynamic function alone isn’t going to be much good. So the tutorial finishes by illustrating how to program a dynamic code loader.