flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > How to patch labels dynamically? |
Author |
|
comrade 06 Mar 2004, 22:12
you need to have relocations for system objects (kernel modules, drivers), much like DLL
|
|||
06 Mar 2004, 22:12 |
|
f0dder 08 Mar 2004, 15:01
I prefer relocations myself, but there's another approach as well - the one typically used by "shared libraries" in *u*x. You use a general-purpose register to point to the loaded imagebase, and access evreything relative to this. This is pretty annoying when coding at assembly level though, where with the GNU GCC compiler it's as easy as passing a command-line argument like "-fPIC".
It's not too bad "losing" a general-purpose register for this, you can always push/pop before and after critical loops where you need all the registers, code pieces could be moved dynamically around in memory if needed, and there's not the (very very tiny) overhead of relocating code on imagebase clashes. But again, annoying if you don't have automated tools to handle this for you. If coding my own OS, I would definitely support both methods - "support" for "-fPIC" style would be something like putting imagebase in EAX on program start (and well, an app could always use the "delta trick" to get the imagebase manually). |
|||
08 Mar 2004, 15:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.