[En-Nut-Discussion] NutOS relocatable?

Nathan Moore nategoose at gmail.com
Thu Apr 7 19:25:29 CEST 2011


I believe that the way relocatable code usually works in C like psudo-code
is:

    CODE_BASE = PC & MODULE_CODE_MASK ;  // Calculates the base address for
the current module from the Program Counter's current value
    ADDR = CODE_BASE | FUNC_OFFSET;   // Calculate the address of the
desired function in the currently running code
    call ADDR;                                              // Call the
function at it's current location by function pointer stored in a register

I don't think that there is any real reason that NutOS couldn't run this
way, and I
don't know of any compiler limitations for this except that the compiler may
assume
an underlying OS's page size when generating the MODULE_CODE_MASK.

I don't know how to go about telling gcc how to do this correctly, though.

Nathan


More information about the En-Nut-Discussion mailing list