OLD | NEW |
1 About | 1 About |
2 ===== | 2 ===== |
3 | 3 |
4 This directory contains the necessary components to run Non-SFI NaCl | 4 This directory contains the necessary components to run Non-SFI NaCl |
5 nexes (native executables) from within Mojo. | 5 nexes (native executables) from within Mojo. |
6 | 6 |
7 Using | 7 Using |
8 ===== | 8 ===== |
9 | 9 |
10 The Non-SFI NaCl and accompanying tests should be built by default for Linux. | 10 The Non-SFI NaCl and accompanying tests should be built by default for Linux. |
11 The boolean indicating if they are built is "mojo_use_nacl_nonsfi", defined | 11 The boolean indicating if they are built is "mojo_use_nacl_nonsfi", defined |
12 inside the BUILD files. | 12 inside the BUILD files. |
13 | 13 |
| 14 Building Non-SFI NaCl |
| 15 --------------------- |
| 16 |
14 Build Mojo (all following commands assume you are in the root of the mojo | 17 Build Mojo (all following commands assume you are in the root of the mojo |
15 repository): | 18 repository): |
16 | 19 |
17 ``` | 20 ``` |
18 $ ./mojo/tools/mojob.py gn | 21 $ ./mojo/tools/mojob.py gn |
19 $ ./mojo/tools/mojob.py build | 22 $ ./mojo/tools/mojob.py build |
20 ``` | 23 ``` |
21 | 24 |
22 Doing this build step will automatically create a pexe of unit tests, at | 25 Doing this build step will automatically create the necessary content handlers |
23 `./out/Debug/newlib_pnacl/monacl_test.pexe`. To translate a pexe into a | 26 and pexes. |
24 non-SFI nexe: | 27 |
| 28 Translating and Running Pexes |
| 29 ----------------------------- |
| 30 |
| 31 When portable executable files (pexes) are generated by mojo, they are created |
| 32 as `.pexe.mojo` files. These pexes are generated by building a gn target with |
| 33 the `mojo_native_application` template with a PNaCl toolchain. |
| 34 |
| 35 The "pexe" part of the name comes from the fact that they are portable, and the |
| 36 "mojo" part of the name comes from the fact that they have the line `#!mojo |
| 37 mojo:content_handler_nonsfi_pexe` prepended to them, so the appropriate pexe |
| 38 content handler can be found by the Mojo Shell. |
| 39 |
| 40 To run the `FOOBAR.pexe.mojo` pexe (aka, to translate and execute it), run the |
| 41 following: |
| 42 |
| 43 ``` |
| 44 $ ./out/Debug/mojo_shell --enable-multiprocess ./out/Debug/FOOBAR.pexe.mojo |
| 45 ``` |
| 46 |
| 47 or, alternatively, for a version compatible with Android: |
| 48 |
| 49 ``` |
| 50 $ ./mojo/devtools/common/mojo_run --enable-multiprocess mojo:FOOBAR.pexe |
| 51 [--android] |
| 52 ``` |
| 53 |
| 54 For more information on the process of translating and handling nexes and pexes, |
| 55 refer to the `services/nacl` directory. |
| 56 |
| 57 Manually Translating Pexes and Running Nexes |
| 58 -------------------------------------------- |
| 59 |
| 60 A raw pexe of unit tests will be built, at |
| 61 `./out/Debug/newlib_pnacl/monacl_test.pexe`. To manually translate this pexe |
| 62 into a non-SFI nexe: |
25 | 63 |
26 ``` | 64 ``` |
27 $ ./native_client/toolchain/linux_x86/pnacl_newlib/bin/pnacl-translate \ | 65 $ ./native_client/toolchain/linux_x86/pnacl_newlib/bin/pnacl-translate \ |
28 ./out/Debug/newlib_pnacl/FOOBAR.pexe -o FOOBAR.nexe -arch x86-32-nonsfi | 66 ./out/Debug/newlib_pnacl/FOOBAR.pexe -o FOOBAR.nexe -arch x86-32-nonsfi |
29 ``` | 67 ``` |
30 | 68 |
31 Now, you should have the fully translated nexe (called | 69 Now, you should have the fully translated nexe (called |
32 "FOOBAR.nexe"). You can run the nexe through the monacl shell | 70 `FOOBAR.nexe`). You can run the nexe through the monacl shell |
33 (a minimal, "nexe-only" shell, which loads the nexe ELF file -- see | 71 (a minimal, "nexe-only" shell, which loads the nexe ELF file -- see |
34 monacl_shell_nonsfi.cc): | 72 `monacl_shell_nonsfi.cc`): |
35 | 73 |
36 ``` | 74 ``` |
37 $ ./out/Debug/clang_x86/monacl_shell_nonsfi FOOBAR.nexe | 75 $ ./out/Debug/clang_x86/monacl_shell_nonsfi FOOBAR.nexe |
38 ``` | 76 ``` |
39 | 77 |
40 This monacl_shell_nonsfi is the easiest way to run nexes in Mojo -- however, it | 78 This monacl_shell_nonsfi is the easiest way to run nexes in Mojo -- however, it |
41 is not the only way. Usually, applications are launched through the | 79 is not the only way. Usually, applications are launched through the |
42 "mojo_shell", but some additional information is required to know how to handle | 80 "mojo_shell", but some additional information is required to know how to handle |
43 this content (i.e., how does the mojo_shell know it is dealing with a nonsfi | 81 this content (i.e., how does the mojo_shell know it is dealing with a nonsfi |
44 nexe?). | 82 nexe?). |
45 | 83 |
46 The BUILD.gn files in Mojo automatically make this pexe, translate it to a | 84 The BUILD.gn files in Mojo automatically make the "monacl_test" pexe, translate |
47 nexe, and prepend a line ("#!mojo mojo:content_handler_nonsfi_nexe") to the | 85 it to a nexe, and prepend a line (`#!mojo mojo:content_handler_nonsfi_nexe`) to |
48 front of the file, at which point it is also runnable through the mojo_shell. | 86 the front of the file, at which point it is also runnable through the |
| 87 mojo_shell. |
49 These files, which start with this "#!" line, are ".mojo" files. The nexes can | 88 These files, which start with this "#!" line, are ".mojo" files. The nexes can |
50 be run like this: | 89 be run like this: |
51 | 90 |
52 ``` | 91 ``` |
53 $ ./out/Debug/mojo_shell --enable-multiprocess out/Debug/FOOBAR.mojo | 92 $ ./out/Debug/mojo_shell --enable-multiprocess out/Debug/FOOBAR.mojo |
54 ``` | 93 ``` |
55 | |
56 TODO | |
57 ==== | |
58 | |
59 * Use subzero (a NaCl project to improve translation speed) for pexe | |
60 translation. | |
61 * Enable caching of translated pexes. | |
OLD | NEW |