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 | |
Petr Hosek
2015/11/11 17:26:17
Nit: Mojo
| |
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 these pexes (which translates and executes them), run the following: | |
41 | |
42 ``` | |
43 $ ./out/Debug/mojo_shell --enable-multiprocess ./out/Debug/FOOBAR.pexe.mojo | |
44 ``` | |
45 | |
46 For more information on the process of translating and handling nexes and pexes, | |
47 refer to the "services/nacl" directory. | |
48 | |
49 Manually Translating Pexes and Running Nexes | |
50 -------------------------------------------- | |
51 | |
52 A raw pexe of unit tests will be built, at | |
53 `./out/Debug/newlib_pnacl/monacl_test.pexe`. To manually translate this pexe | |
54 into a non-SFI nexe: | |
25 | 55 |
26 ``` | 56 ``` |
27 $ ./native_client/toolchain/linux_x86/pnacl_newlib/bin/pnacl-translate \ | 57 $ ./native_client/toolchain/linux_x86/pnacl_newlib/bin/pnacl-translate \ |
28 ./out/Debug/newlib_pnacl/FOOBAR.pexe -o FOOBAR.nexe -arch x86-32-nonsfi | 58 ./out/Debug/newlib_pnacl/FOOBAR.pexe -o FOOBAR.nexe -arch x86-32-nonsfi |
29 ``` | 59 ``` |
30 | 60 |
31 Now, you should have the fully translated nexe (called | 61 Now, you should have the fully translated nexe (called |
32 "FOOBAR.nexe"). You can run the nexe through the monacl shell | 62 "FOOBAR.nexe"). You can run the nexe through the monacl shell |
33 (a minimal, "nexe-only" shell, which loads the nexe ELF file -- see | 63 (a minimal, "nexe-only" shell, which loads the nexe ELF file -- see |
34 monacl_shell_nonsfi.cc): | 64 monacl_shell_nonsfi.cc): |
35 | 65 |
36 ``` | 66 ``` |
37 $ ./out/Debug/clang_x86/monacl_shell_nonsfi FOOBAR.nexe | 67 $ ./out/Debug/clang_x86/monacl_shell_nonsfi FOOBAR.nexe |
38 ``` | 68 ``` |
39 | 69 |
40 This monacl_shell_nonsfi is the easiest way to run nexes in Mojo -- however, it | 70 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 | 71 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 | 72 "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 | 73 this content (i.e., how does the mojo_shell know it is dealing with a nonsfi |
44 nexe?). | 74 nexe?). |
45 | 75 |
46 The BUILD.gn files in Mojo automatically make this pexe, translate it to a | 76 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 | 77 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. | 78 the front of the file, at which point it is also runnable through the |
79 mojo_shell. | |
49 These files, which start with this "#!" line, are ".mojo" files. The nexes can | 80 These files, which start with this "#!" line, are ".mojo" files. The nexes can |
50 be run like this: | 81 be run like this: |
51 | 82 |
52 ``` | 83 ``` |
53 $ ./out/Debug/mojo_shell --enable-multiprocess out/Debug/FOOBAR.mojo | 84 $ ./out/Debug/mojo_shell --enable-multiprocess out/Debug/FOOBAR.mojo |
54 ``` | 85 ``` |
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 |