I'm trying to determine PLM4's address on OpenBSD-4.1 Release on amd64. So, i'm looking into sys/arch/amd64/amd64/locore.S.

There is a point where PML4 is set (line 519):

        /*
         * 3. Load %cr3 with pointer to PML4.
         */
        movl    %esi,%eax
        movl    %eax,%cr3

I do a backwards search to find the latest value that %esi was loaded and find this (line 389):

        /* Clear tables */
        movl    %edi,%esi
        addl    $PGOFSET,%esi
        andl    $~PGOFSET,%esi

So, i need to find the value of %edi. Register %edi was last set here (line 381):

        /* Save the symbols (if loaded). */
        movl    RELOC(esym),%eax
        testl   %eax,%eax
        jz      1f
        subl    $KERNBASE_LO,%eax       /* XXX */
        movl    %eax,%edi

esym is defined here (line 195):

_C_LABEL(esym):         .quad   0       # ptr to end of syms

If 'esym' equals to zero, then %eax seems to get loaded with a negative address (movl RELOC(esym),%eax) that equals to -ffffffff80000000. I am aware that OpenBSD-amd64 is build with the gcc flag "-mcmodel=kernel". Does this mean that the address -ffffffff80000000 is translated to 80000000? Or does 'esym' get a non-zero value from somewhere else?

Thanks,
Constantine

Reply via email to