aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/emultempl/mipself.em15
-rw-r--r--ld/testsuite/ld-mips-elf/binary.d8
-rw-r--r--ld/testsuite/ld-mips-elf/binary.ld5
-rw-r--r--ld/testsuite/ld-mips-elf/binary.s2
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp3
6 files changed, 36 insertions, 6 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index cb72710ed8..2151602659 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-07-07 Maciej W. Rozycki <macro@imgtec.com>
+
+ * emultempl/mipself.em (mips_before_allocation): Avoid ELF
+ processing if not MIPS ELF.
+ * testsuite/ld-mips-elf/binary.d: New test.
+ * testsuite/ld-mips-elf/binary.ld: New test linker script.
+ * testsuite/ld-mips-elf/binary.s: New test source.
+ * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
+
2017-07-07 Alan Modra <amodra@gmail.com>
* testsuite/ld-powerpc/ppc476-shared.lnk: Align .bss.
diff --git a/ld/emultempl/mipself.em b/ld/emultempl/mipself.em
index cd68707ec3..d541fefc93 100644
--- a/ld/emultempl/mipself.em
+++ b/ld/emultempl/mipself.em
@@ -214,13 +214,16 @@ mips_create_output_section_statements (void)
static void
mips_before_allocation (void)
{
- flagword flags;
+ if (is_mips_elf (link_info.output_bfd))
+ {
+ flagword flags;
- flags = elf_elfheader (link_info.output_bfd)->e_flags;
- if (!bfd_link_pic (&link_info)
- && !link_info.nocopyreloc
- && (flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) == EF_MIPS_CPIC)
- _bfd_mips_elf_use_plts_and_copy_relocs (&link_info);
+ flags = elf_elfheader (link_info.output_bfd)->e_flags;
+ if (!bfd_link_pic (&link_info)
+ && !link_info.nocopyreloc
+ && (flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) == EF_MIPS_CPIC)
+ _bfd_mips_elf_use_plts_and_copy_relocs (&link_info);
+ }
gld${EMULATION_NAME}_before_allocation ();
}
diff --git a/ld/testsuite/ld-mips-elf/binary.d b/ld/testsuite/ld-mips-elf/binary.d
new file mode 100644
index 0000000000..eb88c1c7ba
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/binary.d
@@ -0,0 +1,8 @@
+#objdump: -b binary -s
+#name: MIPS link ELF into binary output format
+#ld: -r --oformat=binary -T binary.ld
+
+.*: +file format binary
+
+Contents of section \.data:
+ 0000 61626364 65666768 696a6b6c 6d6e6f70 abcdefghijklmnop
diff --git a/ld/testsuite/ld-mips-elf/binary.ld b/ld/testsuite/ld-mips-elf/binary.ld
new file mode 100644
index 0000000000..037ae69ebd
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/binary.ld
@@ -0,0 +1,5 @@
+SECTIONS
+{
+ .data : { *(.data) }
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/ld-mips-elf/binary.s b/ld/testsuite/ld-mips-elf/binary.s
new file mode 100644
index 0000000000..fbc0244fcd
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/binary.s
@@ -0,0 +1,2 @@
+ .data
+ .ascii "abcdefghijklmnop"
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 4360b83e2b..4008da08a5 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -1213,3 +1213,6 @@ run_ld_link_tests [list \
"relax-offset-umips"]]
rename prune_warnings ""
rename mips_old_prune_warnings prune_warnings
+
+# Verify that we can link ELF input into the `binary' output format.
+run_dump_test "binary"