aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-09-30 05:32:12 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-09-30 05:37:49 -0700
commit9865bd0da6e59c3a1c55605b5a6a9283ed4d542c (patch)
tree00cfc33b4e09eef4d71758d73f7fc0555ac04d73 /bfd
parent2ec6d9e621ca468d56ac92df8ec2ec510d21f6da (diff)
downloadgdb-9865bd0da6e59c3a1c55605b5a6a9283ed4d542c.zip
gdb-9865bd0da6e59c3a1c55605b5a6a9283ed4d542c.tar.gz
gdb-9865bd0da6e59c3a1c55605b5a6a9283ed4d542c.tar.bz2
Also check e_machine when merging sections
When we check consistency for merge ELF sections, we should not only check EI_CLASS, but also compatible e_machine. bfd/ PR ld/19013 * elflink.c (_bfd_elf_merge_sections): Only merge input bfds that have the compatible ELF machine code with the output bfd. ld/testsuite/ PR ld/19013 * ld-x86-64/pr19013-nacl.d: New file. * ld-x86-64/pr19013-x32.d: Likewise. * ld-x86-64/pr19013.d: Likewise. * ld-x86-64/pr19013.s: Likewise. * ld-x86-64/x86-64.exp: Run PR ld/19013 tests.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c12
2 files changed, 16 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f4ca2ec..a218d44 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/19013
+ * elflink.c (_bfd_elf_merge_sections): Only merge input bfds
+ that have the compatible ELF machine code with the output bfd.
+
2015-09-30 Alan Modra <amodra@gmail.com>
PR ld/19013
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 90af6cf..70c231b 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6818,15 +6818,23 @@ _bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
{
bfd *ibfd;
asection *sec;
+ const struct elf_backend_data *bed;
if (!is_elf_hash_table (info->hash))
return FALSE;
+ bed = get_elf_backend_data (obfd);
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
if ((ibfd->flags & DYNAMIC) == 0
&& bfd_get_flavour (ibfd) == bfd_target_elf_flavour
- && (elf_elfheader (ibfd)->e_ident[EI_CLASS]
- == get_elf_backend_data (obfd)->s->elfclass))
+ && (elf_elfheader (ibfd)->e_ident[EI_CLASS] == bed->s->elfclass)
+ && (bed->elf_machine_code == elf_elfheader (ibfd)->e_machine
+ || (bed->elf_machine_alt1 != 0
+ && (bed->elf_machine_alt1
+ == elf_elfheader (ibfd)->e_machine))
+ || (bed->elf_machine_alt2 != 0
+ && (bed->elf_machine_alt2
+ == elf_elfheader (ibfd)->e_machine))))
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
if ((sec->flags & SEC_MERGE) != 0
&& !bfd_is_abs_section (sec->output_section))