]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add --no-dynamic-linker option to ld, for static PIE use
authorRich Felker <dalias@libc.org>
Sun, 20 Sep 2015 02:50:19 +0000 (12:20 +0930)
committerAlan Modra <amodra@gmail.com>
Sun, 20 Sep 2015 06:22:27 +0000 (15:52 +0930)
Inhibits output of .interp section in ELF executables.

include/
* bfdlink.h (struct bfd_link_info): Add "nointerp" field.
bfd/
* elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create
.interp when info->nointerp.
(bfd_elf_size_dynamic_sections): Adjust assert.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp
when info->nointerp.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
* elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise.
* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
ld/
* ld.texinfo (--no-dynamic-linker): Document.
* ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
* lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.

43 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-cr16.c
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-i386.c
bfd/elf32-lm32.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-metag.c
bfd/elf32-nds32.c
bfd/elf32-nios2.c
bfd/elf32-or1k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-score.c
bfd/elf32-score7.c
bfd/elf32-sh.c
bfd/elf32-tic6x.c
bfd/elf32-tilepro.c
bfd/elf32-vax.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfnn-aarch64.c
bfd/elfnn-ia64.c
bfd/elfxx-mips.c
bfd/elfxx-sparc.c
bfd/elfxx-tilegx.c
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/ld.texinfo
ld/ldlex.h
ld/lexsup.c

index 70d99523e58d289a860b1fecbf1e0a40c278a448..37ba69fa3aa2ad25e8b2b840ec74ae4f56b56574 100644 (file)
@@ -1,3 +1,45 @@
+2015-09-20  Rich Felker  <dalias@libc.org>
+
+       * elflink.c (_bfd_elf_link_create_dynamic_sections): Don't create
+       .interp when info->nointerp.
+       (bfd_elf_size_dynamic_sections): Adjust assert.
+       * elf32-arm.c (elf32_arm_size_dynamic_sections): Don't size .interp
+       when info->nointerp.
+       * elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
+       * elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
+       * elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
+       * elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
+       * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
+       * elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
+       * elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
+       * elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
+       * elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
+       * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
+       * elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
+       * elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
+       * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
+       * elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
+       * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
+       * elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
+       * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
+       * elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
+       * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
+       * elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Likewise.
+       * elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
+       * elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
+       * elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
+       * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
+       * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
+       * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
+       * elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
+       * elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise.
+       * elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
+       * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
+       * elfnn-ia64.c (elfNN_ia64_size_dynamic_sections): Likewise.
+       * elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
+       * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
+       * elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
+
 2015-09-18  Doug Evans  <xdje42@gmail.com>
 
        * targets.c (enum bfd_flavour): Add comment.
