Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kallsyms #2142

Closed
wants to merge 10 commits into from
Closed

kallsyms #2142

wants to merge 10 commits into from

Conversation

chrf01
Copy link
Contributor

@chrf01 chrf01 commented Apr 30, 2024

partially implements #1836
fixes: #2106 and #1485 i guess

Tested on the following kernels:

  • qemu-test kernels
  • 6.9.0-rc6 x86_64
  • 5.5.0 x86_64
  • 5.1.0 x86_64
  • 4.16.0 x86_64
  • 4.6.4 x86_64
  • 3.14.74 x86_64

was too lazy to go further down but i think it should work on all version > 3.x
probably fails at OpenWRT kernels, 32bit and big endian (i'll fix this soon)

@CptGibbon
Copy link
Collaborator

Looks like a useful feature, thanks 🙏

Perhaps worth noting this PR is nearly 500 lines and still in draft state, so could be worth splitting up into smaller, easier-to-review PRs of closer to ~100 lines.

@chrf01
Copy link
Contributor Author

chrf01 commented May 7, 2024

I'll close this PR for now, wait for the 32-bit pt fix, and then open smaller PRs soon.

@chrf01 chrf01 closed this May 7, 2024
@disconnect3d
Copy link
Member

@chrf01 tbh it would be great to have it for whatever it works atm and just gate 32-bit saying "To be fixed" or something :).

@disconnect3d
Copy link
Member

Eh, I see this is missing adding the symbols into actual GDB session, hmm... :(

@disconnect3d
Copy link
Member

disconnect3d commented May 27, 2024

Fwiw here's some command hacked fast (not linted etc) to have a klookup <addr> function... better than nothing :).

(In a final version, we should probably just add symbols to the GDB session, but I don't have time for that; if anyone knows how to do it fast, lmk!)

from __future__ import annotations

import pwndbg.commands
from pwndbg.color import message
from pwndbg.commands import CommandCategory
import argparse

parser = argparse.ArgumentParser(description="Lookup kernel address.")
parser.add_argument("addr", type=int, help="Address to lookup")

@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.KERNEL)
@pwndbg.commands.OnlyWhenRunning
def klookup(addr) -> None:
    ksyms = pwndbg.gdblib.kernel.kallsyms.get()
    found = False

    for k,v in ksyms.items():
        if v[0]==int(addr):
            print('%#x => %s (%s)' % (addr, k, v[1]))
            found = True

    if not found:
        print("No symbol found at %#x" % addr)

@mebeim
Copy link
Contributor

mebeim commented May 27, 2024

we should probably just add symbols to the GDB session

It seems like that would require generating a temporary ELF file with the symbols you want to add and then importing it through add-symbol-file or add-symbol-file-from-memory 😕... meh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

remove reliance on debug symbols for kconfig
4 participants