The system.map file

xiaoxiao2021-03-06  38

. System.mapThere seems to be a dearth of information about the System.map file It's really nothing mysterious, and in the scheme of things, it's really not that important But a lack of documentation makes it shady It's like an earlobe;.. We All Have ONE, But Nobody Really Knows Why. this is a little web page i cooked up That Explains the why.

Note, I'm Not Out To BE 100% Correct. For Instance, It's Possible for A System To Not many assure you "go with the flow" and have a Fairly Typical System.

Some of the stuff on OOPSes comes from Alessandro Rubini's "Linux Device Drivers" Which is Where I Learned Most of What I Know About Kernel Programming.

? What Are Symbols In the context of programming, a symbol is the building block of a program:. It is a variable name or a function name It should be of no surprise that the kernel has symbols, just like the programs you write The. Difference is, of course, That The Kernel Is a Very Complicated Piece of Coding and Has Many, Many Global Symbols.

What Is The Kernel Symbol Table? The kernel does not use symbol names. It's much happier knowing a variable or function name by the variable or function's address. Rather than using size_t BytesRead, the kernel prefers to refer to this variable as (for example ) C0343F20.

Humans, on the other hand, do not appreciate names like c0343f20. We prefer to use something like size_t BytesRead. Normally, this does not present much of a problem. The kernel is mainly written in C, so the compiler / linker allows us To Use Symbol Names WHEN We Code And Allows The Kernel To Use Addresses When It Runs. Everyone is happy.

There are situations, however, where we need to know the address of a symbol (or the symbol for an address). This is done by a symbol table, and is very similar to how gdb can give you the function name from an address ( or an address from a function name) A symbol table is a listing of all symbols along with their address Here is an example of a symbol table:.. c03441a0 B dmi_broken c03441a4 B is_sony_vaio_laptop c03441c0 b dmi_ident c0344200 b pci_bios_present c0344204 b pirq_table c0344208 b pirq_router C034420C B Pirq_Router_Dev C0344220 B ASCII_BUFFER C0344224 B ASCII_BUF_BYTESYOU CAN See That The Variable Named Dmi_Broken Is At The Kernel Address C03441A0.

What is the system.map file? There 2 FILES THAT ARE USED AS A SYMBOL TABLE:

/ proc / ksyms system.map there. You now. You's ..map file is.

Every Time You Compile A New Kernel, The Addresses of Various Symbol Names Are Bound To Change.

/ Proc / ksyms is a "proc file" and is created on the fly when a kernel boots up Actually, it's not really a file;.. It's simply a representation of kernel data which is given the illusion of being a disk file If you Don't Believe Me, Try Finding The FileSize Of / Proc / Ksyms. Therefore, It Will Always Be Correct for the Kernel That Is Currently Running ..

However, System.map is an actual file on your filesystem. When you compile a new kernel, your old System.map has wrong symbol information. A new System.map is generated with each kernel compile and you need to replace the old copy with Your new copy.

What is an oops? What is the most common bug in your homebrewed program? The segfault. Good Ol 'Signal 11.

What is the most common bug in the Linux kernel? The segfault. Except here, the notion of a segfault is much more complicated and can be, as you can imagine, much more serious. When the kernel dereferences an invalid pointer, it's not called a segfault -. it's called an "oops" An oops indicates a kernel bug and should always be reported and fixed.Note that an oops is not the same thing as a segfault Your program can not recover from a segfault The kernel doesn '.. THE Linux Kernel Is Very Robust; The Oops May Just Kill The Current Process And Leave The Rest of The Kernel In a Good, Solid State.

An OOPS IS NOT A KERNEL PANIC. IN A PANIC, The System Grinds To a Halt and Must Be Restarted. An Oops May Cause A Panic IF A Vital Part of The System Is Destroyed. An OOPS in A Device Driver , For Example, Will Almost Never Cause A Panic.

When an oops occurs, the system will print out information that is relevent to debugging the problem, like the contents of all the CPU registers, and the location of page descriptor tables. In particular, the contents of the EIP (instruction pointer) is printed THIS:

EIP: 0010: [<00000000>] CALL TRACE: []

What Does An Oops Have To Do With System.map?You can agree that the information given in EIP and Call Trace is not very informative. But more importantly, it's really not informative to a kernel developer either. Since a symbol does not have A Fixed Address, C010B860 CAN Point Anywhere.

To help us understand cryptic oops output, Linux uses a daemon called klogd, the kernel logging daemon. Klogd intercepts kernel oopses and logs them with syslogd, changing some of the useless information like c010b860 with information that humans can use. In other words, klogd is a kernel message logger which can perform name-address resolution. Once klogd tranforms the kernel message, it uses whatever logger is in place to log system wide messages, usually syslogd.To perform name-address resolution, klogd uses System.map. Now You know what an OOPS HAS to do with system.map.

Thele's Other Software Besides The Kernel Logger daemon That Uses System.map. I'll get inTo That Shortly.

Fine Print: There Are Actually Two Types of Address Resolutions Performed by Klogd.

