473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

calling convention adopted by the gcc compiler for the C programs

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

Jul 14 '06 #1
6 1529
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.
Jul 14 '06 #2
priyanka (in 11*********************@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.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto
Jul 14 '06 #3

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

Jul 14 '06 #4
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.
Jul 14 '06 #5

"priyanka" <pr**********@gmail.comwrote in message
news:11*********************@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:
http://en.wikipedia.org/wiki/Calling_convention

More in depth info on register usage:
http://my.execpc.com/CE/AC/geezer/osd/libc/

Rod Pemberton

Jul 15 '06 #6
"Skarmander" <in*****@dontmailme.comwrote in message
news:44***********************@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

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin
--
Posted via a free Usenet account from http://www.teranews.com

Jul 17 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
13
by: RainBow | last post by:
Hi everyone, (Very Sorry, if this is the wrong group in which I am posting this query). Code snippet: //C library typedef int (*PFunc)(int* aArg); void call_c_foo(PFunc aPtrtoFunc) {
16
by: aarklon | last post by:
Hi folks, recently i read the book named assembly language step by step by Jeff Duntemann. in the chapter coding for linux, he has got a paragraph named C calling conventions, which he...
14
by: 42 | last post by:
Hi, Stupid question: I keep bumping into the desire to create classes and properties with the same name and the current favored naming conventions aren't automatically differentiating them......
0
by: Carl Colijn | last post by:
Hi all, Disclaimer: before I might trigger your "let's start a holy war!" button, I'd like to say I'm not intended to; I just post this message to get some input and not to promote "Yet Another...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
10
by: sulekhasweety | last post by:
Hi, the following is the definition for calling convention ,which I have seen in a text book, can anyone give a more detailed explanation in terms of ANSI - C "the requirements that a...
6
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.