System. map is a kernel symbol table of a specific kernel. It is generated by "nm vmlinux" and irrelevant symbols are filtered out.
The following lines are from/usr/src/linux-2.4/Makefile:
Some symbols such as variable names or function names are named during program design. The Linux kernel is a complex code block with many global symbols. the Linux kernel uses the variable or function address instead of the symbol name to identify the variable or function name, for example, instead of using a symbol like size_t BytesRead, the variable is referenced like c0343f20. For people who use computers, they prefer names like size_t BytesRead rather than c0343f20. The kernel is mainly written in c, so the compiler/connector allows us to use a symbolic name for encoding, while the kernel uses an address for running. However, in some cases, we need to know the address of the symbol or the symbol corresponding to the address, which is completed by the symbol table, A symbol table is a list of all symbols along with their addresses.
The Linux symbol table uses two files:/proc/ksyms and System. map. /Proc/ksyms is a "proc file" created during kernel boot. In fact, it is not really a file. It is just a representation of kernel data, but it gives people the illusion of a disk file, which can be seen from its file size being 0. However, System. map exists in the actual file System. When you compile a new kernel, the address of each symbol name changes. Your old System. map has incorrect symbolic information, which generates a new System each time the kernel is compiled. map, you should use the new System. map to replace the old System. map.
Although the kernel itself does not actually use System. map, other programs such as klogd, lsof, and ps need a correct System. map. If you use incorrect or do not have System. map, the output of klogd will be unreliable, which will cause difficulties in troubleshooting the program. Without System. map, you may face annoying prompts. In addition, a few drivers need System. map to parse the symbols. If System. map is not created for the specific kernel you are running, they cannot work normally.
For Linux kernel log daemon klogd to perform name-Address Resolution, klogd needs to use System. map. System. map should be placed where the software that uses it can find it. Run: man klogd. map is used as the location of a variable to klogd, so it will query System in three places in the following order. map:/boot/System. map,/System. map,/usr/src/linux/System. map
System. map also has version information. klogd can intelligently find the correct map file.
Makefile menuconfigWhat does the system do for us when we execute the make menuconfig command? This involves a total of several files. We will discuss them one by one.
1. scripts folder under the Linux kernel root directory
2. The arch/$ ARCH/Kconfig file and the Kconfig file under each layer directory
3. makefile files under the Linux kernel root directory and makefile files under directories at different layers
4. The. config file and the files under arch/$ ARCH/configs/in the root directory of the Linux Kernel
5. Linux kernel root directory include/generated/autoconf. h file
1) the scripts folder stores files related to drawing images on the make menuconfig configuration interface. as users, we do not need to care about the contents of this folder.
2) When we execute the make menuconfig command and the above blue configuration interface appears, the system helps us do the following:
First, the system will read the Kconfig file in the arch/$ ARCH/directory to generate the entire configuration interface option (Kconfig is the core of the linux configuration mechanism). What is the value of the ARCH environment variable equal? It is determined by the makefile file in the root directory of the Linux kernel. The makefile contains the definition of this environment variable:
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ -e s/sh[234].*/sh/ ) .......... export KBUILD_BUILDHOST := $(SUBARCH) ARCH ?= $(SUBARCH) CROSS_COMPILE ?=
You can also use the make ARCH = arm menuconfig command to generate the configuration interface, such as the Academic Affairs Office, to take an exam. The exam subjects may include foreign languages, Chinese languages, and mathematics. Here we choose arm to take the exam, the system will read the arm/kconfig file to generate configuration options (select the arm section of the paper), the system also provides x86 section, milps Section and other more than 10 course questions
3) assume that the Office of Academic Affairs is "benevolent". In order to prevent some students from making wrong questions, we have prepared a reference answer (default configuration options ), stored in the arch/$ ARCH/configs/directory. For arm, it is the arch/arm/configs Folder:
There are many options in this folder. Which one will the system read? By default, the kernel reads data from the root directory of the Linux kernel. the config file is used as the default kernel option (answers to the questions ), we usually select a series that is the closest to our development board to the Linux kernel root directory based on the type of the Development Board (select the nearest reference answer)
4). config
Assuming that the academic affairs office has been focused, his reference answers are not completely correct (. the config file does not exactly match our board. run the make menuconfig command to read the new options. However, we generally do not adopt this scheme. In the configuration interface, we choose to use spaces, esc, and press enter to select some options or do not select, and finally save and exit, the Linux Kernel updates the new options (correct answers). config. config is renamed to another file and saved (when you execute make distclean, the system will. delete the config file). We will not need to go to arch/arm/configs to obtain the corresponding file when we configure the kernel later, saving the trouble of reconfiguration and saving it directly. copy the config file. config.
5) after the above two steps, we can correctly read and configure the interface we need. How can they establish a compilation relationship with the makefile file? When you save the make menuconfig option, the system will automatically update it. in addition to config, all options are saved as Macros in the Linux Kernel root directory include/generated/autoconf. h file
The source code in the kernel will contain the above. h file and implement Conditional compilation with the macro definition. When we need to select whether to compile a file as a whole, we also need to modify the corresponding makefile file, for example:
When we choose whether to compile the s3c2410_ts.c file, makefile will decide to compile this file according to CONFIG_TOUCHSCREEN_S3C2410. This macro is defined in the Kconfig file. After the configuration is complete, it will appear in. in config and autconf, we have completed the entire Linux kernel compilation process. Finally, we will find that throughout the Linux Kernel configuration process, only the Kconfig, makefile files, and corresponding source files of each layer are left for the user interface.
For example, if you want to add a function to the kernel and use make menuconfig to control its claim process, you must first modify the Kconfig file in the corresponding directory, add the corresponding options according to the Kconfig syntax. Then execute make menuconfig to select whether to compile into the kernel or not to compile into the kernel, or compile it as a module ,. config File and autoconf. the H file is automatically generated. The makefile file in the corresponding directory is modified to add the compilation option. The make command is executed to compile the file.
Kconfig and MakefileEach directory of the Linux kernel source code tree contains two documents: Kconfig and Makefile. The Kconfig distributed to each directory constitutes a distributed Kernel configuration database. Each Kconfig describes the Kernel configuration menus related to the source document of the directory. When you execute the Kernel configuration make menuconfig, read the menu from Kconfig and save it to the Kernel configuration document of. config. When the kernel is compiled, the main Makefile calls this. config to understand the user's choice. This content indicates that Kconfig corresponds to each level of configuration menu of the kernel.
If you want to add a new driver to the kernel source code, you need to modify Kconfig so that you can select this driver. If you want to compile this driver, you need to modify the Makefile. There are two types of files to be modified when adding a new driver (if only files are added, you only need to modify the Kconfig and Makefile files of the current layer; if the directory is added, you need to modify a pair of Kconfig and Makefile in the current layer and directory) Kconfig and Makefile. To know how to modify these two documents, you need to know the syntax structure of the two documents. For the syntax of Kconfig, see the reference document "[linux-2.6.31] kbuild".
The Makefile contains five parts:
Makefile at the top layer of Makefile. config Kernel configuration file arch/$ (ARCH)/Makefile architecture Makefile scripts/Makefile. * Applicable to the general rules of all kbuild Makefiles and other kbuild Makefiles, there are about 500 such files
The top-level Makefile reads the. config file generated by the Kernel configuration operation. The top-level Makefile builds two main objectives: vmlinux (kernel image) and modules (all module files ). It recursively accesses sub-directories under the kernel source code tree to build these targets. Which subdirectories are accessed depends on the Kernel configuration. The top-level Makefile contains an architecture Makefile, which is specified by arch/$ (ARCH)/Makefile. The architecture Makefile file provides information about the specific architecture for the top-level Makefile. Each subdirectory has a kbuild file and Makefile file to execute commands passed from the upper layer. The kbuild and Makefile files use the information in the. config file to construct a list of various files built in by kbuild or used by module objects. Scripts/Makefile. * contains all the definitions/rules, and so on. This information is used to build the kernel using the kbuild and Makefile files.
Address: http://www.linuxprobe.com/linux-kernel-compilation.html