. Static translation, which uses the System.map file Dynamic translation, which is used with loadable modules These translations do not use System.map and is therefore not relevant to this discussion, but I'll describe it briefly anyhow:. Klogd Dynamic TranslationSuppose you load a kernel module which generates an oops. An oops message is generated, and klogd intercepts it. It is found that the oops occured at d00cf810. Since this address belongs to a dynamically loaded module, it has no entry in the System. map file. klogd will search for it, find nothing, and conclude that a loadable module must have generated the oops. klogd then queries the kernel for symbols that were exported by loadable modules. Even if the module author did not export his symbols, At the Very Least, Klogd Will Know What Module Generated The Oops, Which is Better Than Knowing Nothing About The Oops At ALL.

Where Should System.map Be Located? System.map should be located wherever the software that uses it looks for it. That being said, let me talk about where klogd looks for it. Upon bootup, if klogd is not given the location of System.map as an argument, it will look for System.map in three places, in the following order: /boot/System.map /System.map /usr/src/linux/System.map System.map also has versioning information , and klogd intelligently searches for the correct map file. for instance, suppose you're running kernel 2.4.18 and the associated map file is /boot/System.map. you now compile a new kernel 2.5.1 in the tree / usr / src / linux. During the compiling process, the file /usr/src/linux/System.map is created. When you boot your new kernel, klogd will first look at /boot/System.map, determine it's not the correct map File for the booting kernel, The Look at /usr/src/linux/system.map, Determine That It is The Correct map file for the booting kenoting kenel and start behaving the symbols.

A Few NOTA BENE'S:

Somewhere during the 2.5.x series, the linux kernel Started To Untar Into Linux-Version, Rather Than Just Linux (Show of Hands - How Many People Have Been Waiting for this to happen?). I don't know if klogd HAS Been Modified to search in /usr/src/linux-version/system.map yet. Todo: Look at the klogd source. if someone beats me to it, please email me and let me know, please email me and let me know, please email me and let me know New Directory Name for the Linux Source Code. The Man Page The Story. Look at this: # straape -f / sbin / klogd | grep 'system.map' 31208 open ("/ boot / system.map -2.4.18 ", O_RDONLY | O_LARGEFILE) = 2Apparently, not only does klogd look for the correct version of the map in the 3 klogd search directories, but klogd also knows to look for the name" System.map "followed by" - KernelVersion, Like System.map-2.4.18. this is undocumented feature of klogd.a few drivers need system.map to resolve symbols snince they're linked against kernel headers instead of glibc) . They will not work correctly without the System.map for the particular kernel currently running. This is NOT the same thing as a module not loading because of a kernel version mismatch. That has to do with the kernel version, not the kernel symbol Table Which Changes Between Kernels of The Same Version!

What else Uses the system.mapsystem.map isn't Just Useful for debugging kernel opses. Other programs like lsof:

Satan # strult LSOF 2> & 1 1> / dev / null | GREP System Readlink ("/ Proc / 22711 / FD / 4", "/Boot/system.map-2.4.18", 4095) = 23and PS:

Satan # strace ps 2> & 1 1> / dev / null | grep system open ("/ boot / system.map-2.4.18", o_rdonly | o_nonblock | o_nOctty) = 6and dosemu required a corrence system.map.what happensiff I Do not Have A Healthy System.map?Suppose you have multiple kernels on the same machine. you need a separate System.map file for each kernel! If you run a kernel with no (or an incorrect) System.map, you 'Ll Periodically See a Message Like:

System.map does not match actual kernel Not a fatal error, but can be annoying to see everytime you use ps. Some software, like dosemu, may not work correctly. Lastly, your klogd or ksymoops output will not be reliable in case of a Kernel OOPS.

How do I Remedy The Above Situation? The Solution Is To Keep All Your System.map Files In / Boot and Rename THEM WILES IN / BOOT AND RENAME THEM WILES IN / BOOT AND RENAME THEM WILES IN / BOOT AND RENAME THEM WILES IN / BOOT AND RENAME THEM WILES IN / BOOT AND RENAME THEM with THE KERNELS LIKE:

/ Boot/vmlinuz-2.2.14 /boot/vmlinuz-2.2.13 The Just Rename your map files accounting to the kernel version and put itmin / boot, Like:

/BOOT/SYSTEM.MAP-2.2.14 /Boot/system.map-2.2.13 Now what if you have two 帖子 帖子 帖子 帖子 帖子 帖子 帖子WITHOUT Sound:

/BOOT /VMLINUZ-2.2.14 /Boot/Vmlinuz-2.2.14.nosound The Best Answer Would Be All Software Looked for the Following Files:

/ Boot/system.map-2.2.14 /boot/system.map-2.2.14.nosound but to beh honest, i don't know, everything. Everything I've seen search for "system.map -version "But what about" system.map-version.extraversion "? i Have No IDEA (TODO).

-----------------------------

Mail Corrections, Suggestions Kudos and Pizza TO: P@dirac.org

转载请注明原文地址:https://www.9cbs.com/read-79185.html

New Post(0)