1# zx_vmo_replace_as_executable
2
3## NAME
4
5<!-- Updated by update-docs-from-abigen, do not edit. -->
6
7vmo_replace_as_executable - add execute rights to a vmo
8
9## SYNOPSIS
10
11<!-- Updated by update-docs-from-abigen, do not edit. -->
12
13```
14#include <zircon/syscalls.h>
15
16zx_status_t zx_vmo_replace_as_executable(zx_handle_t handle,
17                                         zx_handle_t vmex,
18                                         zx_handle_t* out);
19```
20
21## DESCRIPTION
22
23`zx_vmo_replace_as_executable()` creates a replacement for *handle*, referring
24to the same underlying VM object, adding the right **ZX_RIGHT_EXECUTE**.
25
26*handle* is always invalidated.
27
28*vmex* may currently be **ZX_HANDLE_INVALID** to ease migration of new code,
29this is TODO(SEC-42) and will be removed.
30
31## RIGHTS
32
33<!-- Updated by update-docs-from-abigen, do not edit. -->
34
35*handle* must be of type **ZX_OBJ_TYPE_VMO**.
36
37*vmex* must have resource kind **ZX_RSRC_KIND_VMEX**.
38
39## RETURN VALUE
40
41`zx_vmo_replace_as_executable()` returns **ZX_OK** on success. In the event
42of failure, a negative error value is returned.
43
44## ERRORS
45
46**ZX_ERR_BAD_HANDLE**  *handle* isn't a valid VM object handle, or
47*vmex* isn't a valid **ZX_RSRC_KIND_VMEX** resource handle.
48
49**ZX_ERR_NO_MEMORY**  Failure due to lack of memory.
50There is no good way for userspace to handle this (unlikely) error.
51In a future build this error will no longer occur.
52
53## SEE ALSO
54
55 - [`zx_resource_create()`]
56 - [`zx_vmar_map()`]
57
58<!-- References updated by update-docs-from-abigen, do not edit. -->
59
60[`zx_resource_create()`]: resource_create.md
61[`zx_vmar_map()`]: vmar_map.md
62