|
From: Greg P. <gp...@us...> - 2005-02-10 12:45:14
|
This is a patch that makes Valgrind's initial client stack construction more flexible, for use in ports to other operating systems. In particular, it can easily be augmented to handle Mac OS X. Note that this change has not been tested; it probably doesn't even compile. (Does anyone actually have time to look over and fix untested changes like this? If not, I can hold on to them until later.) http://www.sealiesoftware.com/valgrind/setup_client_stack.patch Significant changes: * I rewrote setup_client_stack() itself because I thought it was confusing. Feel free to reject this part. * The client stack layout now includes an OS-dependent "prefix" before argc and "suffix" between envp and the strings. On Linux, prefix is empty and suffix contains auxv. On Mac OS X, the prefix and suffix are used for different purposes. * Linux's auxv processing has been moved to VGOS_(build_client_stack_suffix). Other systems would define appropriate versions of that function and several others for prefix and suffix processing, and all of these OS-specific functions would be moved to other files. * Linux uses a demand-grown stack; the initial stack size is only big enough to hold the initial arguments. Mac OS X always starts with a larger pre-allocated stack; the size is encoded in the executable. setup_client_stack() needs to handle both of these cases when it mmaps the stack itself. Known bugs: * `int argc` is mishandled wrong on 64-bit platforms. Mac OS X writes a four-byte argc followed by a four-byte zero pad. I don't know what Linux does. This version is probably incorrect regardless. * The trampoline code gets written to a different place (it's no longer one page away from the end of the stack block). This would be easy to put back with the assumption that trampoline code always fits in one OS page. Alternatively, another OS-specific size variable could be added. -- Greg Parker gp...@us... |