Re: GCC C/C++ runtime library question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Ramadass, Ramanathan" <Ramanathan.Ramadass@xxxxxxxxxxxxxx> writes:

> I am trying to replace the standard C and C++ libraries which comes
> with a Linux distro with our own(licensed from a 3rd party vendor). We
> will be providing the lower level layer which the C/C++ library
> uses(i.e. the system calls). What i would like to do is replace the
> standard and the runtime libraries which come with gcc with our own. I
> am a newbie in this and hence have some basic questions;

gcc proper only comes with basic runtime support routines, for things
like long long arithmetic and exception handling.  On some systems gcc
also provides basic support for C++ global constructors and
destructors.  It is unlikely that you want to replace this.  If you
think you do, can you explain further?

For C++, gcc also comes with libstdc++-v3 which is an implementation
of the STL.  You should be able to replace that directly with 3rd
party code--assuming of course that you can recompile the 3rd party
code to use the gcc mangling and ABI, or that the 3rd party code uses
the same ABI.

GNU/Linux comes with a large C library, but that is not part of gcc.

> 1. What is the exact difference between the C runtime and the C
> standard libraries i.e where does one end and the other begin;
> specifically w.r.t gcc? While i am going through a lot of text(both
> online and book form) i am not 100% clear on this.

I'm not sure precisely what you mean.  gcc comes with what might be
called a C runtime.  The C standard libraries are not part of gcc;
they are part of glibc.

> 2. In a gcc distribution where exactly does the compiler specific
> magic lie within the runtime libraries? I might have to modify gcc to
> use only my libraries but where and how do i begin? Currently i have
> built the 3rd party vendor's library and am linking with it but for
> some symbols i still have to go to the gcc runtimes. I am running "nm"
> and extracting the object modules using "ar" for all the unresolved
> symbols; which seems to be a roundabout way of doing things. What i
> would like is to understand the structure of how gcc interfaces with
> its runtimes. Would appreciate any and all help on this. Pointers to
> other articles/links/books will also be very welcome.

Basically, the gcc support is found in -lgcc, and the C library is
found in -lc.  So if you link against your 3rd party library instead
of -lc, you will get the gcc runtime, but your 3rd party C library.

gcc normally links against -lc automatically, but you can disable this
using the -nostdlib option.  See the documentation.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux