9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Anant Narayanan <anant@kix.in>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] _tos puzzle
Date: Fri,  9 May 2008 00:49:06 +0530	[thread overview]
Message-ID: <70DCC09F-5B5A-4801-AA60-728D86E3CCEC@kix.in> (raw)
In-Reply-To: <20080508172816.4B2D71E8C55@holo.morphisms.net>

>> 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




  parent reply	other threads:[~2008-05-08 19:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-08 16:18 Anant Narayanan
2008-05-08 16:41 ` Russ Cox
2008-05-08 17:13   ` Anant Narayanan
2008-05-08 17:24     ` Russ Cox
2008-05-08 17:40       ` Steven Vormwald
2008-05-08 19:19       ` Anant Narayanan [this message]
2008-05-08 20:33         ` Russ Cox
2008-05-09  5:30           ` Anant Narayanan
2008-05-09 13:08             ` Russ Cox
2008-05-08 17:50     ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70DCC09F-5B5A-4801-AA60-728D86E3CCEC@kix.in \
    --to=anant@kix.in \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).