mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-01-27 09:42:12 +08:00
building-notes: mention -Wl,-z,pack-relative-relocs
This commit is contained in:
parent
1685f477ab
commit
ec3211006d
@ -1067,10 +1067,20 @@ chmod 744 /usr/sbin/strip-all.sh</userinput></screen>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For <envar>LDFLAGS</envar>, there are two options can be used
|
||||
for optimization. With <option>-Wl,-O1</option>, the linker will
|
||||
optimize the hash table to speed up the dynamic linking. And with
|
||||
<option>-Wl,--as-needed</option>, the linker will disregard
|
||||
For <envar>LDFLAGS</envar>, there are three options can be used
|
||||
for optimization. They are quite safe to use and the building
|
||||
system of some packages use some of these options as the default.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
With <option>-Wl,-O1</option>, the linker will
|
||||
optimize the hash table to speed up the dynamic linking.
|
||||
Note that <option>-Wl,-O1</option> is completely unrelated to the
|
||||
compiler optimization flag <option>-O1</option>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
With <option>-Wl,--as-needed</option>, the linker will disregard
|
||||
unnecessary <option>-l<replaceable>foo</replaceable></option> options
|
||||
from the command line, i. e. the shared library <systemitem
|
||||
class='library'>lib<replaceable>foo</replaceable></systemitem>
|
||||
@ -1078,22 +1088,26 @@ chmod 744 /usr/sbin/strip-all.sh</userinput></screen>
|
||||
class='library'>lib<replaceable>foo</replaceable></systemitem> is
|
||||
really referred from the executable or shared library being linked.
|
||||
This can sometimes mitigate the <quote>excessive dependencies to
|
||||
shared librarues</quote> issues caused by
|
||||
<application>libtool</application>. Note that the
|
||||
<option>-Wl,</option> prefix is necessary because despite the
|
||||
shared libraries</quote> issues caused by
|
||||
<application>libtool</application>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
With <option>-Wl,-z,pack-relative-relocs</option>, the linker
|
||||
generates a more compacted form of the relative relocation entries
|
||||
for PIEs and shared libraries. It reduces the size of the linked
|
||||
PIE or shared library, and speeds up the loading of the PIE or
|
||||
shared library.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <option>-Wl,</option> prefix is necessary because despite the
|
||||
variable is named <envar>LDFLAGS</envar>, its content is actually
|
||||
passed to <command>gcc</command> (or <command>g++</command>,
|
||||
<command>clang</command>, etc.) during the link stage, not directly
|
||||
passed to <command>ld</command>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Note that <option>-Wl,-O1</option> is completely unrelated to the
|
||||
compiler optimization flag <option>-O1</option>. Some packages are
|
||||
using <option>-Wl,-O1</option> and <option>-Wl,--as-needed</option>
|
||||
as the default in their building systems.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="hardening">
|
||||
|
Loading…
Reference in New Issue
Block a user