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

login
register
mail settings
Submitter Ben Cheng
Date Sept. 14, 2012, 8:34 p.m.
Message ID <CAPk6zkDPWzr7evw72upaHS=txQ=8S8fJei1oxxPW0qXfpZNfoA@mail.gmail.com>
Download mbox | patch
Permalink /patch/184037/
State New
Headers show

Comments

Ben Cheng - Sept. 14, 2012, 8:34 p.m.
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.
Richard Earnshaw - Sept. 17, 2012, 10:13 a.m.
On 14/09/12 21:34, Ben Cheng wrote:
> 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
> 

OK.

R.

Patch

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