i#125: Re-enable selfmod-big and port it to x64

I converted this test to split-file asm to avoid duplicating the my
changes.

I had to move more of the *_mem() family of helpers in tools.h into
tools.c so I could call protect_mem() from asm.

Review URL: https://codereview.appspot.com/6619046

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1637 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Silence warning in the client.security vmsafe test and make it pass

- MSVC 2010 warns about our intentional OOB write.  Indirecting through
  pointer_plus_three() avoids the warning.
- We were calling fflush(stdout), not stderr, so I switched to print()
  from tools.c.
- I had to add a trailing newline to the .expect file in order to make
  the test pass.

Review URL: https://codereview.appspot.com/6630043

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1638 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
Add dr_inject_prepare_to_exec() on Linux

This allows native drrun to directly exec the app from the current
process, which matches the drrun shell script.

If the user passes a timeout, we fork a child process as normal.

Review URL: https://codereview.appspot.com/6610053

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1639 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 423
+ security-common.jmp_from_trace is VPS-only

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1640 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fix VPS x64 build

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1641 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 935
+ handle both forward and backward slashes when looking for debuglink file

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1642 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#933: Remove vmarea iteration assert in update_all_memory_areas()

Because we could merge areas with a prior region, it's not possible to relax the assert.

Review URL: https://codereview.appspot.com/6611052

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1643 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#928: Reset bb->exit_target when re-building sandboxed bbs

In issue 577 and r1047, we reset bb->exit_type, but we didn't reset
bb->exit_target.

Normally exit_target will get overwritten if we end on a cti, but if we
have more than 5 stores in the bb, we will stop early on a non-cti
instruction to avoid overly-long sandboxed bbs.  As a result, we attempt
to terminate the bb by jumping to exit_target instead of doing a
fall-through.

Fixes issue 928.

Review URL: https://codereview.appspot.com/6614050

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1644 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixed issue 941: IPC_ALERT at postsys_DuplicateObject
- replace sys_param with postsys_param in postsys_DuplicateObject

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1645 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 904

PEB x86 is not adjacent to x64 on win8 so I switched
is_first_thread_in_new_process() to check whether a 1-page alloc region and
to then compare the first three pointer-sized fields of the two PEB's.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1646 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 932

+ support encoding a rip-rel target properly with a different final
  destination from the local encode target

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1647 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#923 x64 reachability-robust injection follow-up:
+ align stack properly
+ fix 64-bit push-immed bug
+ make earliest injection x64 reachable proof via indirect jump to DR

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1648 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#936: win8 high-addr x64 ntdll: mixed-mode injection

WOW64 injection: win8 wow64 has ntdll up high but it is not possible to
allocate memory that's relative-jump-reachable from there.  Thus I switched
the hook to use an indirect jump.

Also i#565: win8 injection in general:
Early injection location: LdrLoadDll works fine, just like win7.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1649 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#912: win8 API set support, part 1

Longer-term we may want to reconsider using apisetschema, but for now I'm
extending the current scheme.  This just adds one missing map that goes to
ntdll.  There are many more missing maps but they all go to kernelbase so
the catch-all ends up working out which is sufficient for now.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1650 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#565 win8 support:
+ support high-addr ntdll in load_syms64 script

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1651 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
add post_syscall flag and check in sys_param and postsys_param

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1652 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
i#940: Always use a thread private copy for trace building

The underlying issue is that fragment recreation is not deterministic in
the face of transitions between sandboxing and readonly pages in the
code cache.

This change side steps the problem by building a temp thread private
fragment earlier, and using that to extend the trace instead of the
existing thread-shared fragment.

There should be no performance impact, because this just moves work that
we were already doing earlier.

Review URL: https://codereview.appspot.com/6634049

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1653 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 945
+ add missing cast in insert_push_retaddr() for 4-byte x64 retaddr

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1654 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
proper checking for GetEnvironmentVariable return value

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1655 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6
fixes issue 946

When translating the state of a selfmod fragment, recreate from the copy of
the app code, pretending to be at the original pc (so low-2GB
instrumentation differences don't surface).

Added a fault test to the selfmod test.  As part of this added sharing of
signal handler code and sigsetjmp throughout the suite.

git-svn-id: https://dynamorio.googlecode.com/svn/trunk@1656 49cc7528-f6fd-11dd-9d1a-b59b2e1864b6