From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <314ea9d7e23ffbdf3d31c0a3dc3461ab@brasstown.quanstro.net> References: <20110111185536.GA6160@dinah> <20110112223102.GA5183@dinah> <314ea9d7e23ffbdf3d31c0a3dc3461ab@brasstown.quanstro.net> Date: Thu, 13 Jan 2011 01:28:05 +0200 Message-ID: From: Pavel Zholkover To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] plan9 go output faults on 9vx but ok on cpu Topicbox-Message-UUID: 953dc038-ead6-11e9-9d60-3106f5b1d025 > main9.s sets _tos on entry. =A0why 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) =09 // 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 =3D=3D 2) { // Plan 9 if(p->from.type =3D=3D D_INDIR+D_GS && p->to.type >=3D D_AX && p->to.type <=3D = D_DI) { p->as =3D AMOVL; p->from.type =3D D_ADDR+D_STATIC; p->from.offset +=3D 0xdfffefc0; } } ^dostkoff(void) ... case 2: // Plan 9 p->as =3D AMOVL; p->from.type =3D D_ADDR+D_STATIC; p->from.offset =3D 0xdfffefc0; p->to.type =3D 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...