compiled vmlinux symbols doesn't match the /proc/kallsyms

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

compiled vmlinux symbols doesn't match the /proc/kallsyms

zerons
Hi,

Environment:
        Ubuntu 16.04, kernel 4.4.0-119-generic, amd64

cmdline:
        BOOT_IMAGE=/boot/vmlinuz-4.4.0-119-generic root=UUID=54a30539-d55c-4664-a716-409963511419 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US quiet

Steps:
        sudo apt-get install linux-image-4.4.0-119-generic
        reboot
        apt-get source linux-image-4.4.0-119-generic
        cd linux-4.4.0
        cp /boot/config-4.4.0-119-generic .config
        make vmlinux

I also tried `make CONFIG_DEBUG_SECTION_MISMATCH=y vmlinux`, and got some 'section mismatch'
messages.

After that, I checked symbols in vmlinux, for example, 'tty_open', the address was 0xffffffff81502bc0,
while that symbol in /proc/kallsyms was 0xffffffff81502c30. This is very inconvenient to debug the kernel.

For this case(download the source code and `make vmlinux`), how can I get the vmlinux file which can match
the symbols in /proc/kallsyms?

Thanks.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: compiled vmlinux symbols doesn't match the /proc/kallsyms

Juerg Haefliger
On 04/12/2018 05:10 AM, zerons wrote:

> Hi,
>
> Environment:
> Ubuntu 16.04, kernel 4.4.0-119-generic, amd64
>
> cmdline:
> BOOT_IMAGE=/boot/vmlinuz-4.4.0-119-generic root=UUID=54a30539-d55c-4664-a716-409963511419 ro find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US quiet
>
> Steps:
> sudo apt-get install linux-image-4.4.0-119-generic
> reboot
> apt-get source linux-image-4.4.0-119-generic
> cd linux-4.4.0
> cp /boot/config-4.4.0-119-generic .config
> make vmlinux

This is not how you build an Ubuntu kernel. See
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

> I also tried `make CONFIG_DEBUG_SECTION_MISMATCH=y vmlinux`, and got some 'section mismatch'
> messages.
>
> After that, I checked symbols in vmlinux, for example, 'tty_open', the address was 0xffffffff81502bc0,
> while that symbol in /proc/kallsyms was 0xffffffff81502c30. This is very inconvenient to debug the kernel.
>
> For this case(download the source code and `make vmlinux`), how can I get the vmlinux file which can match
> the symbols in /proc/kallsyms?

Why not install the debug package linux-image-4.4.0-119-generic-dbgsym?

...Juerg

> Thanks.
>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: compiled vmlinux symbols doesn't match the /proc/kallsyms

Juerg Haefliger
On 04/13/2018 10:36 AM, zerons wrote:

>>
>> This is not how you build an Ubuntu kernel. See
>> https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
>>
>
> It works. Thank you so much. I edit the file 'debian/rules.d/2-binary-arch.mk', change this line
> `$(build_cd) $(kmake) $(build_O) $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)`
> to
> `$(build_cd) $(kmake) $(build_O) $(conc_level) vmlinux`
> to get the vmlinux.
> I wonder if we can add a new rule to get the vmlinux or a specific module(.ko) only?

They're all in the debug package.


>>
>> Why not install the debug package linux-image-4.4.0-119-generic-dbgsym?
>>
>
> Yes, I tried this years ago. Perhaps I took wrong steps, the vmlinux symbols didn't match /proc/kallsyms.
> Then I copied the configuration file and did `make vmlinux`. For a long time, it works fine.
>

Follow these steps to add the debug repos:
https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29

Then:
$ apt update
$ apt install linux-image-$(uname -r)-dbgysm
$ grep ' tty_open' /proc/kallsyms
ffffffff81502c30 t tty_open
$ nm /usr/lib/debug/boot/vmlinux-$(uname -r) | grep -m1 ' tty_open'
ffffffff81502c30 t tty_open

...Juerg

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: compiled vmlinux symbols doesn't match the /proc/kallsyms

zerons
Thank you, I will follow your steps.

Best regards,

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team