Optimizing Linker Load Times
Posted Jul 27, 2006 22:13 UTC (Thu) by
bluefoxicy (guest, #25366)
In reply to:
Optimizing Linker Load Times by kevinliao
Parent article:
Optimizing Linker Load Times
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.
(
Log in to post comments)