I read some documents that share the library compiled with the -fPIC argument, the .text.so section will be split during the dynamic linking of the fork process (for example, the process will map .so to the same physical address)
I'm interested in who (the kernel or ld.so) and how to do this? maybe I should trace the code, but I don't know where to start.
However, I am trying to verify the statement.
I decided to check the address of the function, for example printf, which is located in libc.so, which will link the entire c-program. I get the printf virtual address of the process and should get the physical address. I tried to write a kernel module and pass the address value to the kernel, and then call virt_to_phys. But this did not work, because virt_to_phys only works for the kmalloc address.
Thus, viewing the table of process pages may be a solution for finding a virtual address card to a physical address. Were there any ways to view the page table? Or are there ways to test the experiment?
early!
source
share