Add more targets to the list of architectures not supporting format changing during...
authorNick Clifton <nickc@redhat.com>
Thu, 3 Aug 2017 10:59:32 +0000 (11:59 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 3 Aug 2017 10:59:32 +0000 (11:59 +0100)
PR ld/21884
* testsuite/ld-elf/pr21884.d: Add AVR, HPPA, IA64, M68HC1x and
SCORE to list of targets not supporting file format changes during
linking.
* testsuite/ld-unique/pr21529.d: Likewise.
* emultempl/avrelf.em (_before_allocation): Skip for non-ELF
output formats.
(avr_elf_create_output_section_statements): Fail if the output
format is not ELF.
(avr_finish): Do not access the ELF header in non-ELF format
output bfds.
* emultempl/m68hc1xelf.em (_before_allocation): Skip for non-ELF
output formats.
(m68hc11elf_create_output_section_statements): Fail if the putput
format is not ELF.
(m68hc11elf_after_allocation): Skip for non-ELF output formats.

ld/ChangeLog
ld/emultempl/avrelf.em
ld/emultempl/m68hc1xelf.em
ld/testsuite/ld-elf/pr21884.d
ld/testsuite/ld-unique/pr21529.d

index efae36c3025f1f56bf9b73c5b9ea4731215636fe..99c14554387f27838b2a3ff31365a7482c62391e 100644 (file)
@@ -1,3 +1,22 @@
+2017-08-03  Nick Clifton  <nickc@redhat.com>
+
+       PR ld/21884
+       * testsuite/ld-elf/pr21884.d: Add AVR, HPPA, IA64, M68HC1x and
+       SCORE to list of targets not supporting file format changes during
+       linking.
+       * testsuite/ld-unique/pr21529.d: Likewise.
+       * emultempl/avrelf.em (_before_allocation): Skip for non-ELF
+       output formats.
+       (avr_elf_create_output_section_statements): Fail if the output
+       format is not ELF.
+       (avr_finish): Do not access the ELF header in non-ELF format
+       output bfds.
+       * emultempl/m68hc1xelf.em (_before_allocation): Skip for non-ELF
+       output formats.
+       (m68hc11elf_create_output_section_statements): Fail if the putput
+       format is not ELF.
+       (m68hc11elf_after_allocation): Skip for non-ELF output formats.
+
 2017-08-03  Alan Modra  <amodra@gmail.com>
 
        PR ld/21884
index 20721244a9e98fe83d6a269d8a8fb442bcbdc132..acb478fc54b2693e64550e1a69b16a9d04bb80b5 100644 (file)
@@ -71,6 +71,12 @@ avr_elf_${EMULATION_NAME}_before_allocation (void)
 
   gld${EMULATION_NAME}_before_allocation ();
 
+  if (bfd_get_flavour (link_info.output_bfd) != bfd_target_elf_flavour)
+    {
+      avr_no_stubs = TRUE;
+      return;
+    }
+
   /* We only need stubs for avr6, avrxmega6, and avrxmega7. */
   if (strcmp ("${EMULATION_NAME}","avr6")
       && strcmp ("${EMULATION_NAME}","avrxmega6")
@@ -108,6 +114,12 @@ avr_elf_create_output_section_statements (void)
 {
   flagword flags;
 
+  if (bfd_get_flavour (link_info.output_bfd) != bfd_target_elf_flavour)
+    {
+      einfo ("%X%P: changing output format whilst linking is not supported\n");
+      return;
+    }
+
   stub_file = lang_add_input_file ("linker stubs",
                                    lang_input_file_is_fake_enum,
                                    NULL);
@@ -204,10 +216,14 @@ avr_finish (void)
     }
 
   abfd = link_info.output_bfd;
-  if (avr_link_relax)
-    elf_elfheader (abfd)->e_flags |= EF_AVR_LINKRELAX_PREPARED;
-  else
-    elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED;
+
+  if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
+    {
+      if (avr_link_relax)
+       elf_elfheader (abfd)->e_flags |= EF_AVR_LINKRELAX_PREPARED;
+      else
+       elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED;
+    }
 
   finish_default ();
 }
index bfe88d604fd7af2e39359af39d7967328f5d60d6..f7337da2066b9df66847b68679ddeeb81d1d7b78 100644 (file)
@@ -66,6 +66,9 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation (void)
 
   gld${EMULATION_NAME}_before_allocation ();
 
+  if (bfd_get_flavour (link_info.output_bfd) != bfd_target_elf_flavour)
+    return;
+
   /* If generating a relocatable output file, then we don't
      have to generate the trampolines.  */
   if (bfd_link_relocatable (&link_info))
@@ -141,6 +144,12 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation (void)
 static void
 m68hc11elf_create_output_section_statements (void)
 {
+  if (bfd_get_flavour (link_info.output_bfd) != bfd_target_elf_flavour)
+    {
+      einfo ("%X%P: changing output format whilst linking is not supported\n");
+      return;
+    }
+
   stub_file = lang_add_input_file ("linker stubs",
                                   lang_input_file_is_fake_enum,
                                   NULL);
@@ -286,22 +295,25 @@ m68hc11elf_add_stub_section (const char *stub_sec_name,
 static void
 m68hc11elf_after_allocation (void)
 {
-  /* Now build the linker stubs.  */
-  if (stub_file->the_bfd->sections != NULL)
+  if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
     {
-      /* Call again the trampoline analyzer to initialize the trampoline
-        stubs with the correct symbol addresses.  Since there could have
-        been relaxation, the symbol addresses that were found during
-        first call may no longer be correct.  */
-      if (!elf32_m68hc11_size_stubs (link_info.output_bfd,
-                                    stub_file->the_bfd,
-                                    &link_info, 0))
+      /* Now build the linker stubs.  */
+      if (stub_file->the_bfd->sections != NULL)
        {
-         einfo ("%X%P: can not size stub section: %E\n");
-         return;
+         /* Call again the trampoline analyzer to initialize the trampoline
+            stubs with the correct symbol addresses.  Since there could have
+            been relaxation, the symbol addresses that were found during
+            first call may no longer be correct.  */
+         if (!elf32_m68hc11_size_stubs (link_info.output_bfd,
+                                        stub_file->the_bfd,
+                                        &link_info, 0))
+           {
+             einfo ("%X%P: can not size stub section: %E\n");
+             return;
+           }
+         if (!elf32_m68hc11_build_stubs (link_info.output_bfd, &link_info))
+           einfo ("%X%P: can not build stubs: %E\n");
        }
-      if (!elf32_m68hc11_build_stubs (link_info.output_bfd, &link_info))
-       einfo ("%X%P: can not build stubs: %E\n");
     }
 
   gld${EMULATION_NAME}_after_allocation ();
index 52cd2c19846febe8062644c936cc7297f62f7e04..0de7b83b1877688a134adc7a3215b0fd43bd4e3c 100644 (file)
@@ -2,7 +2,7 @@
 #source: pr21884b.s
 #ld: -T pr21884.t
 #objdump: -b binary -s
-#notarget: aarch64*-*-* arm*-*-* nds32*-*-*
+#notarget: aarch64*-*-* arm*-*-* avr-*-* hppa-*-* ia64-*-* m68hc1*-*-* nds32*-*-* score-*-*
 # Skip targets which can't change output format to binary.
 
 .*:     file format binary
index bc4763dfeb1fae59b593e17d45563433c0b70609..5d3436badb654b5e4e60f686667013cbd6630d1b 100644 (file)
@@ -1,5 +1,6 @@
 #ld: --oformat binary -T pr21529.ld -e main
 #objdump: -s -b binary
-#xfail: aarch64*-*-* arm*-*-* hppa-*-* ia64-*-* nds32*-*-* score-*-*
+#notarget: aarch64*-*-* arm*-*-* avr-*-* hppa-*-* ia64-*-* m68hc1*-*-* nds32*-*-* score-*-*
+# Skip targets which can't change output format to binary.
 
 #pass