Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #69325

Re: [clang] -Os invalid content of argc+argv

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: [clang] -Os invalid content of argc+argv
Date 2015-09-04 09:15 -0700
Organization None to speak of
Message-ID <ln4mjaqhyr.fsf@kst-u.example.com> (permalink)
References <68a9e68b-dc3b-4c5e-8d01-bc91daaeb0f2@googlegroups.com> <20150903233124.38258cdb@maxa-pc> <lnbndjqda9.fsf@kst-u.example.com> <MPG.3052aca464f49aad5a@news.eternal-september.org>

Show all headers | View raw


Philip Lantz <prl@canterey.us> writes:
> Keith Thompson wrote:
>> Melzzzzz writes:
>> > I don't know about cygwin but argc/argv values are parsed with crt 
>> > on Linux. That is if you link with c runtime and write main in assembler
>> > you get already parsed values eg Linux passes values on stack but crt
>> > parses them into rdi,rsi registers...
>> > Probably on cygwin compiler parses those values therefore bug.
>> 
>> The command line is parsed by the shell, which then passes them to your
>> program using one of the exec*() functions.
>> 
>> The compiler doesn't parse your program's command line arguments
>> (because they don't exist yet).  It merely generates code that is able
>> to receive those arguments via the argc and argv parameters.
>
> Actually, Melzzzzz is right, although I can see why his description was 
> confusing.
>
> On Unix, execv doesn't create the values for argc and argv; it just 
> passes to the program the strings needed to populate argv. The C runtime 
> needs to interpret (or "parse") the strings received from the kernel and 
> create the values for argc and argv.

There are several steps between typing a command line at a shell prompt
and providing the arguments to the program via argc and argv.  On
Unix-like systems, the only one of those steps that IMHO can reasonably
be called "parsing" is done by the shellf

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[clang] -Os invalid content of argc+argv m.labanowicz@gmail.com - 2015-09-03 13:28 -0700
  Re: [clang] -Os invalid content of argc+argv Melzzzzz <mel@zzzzz.com> - 2015-09-03 23:31 +0200
    Re: [clang] -Os invalid content of argc+argv Keith Thompson <kst-u@mib.org> - 2015-09-03 16:43 -0700
      Re: [clang] -Os invalid content of argc+argv Melzzzzz <mel@zzzzz.com> - 2015-09-04 01:53 +0200
      Re: [clang] -Os invalid content of argc+argv Philip Lantz <prl@canterey.us> - 2015-09-03 20:15 -0700
        Re: [clang] -Os invalid content of argc+argv Keith Thompson <kst-u@mib.org> - 2015-09-04 09:15 -0700
          Re: [clang] -Os invalid content of argc+argv m.labanowicz@gmail.com - 2015-09-04 10:33 -0700
            Re: [clang] -Os invalid content of argc+argv Noob <root@127.0.0.1> - 2015-09-04 20:48 +0200

csiph-web