|
Message
From: Balaji V. Iyer<bviyer@n...>
Date: Wed May 4 02:23:41 CEST 2005
Subject: [openrisc] Starting Stack Value and arguments passing
So in the _start function I attached, previously (I am attaching it again). The line that loads r3 with the address of r3-4 (I have indicated it in the below code address 0x100080 , what exactly is contained in R3 during the start? I looked through the FS directory and the only place where they have updated r3 is one function but it is #if to zero.
Thanks,
Balaji V. Iyer.
>> 0100016c <_start>: >> 100016c: 9c 21 ff f8 l.addi r1,r1,0xfffffff8 >> 1000170: d4 01 48 00 l.sw 0x0(r1),r9 >> 1000174: d4 01 10 04 l.sw 0x4(r1),r2 >> 1000178: 9c 41 00 08 l.addi r2,r1,0x8 >> 100017c: a8 a3 00 00 l.ori r5,r3,0x0 >> 1000180: 84 63 ff fc l.lwz r3,0xfffffffc(r3) <+++THIS LINE +++ >> 1000184: a8 85 00 00 l.ori r4,r5,0x0 >> 1000188: b9 83 00 02 l.slli r12,r3,0x2 >> 100018c: e0 a5 60 00 l.add r5,r5,r12 >> 1000190: 04 00 00 15 l.jal 10001e4 <___uClibc_main> >> 1000194: 9c a5 00 04 l.addi r5,r5,0x4 >> 1000198: 84 41 00 04 l.lwz r2,0x4(r1) >> 100019c: 85 21 00 00 l.lwz r9,0x0(r1) >> 10001a0: 44 00 48 00 l.jr r9 >> 10001a4: 9c 21 00 08 l.addi r1,r1,0x8
Matjaz Breskvar said: > * Balaji V. Iyer (bviyer@n...) wrote: >> Hello Everyone, >> I have a couple questions about stack and register values >> initialization. I am also "cut and pasting" a copy of the _start from >> the object dump of a simple file. My question is, what is the stack >> register (r1) initialized as? Also, when we have a main function like >> this: > > well this would depend on the OS. if you were running on uclinux userspace > stack would be somewhere in the uniform memory. On linux though userspace > stack is at the top of the user addressable space, just below 0x80000000 > in > or32 case. > >> int main(int argc, char *argv[]), How are the argc and argv passed into >> the function. In the below code, r3 is used, so what value does it >> originally contain? > > argv and argc are put on the userspace stack of program by kernel. (all > the > nasty details are in fs/binfmt_elf.c...) > > best regards, > p. > >> Here is the objdump: >> >> 0100016c <_start>: >> 100016c: 9c 21 ff f8 l.addi r1,r1,0xfffffff8 >> 1000170: d4 01 48 00 l.sw 0x0(r1),r9 >> 1000174: d4 01 10 04 l.sw 0x4(r1),r2 >> 1000178: 9c 41 00 08 l.addi r2,r1,0x8 >> 100017c: a8 a3 00 00 l.ori r5,r3,0x0 >> 1000180: 84 63 ff fc l.lwz r3,0xfffffffc(r3) >> 1000184: a8 85 00 00 l.ori r4,r5,0x0 >> 1000188: b9 83 00 02 l.slli r12,r3,0x2 >> 100018c: e0 a5 60 00 l.add r5,r5,r12 >> 1000190: 04 00 00 15 l.jal 10001e4 <___uClibc_main> >> 1000194: 9c a5 00 04 l.addi r5,r5,0x4 >> 1000198: 84 41 00 04 l.lwz r2,0x4(r1) >> 100019c: 85 21 00 00 l.lwz r9,0x0(r1) >> 10001a0: 44 00 48 00 l.jr r9 >> 10001a4: 9c 21 00 08 l.addi r1,r1,0x8 > _______________________________________________ > http://www.opencores.org/mailman/listinfo/openrisc >
|
 |