|
From: Nicholas N. <nj...@ca...> - 2004-07-15 14:58:54
|
CVS commit by nethercote:
This commit fixes things so that the client stack can be easily placed
anywhere, even below the client executable, just by changing a single
assignment to VG_(clstk_end). I haven't actually moved the stack, though.
M +14 -10 vg_main.c 1.170 [POSSIBLY UNSAFE: printf]
M +3 -1 vg_signals.c 1.72
--- valgrind/coregrind/vg_main.c #1.169:1.170
@@ -511,5 +511,4 @@ static void layout_remaining_space(float
/* where !FIXED mmap goes */
VG_(client_mapbase) = PGROUNDDN((addr_t)(client_size * CLIENT_HEAP_PROPORTION));
- VG_(client_trampoline_code) = VG_(client_end) - VKI_BYTES_PER_PAGE;
VG_(shadow_base) = VG_(client_end) + REDZONE_SIZE;
@@ -941,6 +940,5 @@ static char *copy_str(char **tab, const
if (0)
- printf("copied %p \"%s\" len %d\n",
- orig, orig, cp-orig);
+ printf("copied %p \"%s\" len %d\n", orig, orig, cp-orig);
*tab = cp;
@@ -1050,6 +1048,11 @@ static Addr setup_client_stack(char **or
VKI_BYTES_PER_PAGE; /* page for trampoline code */
+ // decide where stack goes!
+ VG_(clstk_end) = VG_(client_end);
+
+ VG_(client_trampoline_code) = VG_(clstk_end) - VKI_BYTES_PER_PAGE;
+
/* cl_esp is the client's stack pointer */
- cl_esp = VG_(client_end) - stacksize;
+ cl_esp = VG_(clstk_end) - stacksize;
cl_esp = ROUNDDN(cl_esp, 16); /* make stack 16 byte aligned */
@@ -1058,5 +1061,4 @@ static Addr setup_client_stack(char **or
VG_(clstk_base) = PGROUNDDN(cl_esp);
- VG_(clstk_end) = VG_(client_end);
if (0)
@@ -1070,5 +1072,5 @@ static Addr setup_client_stack(char **or
/* allocate a stack - mmap enough space for the stack */
- res = mmap((void *)PGROUNDDN(cl_esp), VG_(client_end) - PGROUNDDN(cl_esp),
+ res = mmap((void *)PGROUNDDN(cl_esp), VG_(clstk_end) - PGROUNDDN(cl_esp),
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
@@ -1193,4 +1195,8 @@ static Addr setup_client_stack(char **or
vg_assert(auxv->a_type == AT_NULL);
+ /* --- trampoline page --- */
+ VG_(memcpy)( (void *)VG_(client_trampoline_code),
+ &VG_(trampoline_code_start), VG_(trampoline_code_length) );
+
vg_assert((strtab-stringbase) == stringsize);
@@ -2886,9 +2892,7 @@ int main(int argc, char **argv)
//--------------------------------------------------------------
- // Initialize our trampoline page (which is also sysinfo stuff)
- // p: setup_client_stack() [for 'esp_at_startup']
+ // Protect client trampoline page (which is also sysinfo stuff)
+ // p: segment stuff [otherwise get seg faults...]
//--------------------------------------------------------------
- VG_(memcpy)( (void *)VG_(client_trampoline_code),
- &VG_(trampoline_code_start), VG_(trampoline_code_length) );
VG_(mprotect)( (void *)VG_(client_trampoline_code),
VG_(trampoline_code_length), VKI_PROT_READ|VKI_PROT_EXEC );
--- valgrind/coregrind/vg_signals.c #1.71:1.72
@@ -2117,4 +2117,6 @@ void vg_sync_signalhandler ( Int sigNo,
if (seg != NULL)
seg = VG_(next_segment)(seg);
+ else
+ seg = VG_(first_segment)();
if (VG_(clo_trace_signals)) {
|