aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-08-02 05:10:29 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-08-02 05:10:48 -0700
commitdb99ecc08f5b66fbe9cb72e90352c7f77ec71a6e (patch)
tree3c6c4906c1e655f5adbb331e668923591fd647f9
parentb8f4abd342cc54bc2b90c796a2aae93e6c3bda6b (diff)
downloadgdb-db99ecc08f5b66fbe9cb72e90352c7f77ec71a6e.zip
gdb-db99ecc08f5b66fbe9cb72e90352c7f77ec71a6e.tar.gz
gdb-db99ecc08f5b66fbe9cb72e90352c7f77ec71a6e.tar.bz2
Check ELF section header only for ELF output
When placing an orphan input section, check ELF section header only for ELF output. PR ld/21884 * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Check ELF section header only for ELF output. * testsuite/ld-elf/pr21884.d: New test. * testsuite/ld-elf/pr21884.t: Likewise. * testsuite/ld-elf/pr21884a.s: Likewise. * testsuite/ld-elf/pr21884b.s: Likewise.
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/emultempl/elf32.em3
-rw-r--r--ld/testsuite/ld-elf/pr21884.d11
-rw-r--r--ld/testsuite/ld-elf/pr21884.t7
-rw-r--r--ld/testsuite/ld-elf/pr21884a.s5
-rw-r--r--ld/testsuite/ld-elf/pr21884b.s5
6 files changed, 40 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 14c6edd..3b9162d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,15 @@
2017-08-02 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/21884
+ * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Check
+ ELF section header only for ELF output.
+ * testsuite/ld-elf/pr21884.d: New test.
+ * testsuite/ld-elf/pr21884.t: Likewise.
+ * testsuite/ld-elf/pr21884a.s: Likewise.
+ * testsuite/ld-elf/pr21884b.s: Likewise.
+
+2017-08-02 H.J. Lu <hongjiu.lu@intel.com>
+
* emultempl/elf32.em (_place_orphan): Revert the last change.
2017-08-02 Max Filippov <jcmvbkbc@gmail.com>
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index d2551b6..75ded12 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2136,7 +2136,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
}
/* Look through the script to see where to place this section. */
- if (constraint == 0)
+ if (constraint == 0
+ && link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour)
for (os = lang_output_section_find (secname);
os != NULL;
os = next_matching_output_section_statement (os, 0))
diff --git a/ld/testsuite/ld-elf/pr21884.d b/ld/testsuite/ld-elf/pr21884.d
new file mode 100644
index 0000000..52cd2c1
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21884.d
@@ -0,0 +1,11 @@
+#source: pr21884a.s
+#source: pr21884b.s
+#ld: -T pr21884.t
+#objdump: -b binary -s
+#notarget: aarch64*-*-* arm*-*-* nds32*-*-*
+# Skip targets which can't change output format to binary.
+
+.*: file format binary
+
+Contents of section .data:
+#pass
diff --git a/ld/testsuite/ld-elf/pr21884.t b/ld/testsuite/ld-elf/pr21884.t
new file mode 100644
index 0000000..d483911
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21884.t
@@ -0,0 +1,7 @@
+OUTPUT_FORMAT("binary")
+
+ENTRY(_main);
+SECTIONS {
+ . = 0;
+ .setup : { *(.setup) }
+}
diff --git a/ld/testsuite/ld-elf/pr21884a.s b/ld/testsuite/ld-elf/pr21884a.s
new file mode 100644
index 0000000..a3361b2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21884a.s
@@ -0,0 +1,5 @@
+ .text
+ .globl _main
+ .type _main,%function
+_main:
+ .dc.a bar
diff --git a/ld/testsuite/ld-elf/pr21884b.s b/ld/testsuite/ld-elf/pr21884b.s
new file mode 100644
index 0000000..e533837
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr21884b.s
@@ -0,0 +1,5 @@
+ .text
+ .globl bar
+ .type bar,%function
+bar:
+ .byte 0