Ramanathan Ramadass Oct 14 2003, 8:53 PM SHOW OPTIONS
Newsgroups: comp.compilersfrom: ramanathan.ramad ... @ spirentcom.com (Ramanathan Ramadass) - Find Messages by this Author Date: 14 Oct 2003 23:46:56 -0400local: Tues, Oct 14 2003 8:46 PM Subject: GCC C / C Runtime Library QuestionReply 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 (ie the system calls) WIKER THETARD AND TODIME LIBRARIES WHICH COME with GCC WITH OF I am A Newbie in this and hence have some bass quintions
1. What is the exact difference between the C runtime and the C standard libraries ie where does one end and the other begin;? Specifically wrt gcc While i am going through a lot of text (both online and form book) 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. .
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 docutend. -John]
Brian Inglis Oct 18 2003, 12:33 PM SHOW OPTIONS
NewsGroups: comp.compilersfrom: brian inglis
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 dispro with ou ly w (licensed from a 3rd party vendor). WE
> WILL Be Providing The Lower Level Layer Which T
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 harne bass quintions
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 different betWeen THE
C
Runtime and the
C
> Standard Libraries I.E Where does one end and the other begin;
> Specification 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 ITS Interfaces
There is Web Pages and Manuals Athttp: //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 an AN _.
> 2. In a GCC Distribution Where Exactly Does The Compiler Specific
> Magic Lie Withnin thein
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 lineing with it but for
> Some Symbols I Still Have to Go To The GCC Runtimes. I am Running "NM"
> and extracting the object modules us "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.
Alternative, 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
Thase 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 an AN_.
THE INTERESTIN 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 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
Marco Van de Voor Oct 18 2003, 12:33 PM Show Options
NewsGroups: comp.compilersfrom: marco van de Voort
Ramanathan Ramadass Wrote:
(Assuming Some Unix)
> 1. What is the exact different betWeen THEC
Runtime and the
C
> Standard Libraries I.E Where does one end and the other begin;
> Specification 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 Deprondant
Besides these there is 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 Withnin thein
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 of the 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 lineing 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 Doying Things.
- Get the libc Source
- Objdump Small Programs Using The Symbols. Much Easier To Examine.
> What i would like 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 Document. -JOHN]
My main frustration is this a symbol on
C Language Level IS Not
Guaranteed a Symbol in the source. this makess 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.
Vbdis Oct 18 2003, 12:43 PM Show Options
Newsgroups: comp.compilersfrom: v ... @ aol.com (vbdis) - Find Messages by this Author Date: 18 Oct 2003 15:36:26 -0400local: Sat, Oct 18 2003 12:36 PM Subject: Re: GCC C / C Runtime Library QuestionReply TO Author | Forward | Print | Individual Message | Show Original | Report Abuse
Ramanathan.ramad ... @ spirentcom.com (Ramanathan Ramadass) Schreibt:
> 1. What is the exact different betWeen THE
C
Runtime and the
C
> Standard Libraries I.E Where does one end and the other begin;
> Specification 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 this, linking, limited one
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 Introdunce 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 Withnin thein
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
/ 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 platage, 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 lineing
> with it but for some symbols i still have to go to the gcc
> Runtimes. I am running "nm" and extracting the object moduumes 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 yourproject. It May Become tricky to remove unwanted dependencies from
The Glibc "Internal" Header Files.
DODI
End of Messages