I'm trying to access the "rendezvous structure" (struct r_debug *) in order to find the link map of a process. But I keep running into invalid adresses and I really can't figure out what's going on.
Here's how I go on trying to find it:
1. Get the AT_PHDR value from the auxiliary vector
2. Go through the program headers until I find the PT_DYNAMIC segment
3. Try to access the vaddr of that segment (PT_DYNAMIC) to get the dynamic tags
4. Iterate through the dynamic tags until I find DT_DEBUG. If I get here I should be done
The issue is I can't get past step 3 because the vaddr of the PT_DYNAMIC segment always points to an invalid address.
What am I doing wrong ? Do I need to find the relocation of the vaddr ? I have looked at the LLDB sources but I can't figure out how they got the address.
UPDATE: @EmployedRussian was right, I was looking at a position-independent executable. His solution to calculate the relocation worked wonderfully.