From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <70DCC09F-5B5A-4801-AA60-728D86E3CCEC@kix.in> From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-Reply-To: <20080508172816.4B2D71E8C55@holo.morphisms.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Fri, 9 May 2008 00:49:06 +0530 References: <20080508172816.4B2D71E8C55@holo.morphisms.net> Subject: Re: [9fans] _tos puzzle Topicbox-Message-UUID: a38e0f9c-ead3-11e9-9d60-3106f5b1d025 >> So I have to allocate 56 bytes (sizeof(Tos) on 386) of space above >> the >> top of stack (before copying argc and argv) and set AX to that >> address, correct? > > Yes. And you need to maintain it. > At the very least you need to initialize tos->pid > and update it on return from rfork. I set EAX before starting the executable, but still no luck :( On Plan 9, for /bin/mk: acid: symbols("_tos") _tos D 0x00016084 acid: mem(0x00016084, "X") 0xdfffefc8 I'm probing address 0x16084 on linux after every instruction (using ptrace's singlestep), and it consistently returns 0. EIP at the beginning of the program is 0x9fe4, and sure enough: acid: asm(0x9fe4) _main SUBL $0x48, SP _main+0x3 MOVL AX, _tos(SB) ... So (MOVL, _tos(SB)) is definitely executed, but for some reason, the value of AX is not stored in 0x16084. That brings me to the question of how 8a decides what address to put values like that in? Is the address the same everytime, i.e. hardcoded into the binary? (certainly seems to be) I strip the symbol table from plan 9 executables and store only data, text and initialize bss in memory - maybe that has something to do with it. Does the symbol table need to be in memory too for instructions like (MOVL AX, _tos(SB)) to work? Regards, Anant