Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
Does the fisrt method (-Wl,-O1) only apply to shared library? Or it can also be used for normal applications? Thanks a lot.
Optimizing Linker Load Times
Posted Jul 27, 2006 22:13 UTC (Thu) by bluefoxicy (guest, #25366)
It applies to the created object. So if you link glibc or GTK+ with -Wl,-O1, any program that uses glibc or GTK+ will benefit.
As for whether you can build applications with -Wl,-O1, this is absolutely possible. Applications have a .dynsym section and do export symbols. Most symbols are undefined in the executable and must get resolved to a shared library; but there are a few that are straight exported. Looking at gaim:
bluefox@icebox:~$ readelf -s /usr/bin/gaim|grep -v UND
Symbol table '.dynsym' contains 2669 entries:
Num: Value Size Type Bind Vis Ndx Name
3: 0806ef4d 131 FUNC GLOBAL DEFAULT 14 gaim_account_supports_off
4: 080aa128 163 FUNC GLOBAL DEFAULT 14 gaim_markup_get_tag_name
6: 08091136 49 FUNC GLOBAL DEFAULT 14 gaim_plugin_pref_get_name
7: 080b5db8 141 FUNC GLOBAL DEFAULT 14 gaim_whiteboard_destroy
8: 080a5336 162 FUNC GLOBAL DEFAULT 14 gaim_ssl_read
The list goes on. With some applications this is useful; you can dlopen() a library (i.e. a plug-in) and have its undefined symbols resolve to symbols in the main executable. This of course means that this symbol table gets searched too; so if you don't want to parse 'gaim_' over and over again 5-10 times in whatever bucket you land in, build the gaim executable with -Wl,-O1 and make sure only say 1-3 fall in the same bucket.
In short, yes, it's both safe, sane, and purposeful to use this everywhere.
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds