> main9.s sets _tos on entry.  why not just use _tos as
> the c glue code does?
>
> - erik
>
>

I'm already setting _tos on entry:
http://code.google.com/p/go/source/browse/src/pkg/runtime/plan9/386/rt0.s
TEXT _rt0_386_plan9(SB),7, $0
        MOVL    AX, _tos(SB)
        
        // move arguments down to make room for
        // m and g at top of stack, right before Tos.
...

the hard coded addresses are here:
http://code.google.com/p/go/source/browse/src/pkg/runtime/mkasmh.sh
case "$GOOS" in
...
        plan9)
                echo '#define   get_tls(r)'
                echo '#define   g(r)    0xdfffefc0'
                echo '#define   m(r)    0xdfffefc4'

which are easy enough to modify and here:
http://code.google.com/p/go/source/browse/src/cmd/8l/pass.c
^patch(void)
...
                        if(HEADTYPE == 2) {     // Plan 9
                                if(p->from.type == D_INDIR+D_GS
                                && p->to.type >= D_AX && p->to.type <= D_DI) {
                                        p->as = AMOVL;
                                        p->from.type = D_ADDR+D_STATIC;
                                        p->from.offset += 0xdfffefc0;
                                }
                        }

^dostkoff(void)
...
                        case 2: // Plan 9
                                p->as = AMOVL;
                                p->from.type = D_ADDR+D_STATIC;
                                p->from.offset = 0xdfffefc0;
                                p->to.type = D_CX;
                                break;


I am not that familiar with the linker, but maybe calling Sym*
lookup("_tos") and adding some code to to add instructions for
calculating the offset would work.

It was just easier for me to start working on a kvm vm...

Reply via email to