Re: [Hampshire] More deep-down difficulties...

Top Page

Reply to this message
Author: Jim Nicholson
Date:  
To: lug, Hampshire LUG Discussion List
CC: 
Subject: Re: [Hampshire] More deep-down difficulties...

On 21 Nov 2007, at 17:33, Vic wrote:

> Hi All.
>
> I'm having a right old day of it. Another one I can't suss out :-(
>
> I'm writing a bit of code that will be dynamically linked against
> libc.
> And I need to work out my command-line arguments. Simple? Not for
> me...
>
> The thing is - I can't just read argc/argv; I don't have them. I'm not
> writing this in C.


What language are you writing it in? Most of the have some mechanism
for getting the command line arguments.

>
> So does anyone know how Linux communicates argc/argv to a process
> it runs?
> Is there a call I can make or something? Is there a data area I can
> read?
>


If you are linking against libc then I think you need to use the c
bootstrap code as well, that will get the command line arguments and
pass them to a main function that you define. It will also set up
the proper environment for the libc library (I think).

This http://asm.sourceforge.net/articles/startup.html article
explains how command line arguments are passed to ELF executables.

Jim