Re: The generated binary code has different main?

From: Mike Frantzen (frantzen@w4g.org)
Date: 09/05/02


Date: Thu, 5 Sep 2002 00:06:45 -0400
From: Mike Frantzen <frantzen@w4g.org>
To: Minchu Mo <morris_minchu@iwon.com>


> I used cc compiler to compile a simple c code under solaris /sparc. The c
> code has main(int argc, char* argv[]) function as entry point as everybody
> knows.
> But when I run the generated code under adb, I found the main function
> under adb look like this:
> main(2,ffbefd0c,ffbefd18,20800,0,0)
> I know that:
> 2 is the number of arguments,
> ffbefd0c is *argv
> ffbefd18 is *envp,
> but what are 20800 and 0, 0 for?
> Anybody knows? Thanks

Sparc uses register windows. There are eight input registers %i0
through %i7. But %i6 is the frame pointer (actually the previous
functions stack pointer. And %i7 is used as the return pointer (which
was the previous functions program counter aka instruction pointer).

Thus the first six parameters are always passed in registers and the
debugger doesn't really have an easy way to determine how many were
actually passed or will actually be used.

The 20800 is probabley left over from a constructor, _init or the dl
hocus pocus.

.mike
frantzen@(nfr.com | cvs.openbsd.org | w4g.org)



Relevant Pages

  • Re: call by address vs. call by value
    ... pointer and a 16 bit relative pointer. ... So to load a value you first ... I know of one Fortran compiler (where ... > in registers is generally way faster than using pointers. ...
    (comp.lang.c)
  • Re: memset all bits to zero will let float/double to zero?
    ... If the compiler doesn't load a pointer value ... > OTOH, if the CPU has dedicated address registers, it may be that ALL ... the code generated by a C compiler has to be able to do ... registers for pointer assignment and equality comparison (unless it ...
    (comp.lang.c)
  • Re: switching context on MSP430
    ... registers R15,R14,R13 and R12on stack. ... are you aware that not every c compiler for the MSP430 ... Preemption vs Cooperation ... Another important decision to make is whether or not a real-time clock ...
    (comp.arch.embedded)
  • Re: Ive seen the future...and it works! (was: my view on this assembler is blah)
    ... The compiler has the advantage, granted, that it can "remember" what all ... the registers are...but "remembering" isn't the challenge here, ... registers with the CPU... ... The HLLs, though - shackled by a whole bunch of factors that they have to ...
    (alt.lang.asm)
  • Re: How to convert Infix notation to postfix notation
    ... and make all strings const save where the intent ... function whose contract is to change the string. ... the compiler "just" prevents the string ... try to do using the pointer you get. ...
    (comp.lang.c)