~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to coregrind/m_sigframe/sigframe-ppc64-linux.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrés Roldán
  • Date: 2008-06-13 02:31:40 UTC
  • mto: (1.4.1 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20080613023140-iwk33rz9rhvfkr96
Import upstream version 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
   This file is part of Valgrind, a dynamic binary instrumentation
9
9
   framework.
10
10
 
11
 
   Copyright (C) 2000-2006 Nicholas Nethercote
 
11
   Copyright (C) 2000-2007 Nicholas Nethercote
12
12
      njn@valgrind.org
13
 
   Copyright (C) 2004-2006 Paul Mackerras
 
13
   Copyright (C) 2004-2007 Paul Mackerras
14
14
      paulus@samba.org
15
15
 
16
16
   This program is free software; you can redistribute it and/or
32
32
*/
33
33
 
34
34
#include "pub_core_basics.h"
 
35
#include "pub_core_vki.h"
 
36
#include "pub_core_vkiscnums.h"
35
37
#include "pub_core_threadstate.h"
36
38
#include "pub_core_aspacemgr.h"
37
39
#include "pub_core_libcbase.h"
44
46
#include "pub_core_tooliface.h"
45
47
#include "pub_core_trampoline.h"
46
48
#include "pub_core_transtab.h"      // VG_(discard_translations)
47
 
#include "vki_unistd-ppc64-linux.h" // __NR_rt_sigreturn
48
49
 
49
50
 
50
51
/* This module creates and removes signal frames for signal deliveries
133
134
static Bool extend ( ThreadState *tst, Addr addr, SizeT size )
134
135
{
135
136
   ThreadId tid = tst->tid;
136
 
   NSegment *stackseg = NULL;
 
137
   NSegment const *stackseg = NULL;
137
138
 
138
139
   if (VG_(extend_stack)(addr, tst->client_stack_szB)) {
139
140
      stackseg = VG_(am_find_nsegment)(addr);
259
260
   /* XXX should do FP and vector regs */
260
261
 
261
262
   /* set up signal return trampoline */
262
 
   frame->tramp[0] = 0x38000000U + __NR_rt_sigreturn; /* li 0,__NR_rt_sigreturn */
263
 
   frame->tramp[1] = 0x44000002U;                     /* sc */
 
263
   /* NB.  5 Sept 07.  mc->mc_pad[0..1] used to contain a the code to
 
264
      which the signal handler returns, and it just did sys_sigreturn
 
265
      or sys_rt_sigreturn.  But this doesn't work if the stack is
 
266
      non-executable, and it isn't consistent with the x86-linux and
 
267
      amd64-linux scheme for removing the stack frame.  So instead be
 
268
      consistent and use a stub in m_trampoline.  Then it doesn't
 
269
      matter whether or not the (guest) stack is executable.  This
 
270
      fixes #149519 and #145837. */
 
271
   frame->tramp[0] = 0; /* invalid */
 
272
   frame->tramp[1] = 0; /* invalid */
264
273
   VG_TRACK(post_mem_write, Vg_CoreSignal, tst->tid,
265
274
            (Addr)&frame->tramp, sizeof(frame->tramp));
266
275
 
269
278
                              sizeof(frame->tramp), "stack_mcontext" );   
270
279
 
271
280
   /* set the signal handler to return to the trampoline */
272
 
   SET_SIGNAL_LR(tst, (Addr) &frame->tramp[0]);
 
281
   SET_SIGNAL_LR(tst, (Addr)&VG_(ppc64_linux_SUBST_FOR_rt_sigreturn));
273
282
 
274
283
   /* Stack pointer for the handler .. (note, back chain set
275
284
      earlier) */