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

Recommendation for importing the driver into Ghidra #2

Open
smaeul opened this issue Sep 7, 2021 · 1 comment
Open

Recommendation for importing the driver into Ghidra #2

smaeul opened this issue Sep 7, 2021 · 1 comment

Comments

@smaeul
Copy link
Contributor

smaeul commented Sep 7, 2021

Here's a suggestion for anyone wanting to look at the pre-compiled files in Ghidra. This is most useful if you haven't already made a bunch of annotations; I don't know how to copy those over. So it's not really aimed at this repo, per se, but here's where the action seems to be.

  1. Run make ARCH=arm64 rockchip_linux_defconfig to start with a kernel config that builds the EBC driver.
  2. Run make ARCH=arm64 nconfig and enable CONFIG_DEBUG_INFO_DWARF4 (at "Kernel hacking" -> "Compile-time checks and compiler options" -> "Generate dwarf4 debuginfo"). DWARF4 is the newest debug info format that Ghidra understands, but recent GCC will generate DWARF5 by default.
  3. Run make ARCH=arm64 to compile the kernel. If it fails, that is fine, as long as drivers/gpu/drm/rockchip/ebc-dev/built-in.a gets created.
  4. Finally, take the archive containing the EBC driver, and convert it to an object file: aarch64-linux-gnu-ld -r -o drivers/gpu/drm/rockchip/ebc-dev/built-in.o --whole-archive drivers/gpu/drm/rockchip/ebc-dev/built-in.a.

This will create a single file, built-in.o, that includes all of the C and pre-compiled source for the driver, so everything gets loaded together in one code browser, and you don't have to worry about function imports and thunks and whatnot.

@Ralim
Copy link
Owner

Ralim commented Sep 7, 2021

This would have been amazingly useful to know.. a while a go 😂 Thankfully adding thunks is not too hard at all.

That said, this is super useful to know in case I end up regenerating any of the code again. I've done that a fair few times already when trying different ideas.

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

No branches or pull requests

2 participants