关于c runtime library

原创 2005年03月01日 13:43:00
dot_clear.gif
Ramanathan Ramadass   Oct 14 2003, 8:53 pm     show options
Newsgroups: comp.compilers
From: ramanathan.ramad...@spirentcom.com (Ramanathan Ramadass) - Find messages by this author
Date: 14 Oct 2003 23:46:56 -0400
Local: Tues, Oct 14 2003 8:46 pm
Subject: GCC C/C++ runtime library question
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse

Hi,

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;

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.

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.

Thanks
Ram

[Good luck.  The OS interface library, the standard C library, and the
magic helper code libraries are rarely easy to separate out, and the
low level details are rarely documented. -John]


dot_clear.gif
Brian Inglis   Oct 18 2003, 12:33 pm     show options
Newsgroups: comp.compilers
From: Brian Inglis <Brian.Ing...@SystematicSw.ab.ca> - Find messages by this author
Date: 18 Oct 2003 15:31:45 -0400
Local: Sat, Oct 18 2003 12:31 pm
Subject: Re: GCC C/C++ runtime library question
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse

On 14 Oct 2003 23:46:56 -0400 in comp.compilers,

ramanathan.ramad...@spirentcom.com (Ramanathan Ramadass) wrote:
>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;

Your vendor should be able to provide information about replacing a
compiler specific library with theirs, assuming they don't provide a
compiler, and maybe even if they do. ;^>

>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.

If you have gcc installed, 'info gccint' gives you more
information about the compiler collection and its interfaces, and
there are web pages and manuals at http://gcc.gnu.org/onlinedocs
at the bottom under Current Development.
And there really is not a great distinction between C runtime and
standard libraries: the C standard library is a subset of the
POSIX standard library which is a subset of any *IX system's
library. Runtime support may be just another routine in the
library, or maybe flagged as such with an _.

>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.

If you're lucky, runtime support routines should begin with _.
Substituting standard libraries should only require specifying
the 3rd party header include directory on the compile/cc command
line -Iincdir and their standard library and directory on the
build/ld command line: -Llibdir -lstd.
Alternatively, environment variables CPATH, C_INCLUDE_PATH,
CPLUS_INCLUDE_PATH, and LIBRARY_PATH can be set to provide all
the directories.
The gcc/gpp/g++ driver programs shouldn't be hard to tweak to add
these paths and library, once you get everything working using
options or environment variables.

Getting any gcc helper routines to call your standard library
helper routines requires deleting any routines with the same name
from (a copy of) the gcc libraries glib*, and adding your
standard library both before and after glib* on the build/ld
command line.
Similarly, supplying your own system call interface routines
requires deleting any routines with the same name from glib*, and
adding your syscall library and its directory at the end of the
build/ld command line.
Alternatively, you could build total replacement libraries with
your standard and syscall routines, and only include those other
parts of glib* required by gcc, some with names starting with an
_.

The interesting part of the job starts with writing tests to
verify all this stuff works: info at http://gcc.gnu.org/install
and http://gcc.gnu.org/testing

You also need to give consideration to what you will do now to
make it possible/easier to handle compiler and library upgrades
(3rd party and gcc) in the future.

Haven't done this kind of stuff with gcc, but have dealt with
similar issues.

Thanks. Take care, Brian Inglis         Calgary, Alberta, Canada
--
Brian.Ing...@CSi.com    (Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address                use address above to reply


dot_clear.gif
Marco van de Voort   Oct 18 2003, 12:33 pm     show options
Newsgroups: comp.compilers
From: Marco van de Voort <mar...@stack.nl> - Find messages by this author
Date: 18 Oct 2003 15:32:33 -0400
Local: Sat, Oct 18 2003 12:32 pm
Subject: Re: GCC C/C++ runtime library question
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse

Ramanathan Ramadass wrote:

(assuming some unix)

> 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.

Roughly, the runtime is libgcc, the stdlib is libc.  This can be seen
e.g.  on *BSD that use different libc's. (so what the default libc
might be, is platform dependant)

Besides these there are the ELF startup code files (crt*), the .o
files in /usr/lib

The OS interface is a series of calls defined by unistd.h, and usually
a real ugly macro to inline some syscall. You can never be sure that a
call with a certain name (in the stdlib) really exists in the
library. It might be a header only thing and via some macro wrapper
get magically turned into some other call.

