tags:

views:

64

answers:

1

I would like to acquire the address of the vsyscall page for my own uses. I only have two ideas here: alter the compiler to store this information in some known location after it is given to __start, or read /proc/[pid]/maps. I really don't want to read /proc/ as that is slow and shouldn't be necessary. I also don't want to make compiler modifications. Does anyone have an alternative? Is there a symbol I should know about?

Its at the point I'm tempted to stuff this functionality into an ioctl call in a module I've developed as part of this work!

A: 

Here is a stab in the dark:

If you can determine at what address the process stack began, then you can possibly find the parameters which were provided to __start. You might then access the parameters via pointers of the appropriate type set to the corresponding offsets from the initial stack pointer.

According to the article How main() is executed on Linux , by Hyouck "Hawk" Kim, the first few instructions of __start will write the initial arguments in a deterministic way before calling __libc_start_main.

Obviously any approach like this is platform-specific and subject to instability if the implementation of __start were changed.

Heath Hunnicutt