aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-09-30 11:45:32 +0930
committerAlan Modra <amodra@gmail.com>2015-09-30 16:06:09 +0930
commit630993ec93fed0f2da1c4511b865cc69f5f0e835 (patch)
tree92955153c33b0544e02844994f57ab702a121e9b
parenta39d2e820dd949f934411dbc724d9afb5f4ace03 (diff)
downloadgdb-630993ec93fed0f2da1c4511b865cc69f5f0e835.zip
gdb-630993ec93fed0f2da1c4511b865cc69f5f0e835.tar.gz
gdb-630993ec93fed0f2da1c4511b865cc69f5f0e835.tar.bz2
Consistency check for merge sections
We can't allow sections to be merged and sized by the ELF linker backend and then later be output by the generic linker backend. The generic linker backend doesn't understand merge sections. PR ld/19013 * elflink.c (_bfd_elf_merge_sections): Only merge input bfds that will be handled by elf_link_input_bfd. Rename abfd param to obfd.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c11
2 files changed, 13 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 16dd166..f4ca2ec 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-30 Alan Modra <amodra@gmail.com>
+
+ PR ld/19013
+ * elflink.c (_bfd_elf_merge_sections): Only merge input bfds that
+ will be handled by elf_link_input_bfd. Rename abfd param to obfd.
+
2015-09-30 Rich Felker <dalias@libc.org>
* config.bfd (targ_selvecs): Add fdpic and misc targets
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ff7ae73..90af6cf 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6814,7 +6814,7 @@ merge_sections_remove_hook (bfd *abfd ATTRIBUTE_UNUSED,
/* Finish SHF_MERGE section merging. */
bfd_boolean
-_bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
+_bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info)
{
bfd *ibfd;
asection *sec;
@@ -6823,7 +6823,10 @@ _bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
return FALSE;
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
- if ((ibfd->flags & DYNAMIC) == 0)
+ 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))
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
if ((sec->flags & SEC_MERGE) != 0
&& !bfd_is_abs_section (sec->output_section))
@@ -6831,7 +6834,7 @@ _bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
struct bfd_elf_section_data *secdata;
secdata = elf_section_data (sec);
- if (! _bfd_add_merge_section (abfd,
+ if (! _bfd_add_merge_section (obfd,
&elf_hash_table (info)->merge_info,
sec, &secdata->sec_info))
return FALSE;
@@ -6840,7 +6843,7 @@ _bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info)
}
if (elf_hash_table (info)->merge_info != NULL)
- _bfd_merge_sections (abfd, info, elf_hash_table (info)->merge_info,
+ _bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info,
merge_sections_remove_hook);
return TRUE;
}