1

I am building a custom linux kernel (4.15.0 x86_64) with debug symbol enabled. I find that addr2line fails to point to the source code line.

addr2line -e vmlinux 0xffffffff9be625f0

gdb also returns "No line number information available for address" with following command

$ gdb ../linux/vmlinux /proc/kcore

... Reading symbols from ../linux/vmlinux...done.

$ info line *0xffffffff9be625f0

What should be done to get the line number from address? Here is the .config file.

Community
  • 1
  • 1
Proy
  • 336
  • 2
  • 13
  • Are you sure that the address is inside vmlinux image? What if it is from some kernel module? (https://plus.google.com/+TheodoreTso/posts/h8H9z4EopkS https://stackoverflow.com/questions/6151538/addr2line-on-kernel-module/6153751) – osgx May 09 '18 at 03:56
  • @osgx, It's an address of a kernel symbol, not from kernel module. Got it from /proc/kallsym. – Proy May 09 '18 at 04:15

1 Answers1

2

First - try to find out which procedure this address belongs to from /proc/kallsyms. Then compute the offset of this address from the beginning of this proc. Then:

objdump -D -S -l ./vmlinux | less

find your procedure name and then move to your offset. Of course your kernel vmlinux should be compiled with debugging symbols.

user2699113
  • 4,262
  • 3
  • 25
  • 43
  • I can understand that I can find the machine code using this method. But that was not my purpose. I wanted to find the line of the c file, which is the purpose of addr2line. – Proy May 09 '18 at 18:37
  • And with my method you'll find it - I always use this method. Second thing - I checked it on my embedded system, and symbols from modules are also listed int /proc/kallsyms, so maybe this address is from module, not from kernel itself, and that is the reason that addr2line is not showing the address? – user2699113 May 10 '18 at 03:41
  • Due to KASLR, addr2line fails to attribute. Disabling RANDOMIZE_BASE solved the problem. – Proy May 10 '18 at 05:49