C/C++

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • calling convention adopted by the gcc compiler for the C programs

    6 answers - 495 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi there,
    I want to learn about the calling convention that is adopted by the gcc
    compiler for C programs ? I need to learn about it immidiately for
    finding out the parameters passed to registers when a function call is
    made and print out the values of the parameters. Can anyone give me
    some pointers or refer to some book that would be helpful ? I tried
    searching at google but did not find any useful papers or reference.
    Thank you,
    Priyanka
  • No.1 | | 663 bytes | |

    priyanka wrote:
    Hi there,

    I want to learn about the calling convention that is adopted by the gcc
    compiler for C programs ? I need to learn about it immidiately for
    finding out the parameters passed to registers when a function call is
    made and print out the values of the parameters. Can anyone give me
    some pointers or refer to some book that would be helpful ? I tried
    searching at google but did not find any useful papers or reference.
    A more obvious place to search would be at gcc.gnu.org The answer would
    depend (at least) on your target platform, which of course this list
    doesn't want to hear about.
  • No.2 | | 806 bytes | |

    priyanka (in 1152897369.905570.47830@75g2000cwc.googlegroups.co m)
    said:

    | Hi there,
    |
    | I want to learn about the calling convention that is adopted by the
    | gcc compiler for C programs ? I need to learn about it immidiately
    | for finding out the parameters passed to registers when a function
    | call is made and print out the values of the parameters. Can anyone
    | give me some pointers or refer to some book that would be helpful ?
    | I tried searching at google but did not find any useful papers or
    | reference.

    Priyanka

    Gcc provides an option to stop after generating assembly code (man
    gcc). Make a very short program with the call of interest - and
    examine the assembly code file. Warning: the convention may vary from
    processor to processor.
  • No.3 | | 910 bytes | |


    priyanka wrote:
    Hi there,

    I want to learn about the calling convention that is adopted by the gcc
    compiler for C programs ? I need to learn about it immidiately for
    finding out the parameters passed to registers when a function call is
    made and print out the values of the parameters. Can anyone give me
    some pointers or refer to some book that would be helpful ? I tried
    searching at google but did not find any useful papers or reference.

    What you want is called the Application Binary Interface [or something
    like that] the acronym is ABI.

    The compiler doesn't specify it. The platform does.

    Failing that you can always cheat and write a prototype for your
    function, call it and see what the GCC assembler looks like. That's
    the unofficial quick and dirty solution that seems to work for simple
    functions.

    Tom

  • No.4 | | 1184 bytes | |

    Tom St Denis wrote:
    priyanka wrote:
    >Hi there,
    >>

    >I want to learn about the calling convention that is adopted by the gcc
    >compiler for C programs ? I need to learn about it immidiately for
    >finding out the parameters passed to registers when a function call is
    >made and print out the values of the parameters. Can anyone give me
    >some pointers or refer to some book that would be helpful ? I tried
    >searching at google but did not find any useful papers or reference.
    >

    What you want is called the Application Binary Interface [or something
    like that] the acronym is ABI.

    The compiler doesn't specify it. The platform does.

    To be precise in a way that does matter, some interested parties writing
    code for the platform do.

    There's no such thing as "the" ABI for a platform (in contrast to, say, the
    register set) except that which is agreed upon by everyone. Unless, of
    course, one reverses things and takes up the position that the platform is
    *defined* by the ABI, which has its own problems.

    S.
  • No.5 | | 701 bytes | |


    "priyanka" <priyankabhar@gmail.comwrote in message
    news:1152897369.905570.47830@75g2000cwc.googlegrou ps.com
    Hi there,

    I want to learn about the calling convention that is adopted by the gcc
    compiler for C programs ? I need to learn about it immidiately for
    finding out the parameters passed to registers when a function call is
    made and print out the values of the parameters. Can anyone give me
    some pointers or refer to some book that would be helpful ? I tried
    searching at google but did not find any useful papers or reference.

    Read about the cdecl calling convention:

    More in depth info on register usage:

    Rod Pemberton

  • No.6 | | 1325 bytes | |

    "Skarmander" <invalid@dontmailme.comwrote in message
    news:44b7ec53$0$31642$e4fe514c@news.xs4all.nl
    There's no such thing as "the" ABI for a platform (in contrast to, say,
    the register set) except that which is agreed upon by everyone. Unless, of
    course, one reverses things and takes up the position that the platform is
    *defined* by the ABI, which has its own problems.

    I would say that position is the only logical one. Programs are generally
    incompatible with libraries using a different ABI, and a "platform" is (in
    the real world) a collection of libraries and programs, so for the platform
    to be functional it must use a single ABI or provide mechanisms for code
    using different ABIs to link (e.g. Win16/32 thunking).

    In that sense, Solaris x86, Linux x86, and Windows x86 are all different
    "platforms" even though they may be capable of running on the same hardware
    and, in some rare cases, using the same application source. I doubt you'd
    find too many people claiming those are all the same "platform".

    I'm not sure if Linux and the BSDs use the same x86 ABI; I think they do,
    but I also know they require special kernel support to run each others'
    binaries (though that may be due to syscall, not pure ABI, differences).

    S

Re: calling convention adopted by the gcc compiler for the C programs


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 0 =
QUESTION ON "C/C++"

EMSDN.COM