LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-12-2011, 02:03 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Rep: Reputation: 35
Question How are the kernel and Libc connected?


Hello

This is a newbie question: What is the connection between the kernel and Libc (either gLibc, uClibc, etc.)?

For instance, what happens if I upgrade the kernel but keep an older version of Libc and applications that rely on it: Will applications keep running, and I will need to upgrade Libc only if I install newer applications that expect to find new systems calls in the kernel that they reach through Libc?

Or are the kernel and Libc totally unrelated?

Thank you.
 
Old 07-12-2011, 03:06 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,366

Rep: Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335
Sounds like you need to do yourself a linux from scratch.

At it's simplest, header files are subroutines, and libraries are compiled routines. When the kernel decides to write to disk, or screen, for example it calls on routines compiled in the libc of your choice, which know how to address the chips on the board and make that write happen. That's the relationship.

Software writers are able to ignore all those details of sending control codes to specific addresses to instruct chips, and then sending data.
 
Old 07-12-2011, 07:35 AM   #3
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Thanks for the infos. So upgrading the kernel without upgrading the Libc could be a problem, since the kernel might expect new functions that weren't yet available in the current Libc version.
 
Old 07-12-2011, 08:40 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
The kernel cannot use any libraries ... which is why it contains its own simplified implementations of things like printf().

The glibc library is very important, however, since most of the system (including key command-line tools...) uses it. Therefore, this library is both critically important and "not quite like all the others."

However, it is "like all the others" in one respect ... namely, that you can have more than one of them on your system at the same time, if you need to.

Nevertheless: in all aspects concerning this library, I strongly encourage you (nay, "I command thee!") not to touch this library except through distro-provided packages and strictly according to the distro's instructions. Admire the blinking lights, but don't touch. You can get your system thoroughly hosed very quickly, because this library is so very pervasive.

Last edited by sundialsvcs; 07-12-2011 at 08:41 AM.
 
Old 07-12-2011, 11:04 AM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by littlebigman View Post
Hello

This is a newbie question: What is the connection between the kernel and Libc (either gLibc, uClibc, etc.)?
The connection is the other way around: apps use libc (whatever libc you want), and libc translates anything (like printf) into system calls, or plainly spoken, they ask the kernel to do something. Programs can also use direct system calls and bypass libc, but that's not a common thing to do, unless you seek a very specific and obscure purpose.

Take a look here:

http://www.win.tue.nl/~aeb/linux/lk/lk-3.html

Quote:
For instance, what happens if I upgrade the kernel but keep an older version of Libc and applications that rely on it: Will applications keep running, and I will need to upgrade Libc only if I install newer applications that expect to find new systems calls in the kernel that they reach through Libc?
That you will find a kernel version that will not work with a given version of glibc is extremely unlikely to happen, unless you use a very very old glibc in a very very new kernel, or vice versa. Being that said, using any libc others than the ones supported in your distro (and version) is usually doomed to failure, because all the programs that links against libc will be unable to run, and that usually means 100% of your binaries, except, maybe, a static version of grub and the like.

The kernel will still run but after that, init will fail if your new libc is incompatible with your user land. Even in source based distros like Gentoo you have to be careful when updating glibc, and downgrading it is completely unsupported and not straightforward.

Last edited by i92guboj; 07-12-2011 at 11:06 AM.
 
Old 07-13-2011, 04:18 AM   #6
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
Thanks for the clarification. So both the kernel and C applications use some C library, but the kernel compiles it statically, while applications usually use the shared version.

Is the C library used by the kernel the same as gLibc but only includes a subset of the functions available in gLibc, or is it a totally different library rewritten from scratch to fit the needs of the kernel?
 
Old 07-13-2011, 06:15 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
Re-read (the start of) post #4. Stop when you get to the ellipsis.
 
Old 07-14-2011, 10:14 AM   #8
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 660

Original Poster
Rep: Reputation: 35
But then, what difference does it make if the C functions are in the kernel source code or in some library, as long as the library is statically compiled?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot problem:: Kernel Panic because can't find libc.so.6 link glc23 Linux - Newbie 2 04-03-2008 11:05 AM
kernel panic (trying to kill init), libc.so.6 Rocker Linux - Software 0 09-29-2004 11:34 AM
How to use libc.so.5 apps with kernel 2.4 udayg Linux - Newbie 1 03-13-2004 12:09 AM
libc.so verse libc.so.5 markstevens Linux - Software 4 06-19-2003 11:41 AM
GNU libc installation to setup cross compiler env - kernel header file TOO OLD !! tanch00 Linux - Software 1 02-06-2002 02:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration