Page MenuHomeFreeBSD

linker: expose symbol and string table sections of elf_file
Needs ReviewPublic

Authored by khng on Sep 4 2024, 11:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 4:27 AM
Unknown Object (File)
Oct 2 2024, 9:13 PM
Unknown Object (File)
Sep 27 2024, 8:42 PM
Unknown Object (File)
Sep 23 2024, 8:57 AM
Unknown Object (File)
Sep 19 2024, 5:22 AM
Unknown Object (File)
Sep 18 2024, 3:58 PM
Unknown Object (File)
Sep 18 2024, 8:32 AM
Unknown Object (File)
Sep 18 2024, 7:06 AM
Subscribers

Details

Reviewers
dfr
markj
Summary

These exposed part could be consumed by libkvm easily to look for
symbols in a vmcore.

Sponsored by: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59306
Build 56193: arc lint + arc unit

Event Timeline

khng requested review of this revision.Sep 4 2024, 11:36 PM

These exposed part could be consumed by libkvm easily to look for symbols in a vmcore.

Could you please explain further? libkvm should have access to the kernel and KLD binaries, why does it need to inspect symbol tables in a vmcore?

sys/kern/link_elf.c
91

Why did const get dropped?

sys/sys/_linker_elf_file.h
39

This header is not very useful without a definition of struct linker_file, which kind of defeats the usual reason for this style of header file.

These exposed part could be consumed by libkvm easily to look for symbols in a vmcore.

Could you please explain further? libkvm should have access to the kernel and KLD binaries, why does it need to inspect symbol tables in a vmcore?

Which in case of non-live kvm_open() libkvm does not call into kldsym(2). Currently we do not populate the linker_files list in the vmcore. In this scenario usually callers call the kvm_open function with a vmcore and a kernel ELF binary path, so libkvm will never have knowledge of the loaded modules.

These exposed part could be consumed by libkvm easily to look for symbols in a vmcore.

Could you please explain further? libkvm should have access to the kernel and KLD binaries, why does it need to inspect symbol tables in a vmcore?

Which in case of non-live kvm_open() libkvm does not call into kldsym(2). Currently we do not populate the linker_files list in the vmcore. In this scenario usually callers call the kvm_open function with a vmcore and a kernel ELF binary path, so libkvm will never have knowledge of the loaded modules.

I do not follow the bit about "populating the linker_files list". The list should certainly be in the vmcore, that's how kgdb is able to figure out which KLDs were loaded.

These exposed part could be consumed by libkvm easily to look for symbols in a vmcore.

Could you please explain further? libkvm should have access to the kernel and KLD binaries, why does it need to inspect symbol tables in a vmcore?

Which in case of non-live kvm_open() libkvm does not call into kldsym(2). Currently we do not populate the linker_files list in the vmcore. In this scenario usually callers call the kvm_open function with a vmcore and a kernel ELF binary path, so libkvm will never have knowledge of the loaded modules.

I do not follow the bit about "populating the linker_files list". The list should certainly be in the vmcore, that's how kgdb is able to figure out which KLDs were loaded.

It does, but libkvm never walks through the list in the first place when kvm_open()-ing against minidump targets, unlike kgdb.

sys/kern/link_elf.c
91

oops.

Or, I might just do it the way like how other debugger does - not using elf_file but doing adjustments with only ELF parsing libraries rather.

Or, I might just do it the way like how other debugger does - not using elf_file but doing adjustments with only ELF parsing libraries rather.

As discussed elsewhere, I'd prefer to have libkvm walk the linker_files list and locate the corresponding binaries, like kgdb does. This way we avoid growing the kernel ABI.

I'm also not sure what the end goal is here? Is it to have libkvm resolve symbols in loaded modules by name via kvm_nlist*() when looking at a crash dump?

In D46537#1063010, @jhb wrote:

Is it to have libkvm resolve symbols in loaded modules by name via kvm_nlist*() when looking at a crash dump?

Yep.