index b65ae3995faafb7d2676d2665acb1c15ce60eb25..bd41fd0ec918e18d0dc2867fe7889bdab421c017 100644 (file)
@@ -13786,7 +13786,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 152134ee7b9b445d96818fcab2350ffd11795897..0d4d9cf6630ec09a0b88bf42d485740dc6b60248 100644 (file)
@@ -4255,7 +4255,7 @@ elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd,
   if (htab->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 5d8ffbcaa60025226f344e035de5520a1bada7e9..497630e987fca60e9e2658fb3f906dbd61337901 100644 (file)
@@ -2464,7 +2464,7 @@ _bfd_cr16_elf_size_dynamic_sections (bfd * output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
         {
 #if 0
           s = bfd_get_linker_section (dynobj, ".interp");
index 303117393fcc0945d3045ae685ddaba5f1e26865..5b40524707377cf2084d5799dbeb56f8ce3fff84 100644 (file)
@@ -3764,7 +3764,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index fa12528b3d11ab9ed7a4d5d894f8b9c1a5e783a9..1dd2e8cac5699ea4d2fbc84ac3980b40b9487b64 100644 (file)
@@ -5442,7 +5442,7 @@ elf32_frvfdpic_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 8f0f4d0f08935ad52c18efb6c3c29a6ee8944a66..ad40914c484a64ae7c8796cf18df4a5c1195d19f 100644 (file)
@@ -2215,7 +2215,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->etab.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          sec = bfd_get_linker_section (dynobj, ".interp");
          if (sec == NULL)
index 7fba4d1f4171dd1fe070f41405d24638e7edffa7..458f69495d066f901259fd8c8b47035adc18f1c5 100644 (file)
@@ -594,7 +594,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 85885f71e17608537d9ccf053ba1adc2d90983cb..93904503e4fd22bf271cfabc3ce3903789c97e5f 100644 (file)
@@ -2876,7 +2876,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index 23f6e5ea756c64ee5a4cbb4cc9fc78ac2a08f56d..0805e3c9a5f48feaa40bbda1af8a91ecbf82171b 100644 (file)
@@ -2141,7 +2141,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 155d07904f30c4a8ac0455ac3677430bf42b1c3f..a2e3c7ce64cb5079104cf64f613a0b130d5beb51 100644 (file)
@@ -2170,7 +2170,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index f807e03741acfbd194c701ca4dc2fa7e3da7740a..03940fde24f27e37d64b544dd64b790d1946d095 100644 (file)
@@ -3257,7 +3257,7 @@ elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 0fcafc4d9c3c26d537669e47fba61e7fae174097..596cf761a71cc4bdbdfab9fec2e38792453e239c 100644 (file)
@@ -2848,7 +2848,7 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->etab.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index e59110053a78b73449d5c3b68dac0733b5e99e72..28d4df8b933e0e04de480a3443b10a625f7aacc3 100644 (file)
@@ -3980,7 +3980,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (!bfd_link_pic (info))
+      if (!bfd_link_pic (info) && !info->nointerp)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 91897265c830e6aaf0963d65709d9a29375c280a..6b29d8b97f1bc34585c084500c592ee4f9b2b4e7 100644 (file)
@@ -5849,7 +5849,7 @@ nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index d4f92b78fdfe757ca805fc27cf7df441ba6c12c4..a1eba0956e459653a4867d60d9a262c9cd51a60e 100644 (file)
@@ -2447,7 +2447,7 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
         {
           s = bfd_get_section_by_name (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
index 3f708cb171369a8962c42a11a11c06c2e03a25d8..708076d65e8d74515d992c033d92d7cf6764610a 100644 (file)
@@ -6191,7 +6191,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (htab->elf.dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 96c1531e7df0c291c0233c009f8f29861389a998..2143ee1773d9683e6d8dd9bb4b139a6a1dbe30e7 100644 (file)
@@ -2039,7 +2039,7 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index a976a1539f6b12df23a845246a22f61a305440d2..ce9c3777559620ee7a99b9ee978544a1512587fd 100644 (file)
@@ -3269,7 +3269,7 @@ s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (!bfd_link_pic (info))
+      if (!bfd_link_pic (info) && !info->nointerp)
         {
           s = bfd_get_linker_section (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
index 1af034eac0712d371bb1291afff40869dbea6ea5..b0e75bb9cae7f250652c597584a9459fdd4d6e3c 100644 (file)
@@ -3078,7 +3078,7 @@ s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *i
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (!bfd_link_pic (info))
+      if (!bfd_link_pic (info) && !info->nointerp)
         {
           s = bfd_get_linker_section (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
index fdeadd016d59f78db19bacd2d5dff0d07308cd4a..9fa363615ddbb7629628b7fe500df93d0a27a8b0 100644 (file)
@@ -3349,7 +3349,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index b6640eabc88be7c7903a195d71202ae528f5062d..380ab8dd2bf742dbea8e651cd6711997a9ded47a 100644 (file)
@@ -3300,7 +3300,7 @@ elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index cb3f896281d5a7cc7a616ec2ff952c9aa34d63eb..d55be2d3ceef045cb7e4df16b2459775b02ac013 100644 (file)
@@ -2463,7 +2463,7 @@ tilepro_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 6089e8c8f33c82b311684f90ff40af098e5d67a2..893ea8d5fb40b9953d757e0342992f1dcc341a07 100644 (file)
@@ -1124,7 +1124,7 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index ada3e5a3cee713ea9dce0154d80387705b06d613..c2aef2578eb056da0d75471b96dd9aa55f179bc3 100644 (file)
@@ -1641,7 +1641,7 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                  && htab->sgotloc != NULL);
 
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index 35c1ec6189148c254b2c86cd501d5f27cac7f558..e46f27fdc54b6b9e53429dae04c24de795b13718 100644 (file)
@@ -2890,7 +2890,7 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 6f40b88481e08cd43cf488f64dbfa04538485cd5..3b628b466f56963bad685a27ca4c43469d3d0de3 100644 (file)
@@ -1558,7 +1558,7 @@ elf64_hppa_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          sec = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (sec != NULL);
index 5ad5f48c0e2c90df678335b6f176db9c8cadd0de..e5344df446b556b1a54e01c97e726235bab7c07a 100644 (file)
@@ -9815,7 +9815,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd,
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index 0264236f2a5ae7a075bc66b77323858f5db03b3e..1c3769976e65b20b84bf1bf454f66ba0057de32a 100644 (file)
@@ -1989,7 +1989,7 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index e4608953dff9576fa110328cbfc274959be61d8e..d920598008fa3b9eea44280c3920f28466b0edd3 100644 (file)
@@ -3404,7 +3404,7 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 2230c15bc1d48f653829acc88775dfe609f9cf4f..cbb8cfb348431791a8fed0632832736cb4dd37a9 100644 (file)
@@ -3227,7 +3227,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index 4e52d7bf090c801c90462dcc48d734e504513881..aec96e5d6177eb9d46763c74aeaa4acaea5352ac 100644 (file)
@@ -246,7 +246,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   /* A dynamically linked executable has a .interp section, but a
      shared library does not.  */
-  if (bfd_link_executable (info))
+  if (bfd_link_executable (info) && !info->nointerp)
     {
       s = bfd_make_section_anyway_with_flags (abfd, ".interp",
                                              flags | SEC_READONLY);
@@ -5763,7 +5763,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
       bfd_boolean all_defined;
 
       *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
-      BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info));
+      BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info) || info->nointerp);
 
       if (soname != NULL)
        {
index c9780fcf11f318b3e1c80b3adad5c2b0759f2ea8..24ef79f56868f0d52d31dbd5ce3c7842dd42b335 100644 (file)
@@ -7982,7 +7982,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (htab->root.dynamic_sections_created)
     {
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          if (s == NULL)
index c45fa2818af3b6fd971d90fd54a373bd3b7866c3..3b304d53c8590fc4a71e121c203c9341b0a19cda 100644 (file)
@@ -2992,7 +2992,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   /* Set the contents of the .interp section to the interpreter.  */
   if (ia64_info->root.dynamic_sections_created
-      && bfd_link_executable (info))
+      && bfd_link_executable (info) && !info->nointerp)
     {
       sec = bfd_get_linker_section (dynobj, ".interp");
       BFD_ASSERT (sec != NULL);
index 5ece52d0122ce4ad39e9124a2ec6ca679c1839fe..4689b21463302a3c452846c2835686bec66e8d11 100644 (file)
@@ -9579,7 +9579,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 9bb71a99335199fcc8f423f7aa93648583dedcfe..db0d4f180467cf885eecafd78fcb01d052362da0 100644 (file)
@@ -2559,7 +2559,7 @@ _bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 59a2f7ef2882790c4e7fc4ce54c791e3fe66e17b..6f7485a02727f47ad067caa3766af370dbeeca1f 100644 (file)
@@ -2724,7 +2724,7 @@ tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (bfd_link_executable (info))
+      if (bfd_link_executable (info) && !info->nointerp)
        {
          s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
index 4fedda7ad0f4a2bf8ece32e7c033b9e9d999be1d..8b9f921f292c5440296ff18970002f249fcbec9f 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-20  Rich Felker  <dalias@libc.org>
+
+       * bfdlink.h (struct bfd_link_info): Add "nointerp" field.
+
 2015-08-23  Alan Modra  <amodra@gmail.com>
 
        * bfdlink.h (enum output_type): Reorder enum.
index 43bcc6a90406829308ca102435eb1bc047303cfb..2ffb3d1ab56e396564aa042e80bf71495d910cf3 100644 (file)
@@ -431,6 +431,9 @@ struct bfd_link_info
   /* TRUE if BND prefix in PLT entries is always generated.  */
   unsigned int bndplt: 1;
 
+  /* TRUE if generation of .interp/PT_INTERP should be suppressed.  */
+  unsigned int nointerp: 1;
+
   /* Char that may appear as the first char of a symbol, but should be
      skipped (like symbol_leading_char) when looking up symbols in
      wrap_hash.  Used by PowerPC Linux for 'dot' symbols.  */
index e73abeb023aa29460ee16f8a4887bc244e22063c..e1e06b83dc6dbe0952fe1f7234cadeb0e0194d00 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-20  Rich Felker  <dalias@libc.org>
+
+       * ld.texinfo (--no-dynamic-linker): Document.
+       * ldlex.h (enum option_values): Add OPTION_NO_DYNAMIC_LINKER.
+       * lexsup.c (ld_options, parse_args): Handle --no-dynamic-linker.
+
 2015-09-18  Alan Modra  <amodra@gmail.com>
 
        * ld.texinfo: Document PowerPC64 --{no-,}save-restore-funcs.
index c5d39d5e2c14512555952f6fc05cfb199c5ba079..6b7fac82fd2a7032323540e6b59c1fc900b4a6eb 100644 (file)
@@ -1455,6 +1455,13 @@ generating dynamically linked ELF executables.  The default dynamic
 linker is normally correct; don't use this unless you know what you are
 doing.
 
+@kindex --no-dynamic-linker
+@item --no-dynamic-linker
+When producing an executable file, omit the request for a dynamic
+linker to be used at load-time.  This is only meaningful for ELF
+executables that contain dynamic relocations, and usually requires
+entry point code that is capable of processing these relocations.
+
 @kindex --fatal-warnings
 @kindex --no-fatal-warnings
 @item --fatal-warnings
index 5629ef19f18ac1f0a793955b60ab49bd5c16830d..6f11e7bd21782367ad8347d5f3754aa09192b5ed 100644 (file)
@@ -33,6 +33,7 @@ enum option_values
   OPTION_DEFSYM,
   OPTION_DEMANGLE,
   OPTION_DYNAMIC_LINKER,
+  OPTION_NO_DYNAMIC_LINKER,
   OPTION_SYSROOT,
   OPTION_EB,
   OPTION_EL,
index 5dc56dc148e0c38a0cfba2aff2ec25a8b0ff27e2..fdd39a73dc2d228c355bdc2ef8c0129c528f1291 100644 (file)
@@ -138,6 +138,9 @@ static const struct ld_option ld_options[] =
   { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
     'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"),
     TWO_DASHES },
+  { {"no-dynamic-linker", no_argument, NULL, OPTION_NO_DYNAMIC_LINKER},
+    '\0', NULL, N_("Produce an executable with no program interpreter header"),
+    TWO_DASHES },
   { {"library", required_argument, NULL, 'l'},
     'l', N_("LIBNAME"), N_("Search for library LIBNAME"), TWO_DASHES },
   { {"library-path", required_argument, NULL, 'L'},
@@ -761,6 +764,10 @@ parse_args (unsigned argc, char **argv)
        case 'I':               /* Used on Solaris.  */
        case OPTION_DYNAMIC_LINKER:
          command_line.interpreter = optarg;
+         link_info.nointerp = 0;
+         break;
+       case OPTION_NO_DYNAMIC_LINKER:
+         link_info.nointerp = 1;
          break;
        case OPTION_SYSROOT:
          /* Already handled in ldmain.c.  */