1# zx_vmo_replace_as_executable
2
3## NAME
4
5vmo_replace_as_executable - add execute rights to a vmo
6
7## SYNOPSIS
8
9```
10#include <zircon/syscalls.h>
11
12zx_status_t zx_vmo_replace_as_executable(zx_handle_t vmo, zx_handle_t vmex, zx_handle_t* out);
13
14```
15
16## DESCRIPTION
17
18**vmo_replace_as_executable**() creates a replacement for *vmo*, referring
19to the same underlying VM object, adding the right **ZX_RIGHT_EXECUTE**.
20
21*vmo* is always invalidated.
22
23## RIGHTS
24
25*vmex* must be a valid **ZX_RSRC_KIND_VMEX** resource handle,
26or **ZX_HANDLE_INVALID** (to ease migration of old code).
27
28TODO(SEC-42): Disallow **ZX_HANDLE_INVALID**.
29
30## RETURN VALUE
31
32**vmo_replace_as_executable**() returns **ZX_OK** on success. In the event
33of failure, a negative error value is returned.
34
35## ERRORS
36
37**ZX_ERR_BAD_HANDLE**  *vmo* isn't a valid VM object handle, or
38*vmex* isn't a valid **ZX_RSRC_KIND_VMEX** resource handle.
39
40**ZX_ERR_NO_MEMORY**  Failure due to lack of memory.
41There is no good way for userspace to handle this (unlikely) error.
42In a future build this error will no longer occur.
43
44## SEE ALSO
45
46[resource_create](resource_create.md),
47[vmar_map](vmar_map.md).
48