aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2018-03-06 12:01:04 -0800
committerJim Wilson <jimw@sifive.com>2018-03-06 12:01:50 -0800
commit770aa8a3d3da978a35520af5f205ab2d8a5371a0 (patch)
treecad4f7d1d9c153222489e313462a400e06e4b0d7 /ld/emultempl
parent9add17f218409f357d5ed8b831c777ac93f41ec4 (diff)
downloadgdb-770aa8a3d3da978a35520af5f205ab2d8a5371a0.zip
gdb-770aa8a3d3da978a35520af5f205ab2d8a5371a0.tar.gz
gdb-770aa8a3d3da978a35520af5f205ab2d8a5371a0.tar.bz2
RISC-V: Disallow output format changes.
PR 22920 * emultempl/riscvelf.em (riscv_create_output_section_statements): New. (LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): New. * testsuite/ld-elf/pr21884.d (#notarget): Add riscv*-*-*. * testsuite/ld-unique/pr21529.d (#notarget): Likewise. * testsuite/ld-srec/srec.exp (run_srec_test): For riscv*-*-* target, call setup_xfail.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/riscvelf.em20
1 files changed, 20 insertions, 0 deletions
diff --git a/ld/emultempl/riscvelf.em b/ld/emultempl/riscvelf.em
index a284c63..eaaf4c5 100644
--- a/ld/emultempl/riscvelf.em
+++ b/ld/emultempl/riscvelf.em
@@ -62,7 +62,27 @@ gld${EMULATION_NAME}_after_allocation (void)
gld${EMULATION_NAME}_map_segments (need_layout);
}
+/* This is a convenient point to tell BFD about target specific flags.
+ After the output has been created, but before inputs are read. */
+
+static void
+riscv_create_output_section_statements (void)
+{
+ /* See PR 22920 for an example of why this is necessary. */
+ if (strstr (bfd_get_target (link_info.output_bfd), "riscv") == NULL)
+ {
+ /* The RISC-V backend needs special fields in the output hash structure.
+ These will only be created if the output format is a RISC-V format,
+ hence we do not support linking and changing output formats at the
+ same time. Use a link followed by objcopy to change output formats. */
+ einfo (_("%F%P: error: cannot change output format"
+ " whilst linking %s binaries\n"), "RISC-V");
+ return;
+ }
+}
+
EOF
LDEMUL_BEFORE_ALLOCATION=riscv_elf_before_allocation
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
+LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=riscv_create_output_section_statements