OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="dynamic-linking-and-loading-with-glibc"> | 3 <section id="dynamic-linking-and-loading-with-glibc"> |
4 <h1 id="dynamic-linking-and-loading-with-glibc">Dynamic Linking and Loading with
glibc</h1> | 4 <h1 id="dynamic-linking-and-loading-with-glibc">Dynamic Linking and Loading with
glibc</h1> |
5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
7 <li><a class="reference internal" href="#c-standard-libraries-glibc-and-newlib"
id="id1">C standard libraries: glibc and newlib</a></li> | 7 <li><a class="reference internal" href="#c-standard-libraries-glibc-and-newlib"
id="id1">C standard libraries: glibc and newlib</a></li> |
8 <li><a class="reference internal" href="#sdk-toolchains" id="id2">SDK toolchains
</a></li> | 8 <li><a class="reference internal" href="#sdk-toolchains" id="id2">SDK toolchains
</a></li> |
9 <li><p class="first"><a class="reference internal" href="#specifying-and-deliver
ing-shared-libraries" id="id3">Specifying and delivering shared libraries</a></p
> | 9 <li><p class="first"><a class="reference internal" href="#specifying-and-deliver
ing-shared-libraries" id="id3">Specifying and delivering shared libraries</a></p
> |
10 <ul class="small-gap"> | 10 <ul class="small-gap"> |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 <colgroup> | 133 <colgroup> |
134 </colgroup> | 134 </colgroup> |
135 <thead valign="bottom"> | 135 <thead valign="bottom"> |
136 <tr class="row-odd"><th class="head">Target architecture</th> | 136 <tr class="row-odd"><th class="head">Target architecture</th> |
137 <th class="head">C library</th> | 137 <th class="head">C library</th> |
138 <th class="head">Toolchain directory</th> | 138 <th class="head">Toolchain directory</th> |
139 </tr> | 139 </tr> |
140 </thead> | 140 </thead> |
141 <tbody valign="top"> | 141 <tbody valign="top"> |
142 <tr class="row-even"><td>x86</td> | 142 <tr class="row-even"><td>x86</td> |
143 <td>newlib</td> | |
144 <td>toolchain/<platform>_x86_newlib</td> | |
145 </tr> | |
146 <tr class="row-odd"><td>x86</td> | |
147 <td>glibc</td> | 143 <td>glibc</td> |
148 <td>toolchain/<platform>_x86_glibc</td> | 144 <td>toolchain/<platform>_x86_glibc</td> |
149 </tr> | 145 </tr> |
150 <tr class="row-even"><td>ARM</td> | 146 <tr class="row-odd"><td>ARM</td> |
151 <td>newlib</td> | 147 <td>glibc</td> |
152 <td>toolchain/<platform>_arm_newlib</td> | 148 <td>toolchain/<platform>_arm_glibc</td> |
153 </tr> | 149 </tr> |
154 <tr class="row-odd"><td>PNaCl</td> | 150 <tr class="row-even"><td>x86</td> |
155 <td>newlib</td> | 151 <td>newlib</td> |
156 <td>toolchain/<platform>_pnacl</td> | 152 <td>toolchain/<platform>_pnacl</td> |
157 </tr> | 153 </tr> |
| 154 <tr class="row-odd"><td>ARM</td> |
| 155 <td>newlib</td> |
| 156 <td>toolchain/<platform>_pnacl</td> |
| 157 </tr> |
| 158 <tr class="row-even"><td>PNaCl</td> |
| 159 <td>newlib</td> |
| 160 <td>toolchain/<platform>_pnacl</td> |
| 161 </tr> |
158 </tbody> | 162 </tbody> |
159 </table> | 163 </table> |
160 <p>In the directories listed above, <platform> is the platform of your dev
elopment | 164 <p>In the directories listed above, <platform> is the platform of your dev
elopment |
161 machine (i.e., win, mac, or linux). For example, in the Windows SDK, the x86 | 165 machine (i.e., win, mac, or linux). For example, in the Windows SDK, the x86 |
162 toolchain that uses glibc is in <code>toolchain/win_x86_glibc</code>.</p> | 166 toolchain that uses glibc is in <code>toolchain/win_x86_glibc</code>.</p> |
163 <aside class="note"> | 167 <aside class="note"> |
164 <strong>Note:</strong> The ARM and PNaCl toolchains are currently restricted to
newlib. | 168 <strong>Note:</strong> The PNaCl toolchain is currently restricted to newlib. |
165 </aside> | 169 </aside> |
166 <p>To use the glibc library and dynamic linking in your application, you <strong
>must</strong> | 170 <p>To use the glibc library and dynamic linking in your application, you <strong
>must</strong> |
167 use a glibc toolchain. (Currently the only glibc toolchain is | 171 use a glibc toolchain. Note that you must build all code in your application |
168 <code><platform>_x86_glibc</code>.) Note that you must build all code in y
our application | |
169 with one toolchain. Code from multiple toolchains cannot be mixed.</p> | 172 with one toolchain. Code from multiple toolchains cannot be mixed.</p> |
170 <h2 id="specifying-and-delivering-shared-libraries">Specifying and delivering sh
ared libraries</h2> | 173 <h2 id="specifying-and-delivering-shared-libraries">Specifying and delivering sh
ared libraries</h2> |
171 <p>One significant difference between newlib and glibc applications is that glib
c | 174 <p>One significant difference between newlib and glibc applications is that glib
c |
172 applications must explicitly list and deploy the shared libraries that they | 175 applications must explicitly list and deploy the shared libraries that they |
173 use.</p> | 176 use.</p> |
174 <p>In a desktop environment, when the user launches a dynamically linked | 177 <p>In a desktop environment, when the user launches a dynamically linked |
175 application, the operating system’s program loader determines the set of | 178 application, the operating system’s program loader determines the set of |
176 libraries the application requires by reading explicit inter-module | 179 libraries the application requires by reading explicit inter-module |
177 dependencies from executable file headers, and loads the required libraries | 180 dependencies from executable file headers, and loads the required libraries |
178 into the address space of the application process. Typically the required | 181 into the address space of the application process. Typically the required |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 <dt>dlopen.cc</dt> | 222 <dt>dlopen.cc</dt> |
220 <dd>This file implements the Native Client module, which loads the two shared | 223 <dd>This file implements the Native Client module, which loads the two shared |
221 libraries and handles communcation with with JavaScript. The file is compiled | 224 libraries and handles communcation with with JavaScript. The file is compiled |
222 into a Native Client executable (.nexe).</dd> | 225 into a Native Client executable (.nexe).</dd> |
223 </dl> | 226 </dl> |
224 <p>Run <code>make</code> in the dlopen directory to see the commands the Makefil
e executes | 227 <p>Run <code>make</code> in the dlopen directory to see the commands the Makefil
e executes |
225 to build x86 32-bit and 64-bit .nexe and .so files, and to generate a .nmf | 228 to build x86 32-bit and 64-bit .nexe and .so files, and to generate a .nmf |
226 file. These commands are described below.</p> | 229 file. These commands are described below.</p> |
227 <aside class="note"> | 230 <aside class="note"> |
228 <strong>Note:</strong> The Makefiles for most of the examples in the SDK build t
he | 231 <strong>Note:</strong> The Makefiles for most of the examples in the SDK build t
he |
229 examples using multiple toolchains (x86 newlib, x86 glibc, ARM, and PNaCl). | 232 examples using multiple toolchains (x86 newlib, x86 glibc, ARM newlib, ARM |
230 With a few exceptions (listed in the <a class="reference internal" href="/native
-client/sdk/release-notes.html#sdk-release-notes"><em>Release Notes</em></a>), r
unning “make” in each example’s directory builds | 233 glibc, and PNaCl). With a few exceptions (listed in the <a class="reference int
ernal" href="/native-client/sdk/release-notes.html#sdk-release-notes"><em>Releas
e Notes</em></a>), running “make” in each example’s directory
builds |
231 multiple versions of the example using the SDK toolchains. The dlopen example | 234 multiple versions of the example using the SDK toolchains. The dlopen example |
232 is one of those exceptions – it is only built with the x86 glibc toolchain, | 235 is one of those exceptions – it is only built with the x86 glibc toolchain, |
233 as that is currently the only toolchain that supports glibc and thus dynamic | 236 as that is currently the only toolchain that supports glibc and thus dynamic |
234 linking and loading. Take a look at the example Makefiles and the generated | 237 linking and loading. Take a look at the example Makefiles and the generated |
235 .nmf files for details on how to build dynamically linked applications. | 238 .nmf files for details on how to build dynamically linked applications. |
236 </aside> | 239 </aside> |
237 <h3 id="generating-a-native-client-manifest-file-for-a-dynamically-linked-applic
ation"><span id="dynamic-loading-manifest"></span>Generating a Native Client man
ifest file for a dynamically linked application</h3> | 240 <h3 id="generating-a-native-client-manifest-file-for-a-dynamically-linked-applic
ation"><span id="dynamic-loading-manifest"></span>Generating a Native Client man
ifest file for a dynamically linked application</h3> |
238 <p>The Native Client manifest file specifies the name of the executable to run | 241 <p>The Native Client manifest file specifies the name of the executable to run |
239 and must also specify any shared libraries that the application directly | 242 and must also specify any shared libraries that the application directly |
240 depends on. For indirect dependencies (such as libraries opened via | 243 depends on. For indirect dependencies (such as libraries opened via |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 in the .nmf file – either the files are the wrong type or kind, or an | 416 in the .nmf file – either the files are the wrong type or kind, or an |
414 expected library is missing.</dd> | 417 expected library is missing.</dd> |
415 <dt><strong>undefined reference to ‘dlopen’ collect2: ld returned 1
exit status</strong></dt> | 418 <dt><strong>undefined reference to ‘dlopen’ collect2: ld returned 1
exit status</strong></dt> |
416 <dd>This is a linker ordering problem that usually results from improper orderin
g | 419 <dd>This is a linker ordering problem that usually results from improper orderin
g |
417 of command line flags when linking. Reconfigure your command line string to | 420 of command line flags when linking. Reconfigure your command line string to |
418 list libraries after the -o flag.</dd> | 421 list libraries after the -o flag.</dd> |
419 </dl> | 422 </dl> |
420 </section> | 423 </section> |
421 | 424 |
422 {{/partials.standard_nacl_article}} | 425 {{/partials.standard_nacl_article}} |
OLD | NEW |