diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-10 17:54:23 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-10 17:54:23 +0000 |
| commit | f19998032421ab78400a451e9b684de36f2347ad (patch) | |
| tree | 35eee218be6adb9ce0db26077e93a2a7dac1b872 /docs/busybox.net/programming.html | |
| parent | 602aa28af7e507a010e6b5dfb7804963af60e1c5 (diff) | |
| download | busybox-w32-f19998032421ab78400a451e9b684de36f2347ad.tar.gz busybox-w32-f19998032421ab78400a451e9b684de36f2347ad.tar.bz2 busybox-w32-f19998032421ab78400a451e9b684de36f2347ad.zip | |
Notes about pic, static linking, and debugging dynamic linking.
git-svn-id: svn://busybox.net/trunk/busybox@14791 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'docs/busybox.net/programming.html')
| -rw-r--r-- | docs/busybox.net/programming.html | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/docs/busybox.net/programming.html b/docs/busybox.net/programming.html index 7afa53e27..1214e70f7 100644 --- a/docs/busybox.net/programming.html +++ b/docs/busybox.net/programming.html | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | <li><a href="#tips_encrypted_passwords">Encrypted Passwords</a></li> | 17 | <li><a href="#tips_encrypted_passwords">Encrypted Passwords</a></li> |
| 18 | <li><a href="#tips_vfork">Fork and vfork</a></li> | 18 | <li><a href="#tips_vfork">Fork and vfork</a></li> |
| 19 | <li><a href="#tips_short_read">Short reads and writes</a></li> | 19 | <li><a href="#tips_short_read">Short reads and writes</a></li> |
| 20 | <li><a href="#tips_memory">Memory used by relocatable code, PIC, and static linking.</a></li> | ||
| 20 | </ul> | 21 | </ul> |
| 21 | <li><a href="#who">Who are the BusyBox developers?</a></li> | 22 | <li><a href="#who">Who are the BusyBox developers?</a></li> |
| 22 | </ul> | 23 | </ul> |
| @@ -346,6 +347,35 @@ data comes in that can be merged into the same packet. (In case you were | |||
| 346 | wondering why action games that use TCP/IP set TCP_NODELAY to lower the latency | 347 | wondering why action games that use TCP/IP set TCP_NODELAY to lower the latency |
| 347 | on their their sockets, now you know.)</p> | 348 | on their their sockets, now you know.)</p> |
| 348 | 349 | ||
| 350 | <h2><a name="tips_memory">Memory used by relocatable code, PIC, and static linking.</a></h2> | ||
| 351 | |||
| 352 | <p>The downside of standard dynamic linking is that it results in self-modifying | ||
| 353 | code. Although each executable's pages are mmaped() into a process's address | ||
| 354 | space from the executable file and are thus naturally shared between processes | ||
| 355 | out of the page cache, the library loader (ld-linux.so.2 or ld-uClibc.so.0) | ||
| 356 | writes to these pages to supply addresses for relocatable symbols. This | ||
| 357 | dirties the pages, triggering copy-on-write allocation of new memory for each | ||
| 358 | processes's dirtied pages.</p> | ||
| 359 | |||
| 360 | <p>One solution to this is Position Independent Code (PIC), a way of linking | ||
| 361 | a file so all the relocations are grouped together. This dirties fewer | ||
| 362 | pages (often just a single page) for each process's relocations. The down | ||
| 363 | side is this results in larger executables, which take up more space on disk | ||
| 364 | (and a correspondingly larger space in memory). But when many copies of the | ||
| 365 | same program are running, PIC dynamic linking trades a larger disk footprint | ||
| 366 | for a smaller memory footprint, by sharing more pages.</p> | ||
| 367 | |||
| 368 | <p>A third solution is static linking. A statically linked program has no | ||
| 369 | relocations, and thus the entire executable is shared between all running | ||
| 370 | instances. This tends to have a significantly larger disk footprint, but | ||
| 371 | on a system with only one or two executables, shared libraries aren't much | ||
| 372 | of a win anyway.</p> | ||
| 373 | |||
| 374 | <p>You can tell the glibc linker to display debugging information about its | ||
| 375 | relocations with the environment variable "LD_DEBUG". Try | ||
| 376 | "LD_DEBUG=help /bin/true" for a list of commands. Learning to interperet | ||
| 377 | "LD_DEBUG=statistics cat /proc/self/statm" could be interesting.</p> | ||
| 378 | |||
| 349 | <h2><a name="who">Who are the BusyBox developers?</a></h2> | 379 | <h2><a name="who">Who are the BusyBox developers?</a></h2> |
| 350 | 380 | ||
| 351 | <p>The following login accounts currently exist on busybox.net. (I.E. these | 381 | <p>The following login accounts currently exist on busybox.net. (I.E. these |
| @@ -375,7 +405,6 @@ solar :Ned Ludd | |||
| 375 | timr :Tim Riker | 405 | timr :Tim Riker |
| 376 | tobiasa :Tobias Anderberg | 406 | tobiasa :Tobias Anderberg |
| 377 | vapier :Mike Frysinger | 407 | vapier :Mike Frysinger |
| 378 | vodz :Vladimir N. Oleynik | ||
| 379 | </pre> | 408 | </pre> |
| 380 | 409 | ||
| 381 | <p>The following accounts used to exist on busybox.net, but don't anymore so | 410 | <p>The following accounts used to exist on busybox.net, but don't anymore so |
| @@ -395,6 +424,7 @@ miles | |||
| 395 | proski | 424 | proski |
| 396 | rjune | 425 | rjune |
| 397 | tausq | 426 | tausq |
| 427 | vodz :Vladimir N. Oleynik | ||
| 398 | </pre> | 428 | </pre> |
| 399 | 429 | ||
| 400 | 430 | ||
