Re: Command line arguments without argc and argv

From: Jirka Kosina (jikos_at_jikos.cz)
Date: 07/23/05


Date: Sat, 23 Jul 2005 14:37:00 +0200

On Sat, 23 Jul 2005, Jirka Kosina wrote:

> If it doesn't work for you, then it probably needs some tuning to your
> version of glibc (and dynamic linker specifically)
> This is how it behvaes on my fedora box without stack randomization

Or even simpler guys, this is probably more portable :)

int main()
{
        extern char **environ;
        char *** argvp;
        char ** argv;
        char * s;
        void * p;
        asm ("mov %%esp, %0" : "=r" (p));
        argvp = p;
        while (*argvp != environ)
                 argvp++;
        argvp--;
        argv = *argvp;
        for (s = *argv ; s ; s = *++argv)
                printf("%s\n", s);
        return 0;
}

-- 
JiKos.


Relevant Pages

  • Re: f90 with linux 2.6 kernel
    ... you have a package installed called lib-compat (glibc compatibility). ... older version of glibc then the 2.3 series that would be in Fedora. ... I've just installed fedora 1.92 (with 2.6.5 kernel) and am having ... compiles ok but code including allocatable arrays etc yields errors ...
    (comp.lang.fortran)
  • Re: running jk2ded 1.02
    ... Something about that binary is crashing the dynamic linker. ... *probably* a bug in the dynamic linker, and I suspect I know which bug ... If it's statically linked and you don't know what version of glibc it ... but it still supports it better than e.g. Solaris, ...
    (uk.comp.os.linux)
  • Re: running jk2ded 1.02
    ... Something about that binary is crashing the dynamic linker. ... *probably* a bug in the dynamic linker, and I suspect I know which bug ... If it's statically linked and you don't know what version of glibc it ... but it still supports it better than e.g. Solaris, ...
    (uk.comp.os.linux)
  • Re: Printer setup headache
    ... I firmly believe it is a problem between fedora and setup. ... the crash is happening somewhere in glibc. ... I'm using glibc-2.16-28.fc18 on a Mini-Laptop that is using same install DVD, and install of printer went off with no errors, it prints without any errors. ... the Printer Queue does not come up in Tray when doing a print job. ...
    (Fedora)
  • Re: Printer setup headache
    ... I firmly believe it is a problem between fedora and setup. ... the crash is happening somewhere in glibc. ... regression in glibc (though when the blame lies between some binary ...
    (Fedora)