> 2. In a gcc distribution where exactly does the compiler specific
> magic lie within the runtime libraries?

(no idea, don't develop with gcc, only use it as systems compiler)

> I might have to modify gcc to use only my libraries but where and how do i
> begin?

Start to link your binary, and see what calls are missing. Find out
what these calls are, and how they interact (e.g. by objdump -D small
static binaries)

> 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.

- Get the libc source
- objdump small programs using the symbols. Much easier to examine.

> 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.

No idea. I looked at libc to implement our own runtime, but don't use gcc
(or libc)

> [Good luck.  The OS interface library, the standard C library, and the
> magic helper code libraries are rarely easy to separate out, and the
> low level details are rarely documented. -John]

My main frustration is that a symbol on C language level is not
guaranteed a symbol in the source. This makes POSIX useless if you
don't use C, and, together with liberal use of preprocessor macro's in
Unix headers in general hinders a lot of automatic conversion.

dot_clear.gif
VBDis   Oct 18 2003, 12:43 pm     show options
Newsgroups: comp.compilers
From: v...@aol.com (VBDis) - Find messages by this author
Date: 18 Oct 2003 15:36:26 -0400
Local: Sat, Oct 18 2003 12:36 pm
Subject: Re: GCC C/C++ runtime library question
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse

ramanathan.ramad...@spirentcom.com (Ramanathan Ramadass) schreibt:

>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.

Currently I'm doing a similar job, extending the standard library of
another compiler for GNU compatibility. I intend to achieve that
compatibility by creating a glibc with all those modules, which are
not found in the compiler's standard library. Linking with that
library in the first place should exclude all multiply existing
modules.

Some suggestions:

Have a look at the glibc and related documentation. The glibc is a
merge of multiple C standards (C89, C99), and other POSIX
etc. standards and extensions.  The glibc package can be rebuilt with
a selection of these standards, when you modify features.h as
appropriate. At the same time you have a chance to introduce your own
#define for exclusion or replacement of specific modules with those
from your library.

>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?

I don't know what "magic" you mean, gcc doesn't care for libraries -
that's the task of ld. But as gcc can be used as a cross compiler, at
least the platform specific header files reside in the
/lib/gcc-lib/... directories. You can create another target branch for
your library there, so that you can specify with --target whether gcc
shall compile for the default platform, using the standard glibc, or
for your target, using your glibc replacement. IMO the compiler itself
deserves no modifications herefore, as long as the target machine has
the same instruction set as the build machine.

> 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.

Locate the missing modules in the glibc package, and add these to your
project.  It may become tricky to remove unwanted dependencies from
the glibc "internal" header files.

DoDi


End of messages

带你玩转Visual Studio——带你跳出坑爹的Runtime Library坑

Windows下**C Runtime Library**是微软对C标准库函数的实现,这样每个程序可以直接使用C标准库的函数;后来出现了C++,于是又在C Runtime Library基础上开发了*...
  • luoweifu
  • luoweifu
  • 2015年10月13日 20:06
  • 23366

Microsoft Visual C++ Runtime Library Runtime Error的解决办法

打开浏览器时,出现Microsoft Visual C++ Runtime Library Runtime Error错误,初步估计是软件冲突,可能有多种出错的方式,我的是浏览器自动关闭。 一、 ...
  • yi_zz
  • yi_zz
  • 2012年01月05日 08:35
  • 460819

error LNK2038 RuntimeLibrary 不匹配的解决

在工程上右键-》属性-》c/c++-》代码生成-》运行库 因为所选的 改成(release为MT,debug为MTD)即可解决: error ...

C Runtime Library 的来历

运行时库就是C Run-Time Library,是C而非C++语言世界的概念。取这个名字就是因为你的C程序运行时需要这些库中的函数。 C Run-Time Library里面含有初始化代码,还有错误...

cuDNN 下载地址

cuDNN Archive NVIDIA cuDNN is a GPU-accelerated library of primitives for deep neural networks...

windows多线程基础(5):使用_beginthreadex创建线程(C/C++ Runtime Library考虑)

标准CRT(C Runtime Library)问世于1970年,没有考虑到将CRT运行于多线程应用程序的问题。 在多线程环境中存在问题的C/C++运行期库变量和函数包括:error, _d...

调试版本C Runtime Library11.0.51106.1

  • 2013年08月23日 09:52
  • 742KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:关于c runtime library
举报原因:
原因补充:

(最多只允许输入30个字)