We need some sort of code relocation table.
However, since everyone has their own Executable Image format, it'll probably be a waste of time trying to implement it in a specific manner. What I suggest is that you have an option for users to add custom passes or something of this sort so that they can recognize places where code should be relocated and generate appropriate metadata in a table.
Not sure how exactly it should be done, but like I said it should be highly configurable.