1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <string>
18 
19 #include "berberis/base/file.h"
20 #include "berberis/guest_loader/guest_loader.h"
21 #include "berberis/runtime/berberis.h"
22 
23 namespace berberis {
24 
Run(const char * vdso_path,const char * loader_path,int argc,const char * argv[],char * envp[],std::string * error_msg)25 bool Run(const char* vdso_path,
26          const char* loader_path,
27          int argc,
28          const char* argv[],
29          char* envp[],
30          std::string* error_msg) {
31   InitBerberis();
32 
33   std::string executable_realpath;
34   if (!Realpath(argv[0], &executable_realpath)) {
35     *error_msg = std::string("Unable to get realpath of ") + argv[0];
36     return false;
37   }
38 
39   GuestLoader::StartExecutable(
40       executable_realpath.c_str(), vdso_path, loader_path, argc, argv, envp, error_msg);
41 
42   return false;
43 }
44 
45 }  // namespace berberis
46