I don't have a ~= RHEL5 at hand, so the output shown is from a Fedora 20, though the process should be mostly the same (the name of the function has changed).
You'd need to install the appropriate kernel-debug-debuginfo
package for your kernel (assuming RHEL or derivative distro).This package provides a vmlinux
image (an uncompressed not stripped version of the kernel):
# rpm -ql kernel-debug-debuginfo | grep vmlinux/usr/lib/debug/lib/modules/3.14.7-200.fc20.x86_64+debug/vmlinux
that image can be used directly with gdb
# gdb /usr/lib/debug/lib/modules/3.14.7-200.fc20.x86_64+debug/vmlinuxGNU gdb (GDB) Fedora 7.7.1-13.fc20Copyright (C) 2014 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>...Reading symbols from /usr/lib/debug/lib/modules/3.14.7-200.fc20.x86_64+debug/vmlinux...done.(gdb) disassemble link_path_walkDump of assembler code for function link_path_walk: 0xffffffff81243d50 <+0>: callq 0xffffffff817ea840 <__fentry__> 0xffffffff81243d55 <+5>: push %rbp 0xffffffff81243d56 <+6>: mov %rsp,%rbp 0xffffffff81243d59 <+9>: push %r15 0xffffffff81243d5b <+11>: mov %rsi,%r15 0xffffffff81243d5e <+14>: push %r14 0xffffffff81243d60 <+16>: push %r13 0xffffffff81243d62 <+18>: push %r12 0xffffffff81243d64 <+20>: push %rbx 0xffffffff81243d65 <+21>: mov %rdi,%rbx 0xffffffff81243d68 <+24>: sub $0x78,%rsp 0xffffffff81243d6c <+28>: mov %gs:0x28,%rax 0xffffffff81243d75 <+37>: mov %rax,0x70(%rsp) 0xffffffff81243d7a <+42>: xor %eax,%eax 0xffffffff81243d7c <+44>: movzbl (%rdi),%eax 0xffffffff81243d7f <+47>: cmp $0x2f,%al ....
You can also use objdump(1)
on the vmlinux
image:
# objdump -rDlS /usr/lib/debug/lib/modules/3.14.7-200.fc20.x86_64+debug/vmlinux > vmlinux.out
The flags are:
-D --disassemble-all Like -d, but disassemble the contents of all sections, not just those expected to contain instructions. -r --reloc Print the relocation entries of the file. If used with -d or -D, the relocations are printed interspersed with the disassembly. -S --source Display source code intermixed with disassembly, if possible. Implies -d. -l --line-numbers Label the display (using debugging information) with the filename and source line numbers corresponding to the object code or relocs shown. Only useful with -d, -D, or -r.
You can lookup the function there:
ffffffff81243d50 <link_path_walk>:link_path_walk():/usr/src/debug/kernel-3.14.fc20/linux-3.14.7-200.fc20.x86_64/fs/namei.c:1729 * * Returns 0 and nd will have valid dentry and mnt on success. * Returns error and drops reference to input namei data on failure. */static int link_path_walk(const char *name, struct nameidata *nd){ffffffff81243d50: e8 eb 6a 5a 00 callq ffffffff817ea840 <__entry_text_start>ffffffff81243d55: 55 push %rbpffffffff81243d56: 48 89 e5 mov %rsp,%rbpffffffff81243d59: 41 57 push %r15ffffffff81243d5b: 49 89 f7 mov %rsi,%r15ffffffff81243d5e: 41 56 push %r14ffffffff81243d60: 41 55 push %r13ffffffff81243d62: 41 54 push %r12ffffffff81243d64: 53 push %rbxffffffff81243d65: 48 89 fb mov %rdi,%rbxffffffff81243d68: 48 83 ec 78 sub $0x78,%rspffffffff81243d6c: 65 48 8b 04 25 28 00 mov %gs:0x28,%raxffffffff81243d73: 00 00ffffffff81243d75: 48 89 44 24 70 mov %rax,0x70(%rsp)ffffffff81243d7a: 31 c0 xor %eax,%eax/usr/src/debug/kernel-3.14.fc20/linux-3.14.7-200.fc20.x86_64/fs/namei.c:1733 struct path next; int err; while (*name=='/')ffffffff81243d7c: 0f b6 07 movzbl (%rdi),%eaxffffffff81243d7f: 3c 2f cmp $0x2f,%alffffffff81243d81: 75 10 jne ffffffff81243d93 <link_path_walk+0x43>ffffffff81243d83: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)/usr/src/debug/kernel-3.14.fc20/linux-3.14.7-200.fc20.x86_64/fs/namei.c:1734 name++;ffffffff81243d88: 48 83 c3 01 add $0x1,%rbx/usr/src/debug/kernel-3.14.fc20/linux-3.14.7-200.fc20.x86_64/fs/namei.c:1733static int link_path_walk(const char *name, struct nameidata *nd){ struct path next; int err; while (*name=='/')....
and match the offset to the actual line of code.