Skip to content
Advertisement

Dynamically find the address at which the kernel is loaded

I’d like to be able to programmatically find out the address at which the linux kernel is loaded. If there are tools out there that already do that, I’d be willing to use them. However, inspecting the PARAMS_PHYS field in the .config during the kernel build is not an option. How could I go about doing this?

Advertisement

Answer

From where do you want to find it? From kernel space or user space? If you want to get it from userspace you can parse output of the /proc/iomem:

cat /proc/iomem | grep "Kernel code"
01000000-0168b523 : Kernel code

If you want to get it from kernel space, you can __pa_symbol macro which returns physical address of a given symbol. In your case you will need to do something like this:

__pa_symbol(_text)
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement