[PATCH,ARM] Suppress the dynamic linker commands for statically linked programs

Ben Cheng bccheng@google.com
Fri Sep 14 20:34:00 GMT 2012


Hi,

Recently we found out that the .interp section starts to show up in
ARM executables compiled with "-shared -static" and the gold linker
from binutils 2.22. We tracked down the origin of the dynamic linker
commands and they are always explicitly specified in
config/arm/linux-elf.h. We tested the following simple patch to
suppress the dynamic linker options for statically linked programs on
Android's AOSP tree. Everything builds fine and the unneeded .interp
section is gone.

Thanks,
-Ben

==

gcc/ChangeLog
2012-09-14 Ben Cheng <bccheng@google.com>
    * config/arm/linux-elf.h: Suppress the dynamic linker commands for
    statically linked programs.

Index: config/arm/linux-elf.h
===================================================================
--- config/arm/linux-elf.h	(revision 191198)
+++ config/arm/linux-elf.h	(working copy)
@@ -65,8 +65,9 @@
    %{static:-Bstatic} \
    %{shared:-shared} \
    %{symbolic:-Bsymbolic} \
-   %{rdynamic:-export-dynamic} \
-   -dynamic-linker " GNU_USER_DYNAMIC_LINKER " \
+   %{!static: \
+     %{rdynamic:-export-dynamic} \
+     -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \
    -X \
    %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
    SUBTARGET_EXTRA_LINK_SPEC



More information about the Gcc-patches mailing list