Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Andreas Jaeger <aj@suse.de>
To: sjhill@cotw.com
Cc: binutils@sources.redhat.com, linux-mips@oss.sgi.com, uclibc@uclibc.org
Subject: Re: Linux/MIPS and ELF dynamic linker/loader questions...
Date: Wed, 27 Mar 2002 22:09:00 +0100	[thread overview]
Message-ID: <hopu1pn2fn.fsf@gee.suse.de> (raw)
In-Reply-To: <3CA233B6.58DB8B08@cotw.com> ("Steven J. Hill"'s message of "Wed, 27 Mar 2002 15:03:50 -0600")

"Steven J. Hill" <sjhill@cotw.com> writes:

> Greetings.
>
> I am working on a MIPS dynamic linker/loader for uClibc and
> would appreciate some clarification on the finer points of
> ELF and the Linux kernel interface. Forgive the cross post.
>
> The first problem I have discovered is that the value of
> argc passed back to the userspace process from the Linux
> kernel is always zero. The argv, environment and auxillary
> vectors come through just fine. I have to loop through the
> stack manually to count the number of argument vectors in
> order to get argc:

In glibc I had no problems finding argc, check
sysdeps/mips/elf/start.S:

/* This is the canonical entry point, usually the first thing in the text
   segment.  The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
   point runs, most registers' values are unspecified, except for:

   v0 ($2)	Contains a function pointer to be registered with `atexit'.
		This is how the dynamic linker arranges to have DT_FINI
		functions called for shared libraries that have been loaded
		before this code runs.

   sp ($29)	The stack contains the arguments and environment:
		0(%esp)			argc
		4(%esp)			argv[0]
		...
		(4*argc)(%esp)		NULL
		(4*(argc+1))(%esp)	envp[0]
		...
					NULL
   ra ($31)	The return address register is set to zero so that programs
		that search backword through stack frames recognize the last
		stack frame.
*/


Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

      reply	other threads:[~2002-03-27 21:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27 21:03 Linux/MIPS and ELF dynamic linker/loader questions Steven J. Hill
2002-03-27 21:09 ` Andreas Jaeger [this message]

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=hopu1pn2fn.fsf@gee.suse.de \
    --to=aj@suse.de \
    --cc=binutils@sources.redhat.com \
    --cc=linux-mips@oss.sgi.com \
    --cc=sjhill@cotw.com \
    --cc=uclibc@uclibc.org \
    /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