Analysis of the compilation process of a single kernel module in Linux

Source: Internet
Author: User
Article title: Parsing the compilation process of a single kernel module in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Single Module compilation

Imagine two situations:

If I forget to add a function to my preset core and the function can be compiled into a module, however, the preset core does not compile the function into a module, which makes it unavailable to me, what should I do?

If the Linux core source code does not have a hardware driver (module), but the vendor that develops the hardware has the original driver code provided to Linux, so how can I compile this function into the core module?

Interesting, right! However, in this case, there is nothing to say about it. it is simply "get the original code and recompile it into a module that the system can load! It's easy, right! ^_^ However, the compilation behavior of the above two cases is not the same. however, make, gcc and include header files and function libraries provided by the core are all required.

Additional modules provided by hardware developers:

Most of the time, you may not be satisfied with the features provided by the core preset core driver module, or the core module provided by the hardware developer has more powerful functions, or the hardware is new, so when the preset core does not have the driver module of the hardware, you have to obtain the driver module from the hardware developer and compile it on your own ??

If your hardware developer provides a driver, it is really easy to solve. download the original code, recompile it, and place it to the place where the core module is placed! You can use it! For example, if you do not want to use the Intel network card module originally provided by the core but want to use the latest module officially released by Intel, for example:

Module description and download: http://downloadfinder.intel.com/... l/Detail_Desc.aspx? Agr = Y & Inst = Yes & ProductID = 993 & DwnldID = 2896 & strOSs = 39 & OSFullName = Linux * & lang = eng

You can use various methods to download the file. If this file is stored in/root, decompress it directly! Then you can read INSTALL/README and find the Makefile to compile it. The overall process is a bit like this:

1. decompress the file:

[Root @ linux ~] # Cd/usr/local/src

[Root @ linux src] # tar-zxvf/root/e100-3.4.14.tar.gz

[Root @ linux src] # cd e100-3.4.14

2. start compilation and installation:

[Root @ linux e100-3.4.14] # vi README <= check the file content

[Root @ linux e100-3.4.14] # cd src

[Root @ linux src] # make

# The following line appears:

# Make [1]: Entering directory '/usr/src/kernels/2.6.13-1.1532 _ FC4-i686'

# This indicates that the driver will read the core source code include file during compilation.

# Directory! If you are interested, check out Makefile!

[Root @ linux src] # ls-l

-Rw-r -- 1 root 77908 Jul 2 08:24 e100.c

-Rw-r -- 1 root 351351 Dec 5 00:48 e100.ko

-Rw-r -- 1 root 4775 Dec 5 00:48 e100.mod. c

-Rw-r -- 1 root 39684 Dec 5 00:48 e100.mod. o

-Rw-r -- 1 root 312564 Dec 5 00:48 e100.o

-Rw-r -- 1 root 21092 Jul 2 08:24 ethtool. c

-Rw-r -- 1 root 43258 Jul 2 08:24 kcompat. h

-Rw-r -- 1 root 9610 Jul 2 08:24 Makefile

 

[1] [2] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.