This is the mail archive of the
mailing list for the newlib project.
Re: Question : i386's crt0 ?
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: Jeff Johnston <jjohnstn at redhat dot com>
- Cc: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Mon, 29 Apr 2013 11:55:24 -0500
- Subject: Re: Question : i386's crt0 ?
- References: <CAFAwnGP8Xp752=rKFOFBpuD89cqRhMooYcmSeO_1u9sZZeaRAA at mail dot gmail dot com> <517EA520 dot 5020806 at redhat dot com>
On 4/29/2013 11:51 AM, Jeff Johnston wrote:
On 04/22/2013 03:26 PM, Julio Guerra wrote:
I am trying find out why crt0.S is not provided for i386 target as it
is the case with, for example, powerpc's. If we consider it is
supposed to initialize the C runtime, I don't understand why I should
write it myself since every i386's crt0 will do the same : stack
pointer initialization, constructor calls, etc. I really need hints
about that, it looks like I missed something...
Thank you !
Well, the short answer is that no one has submitted one.
The long answer is that historically, newlib started out as a C Library
for embedded tool ports by Cygnus Solutions. Native platforms such as
i386 Linux were expected to use glibc with gcc supplying crt0.o.
An x86-linux port has been added for for newlib (see libc/sys/linux) if
you are using Linux. There is also a Cygmon port of libgloss in
So, you could certainly put something together from the Cygmon
cygmon-crt0.S or use the crt0.o from gcc (which the sys/linux port uses).
For the other minimum newlib syscalls required, you can use libnosys if
you do not have an OS. This will create failure stubs for most things
except for sbrk which expects you to set up a variable in your linkage
script. For _exit, you can cause an exception to occur (e.g. divide by
I would add that RTEMS is also an option on x86 hardware. That would give
you bare metal with RTOS capabilities. Plus you wouldn't have to write a
crt0 or any of the device drivers.
-- Jeff J.
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985