Pre Linking

From eLinux.org
Revision as of 02:17, 28 October 2011 by Cschalle (Talk | contribs) (Add category)

Jump to: navigation, search

Description

Pre-Linking is a mechanism for linking programs to shared libraries ahead of time. In general, every time an application is run it must have it's external symbols resolved - looked up in the shared library symbol table, and fixed up in the program binary to refer to the correct offsets in the library. To use prelinking, a special utility is run which does this resolution and fixup once for the program. This saves the cost of linking at runtime.

There is an existing package from RedHat which provides this feature.

A drawback of this is that if the shared library is changed, the fixups are no longer correct, and the program must be fixed-up again. This is much less of an issue in an embedded situation, where the programs and libraries are less likely to change than in a desktop or server Linux system.

Overview of linking

There is an excellent paper with an overview of dynamic linking issues at: Pre Linking Overview This paper describes not only pre-linking, but lazy linking and more exotic systems, like compile-on-load.

Expected Improvement

[This is not measured yet.]

We expect that with use of prelinking, there will be a slight reduction in boot time for Linux system, in the area of initial application loading.

We need to use this system and measure the effect of prelinking for a determined set of applications.

Resources

RedHat prelinking system

prelink currently supports the following architectures: alpha, arm, cris, i386, ia64, ppc32, ppc64, s390, sh, sparc32, sparc64, x86_64. At present the glibc dynamic linker is required to prelink executables and load prelinked code, uClibc does not support it.

Instructions for using prelinking with Gentoo

The following page has information on how to use prelinking with a Gentoo system:

http://www.gentoo.org/doc/en/prelink-howto.xml

Related Projects

http://mail-index.netbsd.org/tech-userlevel/2002/12/01/0000.html

  • Resident - Resident Good (comparisons with prebind)

http://www.shiningsilence.com/dbsdlog/2004/01/20/215.html


Specifications

None so far.

Patches

No kernel patches required for kernels 2.4.10 and later.

Case Studies

Case 1 - Panasonic mobile phone prelink

Panasonic used pre-linking on their Linux-based mobile phones. These used a 2.4.x Linux kernel, for an ARM processor. Measuring the time to load a single multimedia application with regular dynamic linking and pre-linking, showed that pre-linking could save a lot of time.

Hardware 
ARM9 (unspecified CPU frequency)
Kernel Version 
2.4.20 (based on Monta Vista Linux CEE 3.1), glibc 2.3
Time without change 
2479 ms
Time with change 
125 ms
Source 
page 19 of Making Mobile Phone with CE Linux

Case 2

Case 3

Future Work

This item is a work-in-progress, and we are just getting started.

Material from CELF presentations

ARM Prelink

MIPS Prelink
{"cc_re__cc_re__cc_by_sa_3_0": ["ent link to this revision of the page\">Permanent link</a></li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li id=\"t-info\"><a href=\"/index.php?title=Pre_Linking&amp;action=info\" title=\"More information about this page\">Page information</a></li>\n\t\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</div>\n\t\t</div>\n\t\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"footer\" role=\"contentinfo\">\n\t\t\t\t\t\t\t<ul id=\"footer-info\">\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-info-viewcount\">This page has been accessed 29,931 times.</li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-info-copyright\">Content is available under <a class=\"external\" rel=\"nofollow\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\">a Creative Commons Attribution-ShareAlike 3.0 Unported License</a> unless otherwise noted.</li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t<ul id=\"footer-places\">\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-places-privacy\"><a href=\"/eLinux.org:Privacy_policy\" title=\"eLinux.org:Privacy policy\">Privacy policy</a></li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-places-about\"><a href=\"/eLinux.org:About\" title=\"eLinux.org:About\">About eLinux.org</a></li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-places-disclaimer\"><a href=\"/eLinux.org:General_disclaimer\" title=\"eLinux.or", "oter-places-privacy\"><a href=\"/eLinux.org:Privacy_policy\" title=\"eLinux.org:Privacy policy\">Privacy policy</a></li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-places-about\"><a href=\"/eLinux.org:About\" title=\"eLinux.org:About\">About eLinux.org</a></li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-places-disclaimer\"><a href=\"/eLinux.org:General_disclaimer\" title=\"eLinux.org:General disclaimer\">Disclaimers</a></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t\t\t<ul id=\"footer-icons\" class=\"noprint\">\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-copyrightico\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"http://creativecommons.org/licenses/by-sa/3.0/\"><img src=\"http://i.creativecommons.org/l/by-sa/3.0/88x31.png\" alt=\"a Creative Commons Attribution-ShareAlike 3.0 Unported License\" width=\"88\" height=\"31\" /></a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t\t<li id=\"footer-poweredbyico\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"//www.mediawiki.org/\"><img src=\"/resources/assets/poweredby_mediawiki_88x31.png\" alt=\"Powered by MediaWiki\" srcset=\"/resources/assets/poweredby_mediawiki_132x47.png 1.5x, /resources/assets/poweredby_mediawiki_176x62.png 2x\" width=\"88\" height=\"31\" /></a>\n\t"], "copyright__copyright__copyright": ["", "le multimedia application with regular dynamic linking and pre-linking, showed that pre-linking could save a lot of time.\n\nHardware\u00a0\nARM9 (unspecified CPU frequency)\nKernel Version\u00a0\n2.4.20 (based on Monta Vista Linux CEE 3.1), glibc 2.3\nTime without change\u00a0\n2479 ms\nTime with change\u00a0\n125 ms\nSource\u00a0\npage 19 of Making Mobile Phone with CE Linux\n\nCase 2\n\nCase 3\n\nFuture Work\n\nThis item is a work-in-progress, and we are just getting started.\n\nMaterial from CELF presentations\n\nARM Prelink\n\nMIPS Prelink", "le multimedia application with regular dynamic linking and pre-linking, showed that pre-linking could save a lot of time.\n\nHardware\u00a0\nARM9 (unspecified CPU frequency)\nKernel Version\u00a0\n2.4.20 (based on Monta Vista Linux CEE 3.1), glibc 2.3\nTime without change\u00a0\n2479 ms\nTime with change\u00a0\n125 ms\nSource\u00a0\npage 19 of Making Mobile Phone with CE Linux\n\nCase 2\n\nCase 3\n\nFuture Work\n\nThis item is a work-in-progress, and we are just getting started.\n\nMaterial from CELF presentations\n\nARM Prelink\n\nMIPS Prelink"]}