aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-08-03 11:59:32 +0100
committerNick Clifton <nickc@redhat.com>2017-08-03 11:59:32 +0100
commitfd9770d81fba7ad860e8bcfbc13c77f21041f1f3 (patch)
tree9986b3b1e364d8f2e12a363206afe13298768c10
parent2e9246e077cdbbff0a56a810c5750cc895382ba3 (diff)
downloadgdb-fd9770d81fba7ad860e8bcfbc13c77f21041f1f3.zip
gdb-fd9770d81fba7ad860e8bcfbc13c77f21041f1f3.tar.gz
gdb-fd9770d81fba7ad860e8bcfbc13c77f21041f1f3.tar.bz2
Add more targets to the list of architectures not supporting format changing during linking. Fix seg-faults triggered when this is attempted.
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.
-rw-r--r--ld/ChangeLog19
-rw-r--r--ld/emultempl/avrelf.em24
-rw-r--r--ld/emultempl/m68hc1xelf.em38
-rw-r--r--ld/testsuite/ld-elf/pr21884.d2
-rw-r--r--ld/testsuite/ld-unique/pr21529.d3
5 files changed, 67 insertions, 19 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index efae36c..99c1455 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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
diff --git a/ld/emultempl/avrelf.em b/ld/emultempl/avrelf.em
index 2072124..acb478f 100644
--- a/ld/emultempl/avrelf.em
+++ b/ld/emultempl/avrelf.em
@@ -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 ();
}
diff --git a/ld/emultempl/m68hc1xelf.em b/ld/emultempl/m68hc1xelf.em
index bfe88d6..f7337da 100644
--- a/ld/emultempl/m68hc1xelf.em
+++ b/ld/emultempl/m68hc1xelf.em
@@ -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 ();
diff --git a/ld/testsuite/ld-elf/pr21884.d b/ld/testsuite/ld-elf/pr21884.d
index 52cd2c1..0de7b83 100644
--- a/ld/testsuite/ld-elf/pr21884.d
+++ b/ld/testsuite/ld-elf/pr21884.d
@@ -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
diff --git a/ld/testsuite/ld-unique/pr21529.d b/ld/testsuite/ld-unique/pr21529.d
index bc4763d..5d3436b 100644
--- a/ld/testsuite/ld-unique/pr21529.d
+++ b/ld/testsuite/ld-unique/pr21529.d
@@ -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