I want to know about C-startup Routine contents and its modification

R

Ramaraj

Hi All,

I am very interest to know the c-startup routine (like GNU gcc C-startup
routine). and it s working principle and How this function is attached to
operating system


Thanks in adavance.

with regards
Ramaraj
 
M

Morris Dovey

Ramaraj said:
I am very interest to know the c-startup routine (like GNU gcc
C-startup routine). and it s working principle and How this
function is attached to operating system

Ramaraj...

The startup function is platform/implementation specific and not
a standardized part of the C language. Why not take a look at the
compiler and library documentation?

For gcc, you can actually look at the source code and answer your
own question more quickly than anyone here could provide you with
a complete answer.
 
D

Dan Pop

In said:
Ramaraj...

The startup function is platform/implementation specific and not
a standardized part of the C language. Why not take a look at the
compiler and library documentation?

In my experience, people asking this kind of questions should better
spend their time actually learning C. By the time you actually understand
what really C is about, the interest for such issues is very likely to
vanish: as a C programmer, you couldn't care less.

By the time you're confronted with writing a C startup module yourself,
you have enough clues to realise that c.l.c is one of the last newsgroups
to ask for help.

Dan
 
M

Morris Dovey

Dan said:
In <[email protected]> Morris Dovey


In my experience, people asking this kind of questions should
better spend their time actually learning C. By the time you
actually understand what really C is about, the interest for
such issues is very likely to vanish: as a C programmer, you
couldn't care less.

True - except that at one point I found myself writing a startup
function for an embedded system (along with the code to produce
argc and argv along with a split 'shell', half of which ran on an
NT system and half on the SoC under test).
By the time you're confronted with writing a C startup module
yourself, you have enough clues to realise that c.l.c is one
of the last newsgroups to ask for help.

/Usually/ true. I didn't search to see if Ramaraj is new to c.l.c
- I just assumed that he found himself in a situation similar to
that described above. Note that /I/ didn't bring my issue to
c.l.c - although I did e-mail a c.l.c regular (after consulting
several of my favorite search engines) to ask if he was aware of
any available solutions to a related device usage problem.
 
D

Dan Pop

In said:
True - except that at one point I found myself writing a startup
function for an embedded system (along with the code to produce
argc and argv along with a split 'shell', half of which ran on an
NT system and half on the SoC under test).


/Usually/ true. I didn't search to see if Ramaraj is new to c.l.c
- I just assumed that he found himself in a situation similar to
that described above.

Nope, he was explicitly talking about hosted implementations, where one
seldom gets to write a startup module. See the underlined text above.

Freestanding implementations are a completely different issue, as each
case has unique requirements:

- is there any main function?

- if yes, does it take any arguments?

- is there any initialisation code executed before the startup module?

- is the program supposed to ever terminate?

- etc etc etc

Dan
 
M

Morris Dovey

Nope, he was explicitly talking about hosted implementations,
where one seldom gets to write a startup module. See the
underlined text above.

Oops! You're right (bad assumption on my part) - thanks for
underlining. Suddenly I'm in complete agreement. :)
 
S

Sandeep

The C startup routine does the following:
- Initialize all global variables to 0
- Call standard library init
- Prepares argc and argv
- Calls main

Sandeep
 
M

Morris Dovey

Sandeep said:
The C startup routine does the following:
- Initialize all global variables to 0
- Call standard library init
- Prepares argc and argv
- Calls main

Sandeep...

Perhaps (more or less; possibly more /and/ less :)

[less] One would hope that the compiler emits code that
pre-initializes all globals;

[more] If the startup function calls main directly, then it will
also need to provide for main's return.

This /is/ off-topic for comp.lang.c because nearly every aspect
of the subject is platform/implementation dependent; and the OP's
question has nothing to do with the C language itself; but rather
with a particular implementation (gcc) whose startup function is
likely to vary at least somewhat for each target platform.

Since the OP didn't specify a platform, providing a list of
specifics is almost certainly a misleading response - however
well-intended.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top