[aslr-analysis] Switch to fdio_spawn_etc
Most codepaths that create processes should use fdio_spawn rather than
launchpad directly.
Test: Manually ran aslr-analysis
Change-Id: I818e2142ba332f7b6ed123aca4acf35aa2690b81
diff --git a/system/uapp/aslr-analysis/main.cpp b/system/uapp/aslr-analysis/main.cpp
index c4a364d..fdbf3ec 100644
--- a/system/uapp/aslr-analysis/main.cpp
+++ b/system/uapp/aslr-analysis/main.cpp
@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <inttypes.h>
-#include <fcntl.h>
-#include <launchpad/launchpad.h>
-#include <launchpad/vmo.h>
-#include <limits.h>
-#include <math.h>
-#include <lib/fdio/io.h>
#include <fbl/algorithm.h>
#include <fbl/array.h>
#include <fbl/auto_call.h>
#include <fbl/unique_ptr.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <lib/fdio/io.h>
+#include <lib/fdio/spawn.h>
+#include <limits.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -219,34 +218,22 @@
}
// This function unconditionally consumes the handle h.
-zx_status_t LaunchTestRun(const char* bin, zx_handle_t h, zx_handle_t* out) {
- launchpad_t* lp;
- zx_handle_t proc;
- zx_handle_t hnd[1];
- zx_handle_t job;
- uint32_t ids[1];
- const char* args[] = {bin, "testrun"};
- const char* errmsg;
+zx_status_t LaunchTestRun(const char* bin, zx_handle_t h, zx_handle_t* proc) {
+ const char* argv[] = {bin, "testrun", nullptr};
- zx_status_t status = zx_handle_duplicate(zx_job_default(), ZX_RIGHT_SAME_RIGHTS, &job);
- if (status != ZX_OK) {
- return status;
- }
+ fdio_spawn_action_t actions[2];
+ actions[0].action = FDIO_SPAWN_ACTION_SET_NAME;
+ actions[0].name.data = "testrun";
+ actions[1].action = FDIO_SPAWN_ACTION_ADD_HANDLE;
+ actions[1].h = {.id = PA_USER1, .handle = h};
- ids[0] = PA_USER1;
- hnd[0] = h;
- launchpad_create(job, "testrun", &lp);
- launchpad_load_from_file(lp, bin);
- launchpad_set_args(lp, static_cast<int>(fbl::count_of(args)), args);
- launchpad_add_handles(lp, fbl::count_of(hnd), hnd, ids);
+ char err_msg[FDIO_SPAWN_ERR_MSG_MAX_LENGTH];
+ zx_status_t status = fdio_spawn_etc(ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_LDSVC, bin, argv,
+ nullptr, fbl::count_of(actions), actions, proc, err_msg);
- status = launchpad_go(lp, &proc, &errmsg);
- if (status != ZX_OK) {
- printf("launch failed (%d): %s\n", status, errmsg);
- return status;
- }
+ if (status != ZX_OK)
+ printf("launch failed (%d): %s\n", status, err_msg);
- *out = proc;
return ZX_OK;
}
diff --git a/system/uapp/aslr-analysis/rules.mk b/system/uapp/aslr-analysis/rules.mk
index e90c549..91a6f30 100644
--- a/system/uapp/aslr-analysis/rules.mk
+++ b/system/uapp/aslr-analysis/rules.mk
@@ -18,7 +18,6 @@
system/ulib/runtime
MODULE_LIBS := \
- system/ulib/launchpad \
system/ulib/zircon \
system/ulib/c \
system/ulib/fdio \