LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-28-2004, 07:03 AM   #1
class_struggle
Member
 
Registered: Nov 2003
Location: where rock meets hard place
Distribution: 1- Knoppix 2-Gentoo
Posts: 121

Rep: Reputation: 15
can anyone explain kernel headers?


Hi,

Setting up my winmodem for a second time has led me to the kernel header files once more.

The fact is, I don't know what they are. Are they a special sort of module that can be read in by the kernel? why are they spearated from the kernel. What does the kernel do with them?
 
Old 07-28-2004, 08:22 AM   #2
RobertP
Member
 
Registered: Jan 2004
Location: Manitoba, Canada
Distribution: Debian
Posts: 454

Rep: Reputation: 32
Drivers are a part of the Linux kernel, but they may be developed separately at different times and places. If you write a driver and wish it to work with Linux x.y, you do not need to have Linux x.y handy, just the kernel headers, which contain all the information needed by compilers to make the driver files. The headers essentially tell the world how to pass information to the kernel and how to receive information from the kernel. When you install any software that needs this intimate knowledge of the kernel, the kernel header files will be required to be present. When a programme or driver is loaded or linked, any references to the kernel can be satisfied by the loader/linker. This process is similar to using a precompiled library with any programming language. The source files refer to external symbols which may be used by the compiler to generate linkages to libraries and other external objects.

The second computer job in my career was working with a primitive operating system. The applications were always loaded to the same absolute location in memory. A list of symbols that were addresses of locations in the operating system were available at the time of compiling the application. The result was that we could get a separately compiled application to behave as if it were compiled along with the operating system as one big programme. It was very crude, but it worked, sometimes ... The kernel headers are a similar concept brought up to date.
 
Old 07-28-2004, 09:07 AM   #3
class_struggle
Member
 
Registered: Nov 2003
Location: where rock meets hard place
Distribution: 1- Knoppix 2-Gentoo
Posts: 121

Original Poster
Rep: Reputation: 15
That was a cool reply, thanks RobertP!

Inevitably I have 2 further questions (but then I'll stop, all right?:-))

1. Are headers then generated from the kernel in use? That would make them consistent with that kernel's configuration. I can remember last time though, I simply downloaded them, so they couldn't have reflected the kernel's exact config.

2. In an otherwise very clear explanation, I was sure what you meant by
Quote:
The source files refer to external symbols which may be used by the compiler to generate linkages to libraries and other external objects.
Do you mean the driver source file or the kernel sources? By external symbols, are you including the kernel calls (for lack of a better word)?
 
Old 07-28-2004, 09:27 AM   #4
RobertP
Member
 
Registered: Jan 2004
Location: Manitoba, Canada
Distribution: Debian
Posts: 454

Rep: Reputation: 32
The folks who write/maintain the kernel, produce matching headers for each kernel.

The source file of an application/driver will refer to a symbol defined in the kernel header files. The source file will usually have something that says "include the kernel headers with this source". The compiler will then treat the headers as a part of the source it is compiling and the definitions in the headers will produce the right linkages in the output of the compiler.

An example: If a programme needs to know what an error code means, it can refer to errno.h in kernel-headers

errno.h contains stuff like this:
errno.h

External symbols can be constants, routine locations, data locations, configuratioin settings
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
trying to find/install kernel-source or kernel-headers timsch75 Slackware 3 10-22-2005 10:17 AM
explain differences in kernel ruddigger Debian 1 07-18-2005 10:55 PM
Difference between kernel-headers kernel-source twinkers Debian 2 06-18-2005 12:20 PM
send packets with kernel routing and without kernel messing with headers bassdemon Programming 5 02-08-2005 07:29 PM
Explain me bzImage, /vmlinuz to build kernel letdoit Slackware 3 05-23-2004 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:22 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration