libc behind the curtain

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

libc behind the curtain

Metuki Sabhe
hello all,

when I build a simple C program, I see it is linked against:

crt1.o
crti.o
crtbegin.o
-lgcc
-lgcc_s
crtend.o
crtn.o

What are those files ? Where do they come from ?

(after I built glibc-2.5 I saw those files showed up in the build folder:
./csu/crti.S
./csu/crti.o
./csu/crt1.o
./csu/crtn.S
./csu/crtn.o
./nptl/crti.S
./nptl/crti.o
./nptl/crtn.S
./nptl/crtn.o
)

thank you !!
Metuki
Reply | Threaded
Open this post in threaded view
|

Re: libc behind the curtain

Mike Frysinger
On Monday 11 June 2007, Metuki Sabhe wrote:

> when I build a simple C program, I see it is linked against:
>
> crt1.o
> crti.o
> crtbegin.o
> -lgcc
> -lgcc_s
> crtend.o
> crtn.o
>
> What are those files ?
the crt files are the C RunTime files while the -l libraries are internal gcc
libraries

> Where do they come from ?

gcc's spec file ... run `gcc -dumpspecs`
-mike

signature.asc (844 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: libc behind the curtain

Metuki Sabhe
On 6/11/07, Mike Frysinger <[hidden email]> wrote:

> On Monday 11 June 2007, Metuki Sabhe wrote:
> > when I build a simple C program, I see it is linked against:
> >
> > crt1.o
> > crti.o
> > crtbegin.o
> > -lgcc
> > -lgcc_s
> > crtend.o
> > crtn.o
> >
> > What are those files ?
>
> the crt files are the C RunTime files while the -l libraries are internal gcc
> libraries

does the gcc libraries add code to the final executable too ?

where can I read the sources for the C RunTime files (i didn't find any crt*
in glibc-2.5) ?

Thank You
Metuki
Reply | Threaded
Open this post in threaded view
|

Re: libc behind the curtain

Mike Frysinger
On Monday 11 June 2007, Metuki Sabhe wrote:

> On 6/11/07, Mike Frysinger <[hidden email]> wrote:
> > On Monday 11 June 2007, Metuki Sabhe wrote:
> > > when I build a simple C program, I see it is linked against:
> > >
> > > crt1.o
> > > crti.o
> > > crtbegin.o
> > > -lgcc
> > > -lgcc_s
> > > crtend.o
> > > crtn.o
> > >
> > > What are those files ?
> >
> > the crt files are the C RunTime files while the -l libraries are internal
> > gcc libraries
>
> does the gcc libraries add code to the final executable too ?
only when it's needed ... give the linker -M to have ld print out a linker map
so you can see where everything is coming from and going to

> where can I read the sources for the C RunTime files (i didn't find any
> crt* in glibc-2.5) ?

start in the csu/ directory and work your way out from there
-mike

signature.asc (844 bytes) Download Attachment