Very nice blog post on how to write a fully position independent RDI/sRDI loader in C and ASM (credits @deadvolvo)