aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-10-16 21:16:07 +1030
committerAlan Modra <amodra@gmail.com>2014-10-16 21:18:16 +1030
commitf1885d1e59a7e6e0627429cd3068740d96f8a184 (patch)
tree903d9dc96d952cd73a24508ca9404dca01c79565
parentbb99c4726c8926b943e0f525247d2ce0d7ffe6d1 (diff)
downloadgdb-f1885d1e59a7e6e0627429cd3068740d96f8a184.zip
gdb-f1885d1e59a7e6e0627429cd3068740d96f8a184.tar.gz
gdb-f1885d1e59a7e6e0627429cd3068740d96f8a184.tar.bz2
Fix 17492, ld segfault with --oformat=binary
PR 17492 * elf32-arm.c (elf32_arm_add_symbol_hook): Only set has_gnu_symbols on ELF output bfd. * elf32-i386.c (elf_i386_add_symbol_hook): Likewise. * elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise. * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise. * elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise. * elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise. * elf-s390-common.c (elf_s390_add_symbol_hook): Likewise. Handle STB_GNU_UNIQUE too.
-rw-r--r--bfd/ChangeLog16
-rw-r--r--bfd/elf-s390-common.c6
-rw-r--r--bfd/elf32-arm.c7
-rw-r--r--bfd/elf32-i386.c9
-rw-r--r--bfd/elf32-m68k.c7
-rw-r--r--bfd/elf32-ppc.c7
-rw-r--r--bfd/elf32-sparc.c9
-rw-r--r--bfd/elf64-ppc.c19
-rw-r--r--bfd/elf64-sparc.c7
-rw-r--r--bfd/elf64-x86-64.c7
-rw-r--r--bfd/elfxx-aarch64.c7
11 files changed, 62 insertions, 39 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 80cd6bc..384fca7 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,21 @@
2014-10-16 Alan Modra <amodra@gmail.com>
+ PR 17492
+ * elf32-arm.c (elf32_arm_add_symbol_hook): Only set has_gnu_symbols
+ on ELF output bfd.
+ * elf32-i386.c (elf_i386_add_symbol_hook): Likewise.
+ * elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
+ * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
+ * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
+ * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
+ * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
+ * elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
+ * elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
+ * elf-s390-common.c (elf_s390_add_symbol_hook): Likewise. Handle
+ STB_GNU_UNIQUE too.
+
+2014-10-16 Alan Modra <amodra@gmail.com>
+
* elf64-ppc.c (ppc64_elf_before_check_relocs): Do .opd processing
even when output is not ppc64 ELF. Remove redundant tests on
type of input bfd.
diff --git a/bfd/elf-s390-common.c b/bfd/elf-s390-common.c
index dd35c40..c74883c 100644
--- a/bfd/elf-s390-common.c
+++ b/bfd/elf-s390-common.c
@@ -234,8 +234,10 @@ elf_s390_add_symbol_hook (bfd *abfd,
asection **secp ATTRIBUTE_UNUSED,
bfd_vma *valp ATTRIBUTE_UNUSED)
{
- if ((abfd->flags & DYNAMIC) == 0
- && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b4bf5e6..996889d 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -15908,9 +15908,10 @@ elf32_arm_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
Elf_Internal_Sym *sym, const char **namep,
flagword *flagsp, asection **secp, bfd_vma *valp)
{
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
if (elf32_arm_hash_table (info) == NULL)
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index dddd9dc..64cdece 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -5038,16 +5038,17 @@ elf_i386_hash_symbol (struct elf_link_hash_entry *h)
static bfd_boolean
elf_i386_add_symbol_hook (bfd * abfd,
- struct bfd_link_info * info ATTRIBUTE_UNUSED,
+ struct bfd_link_info * info,
Elf_Internal_Sym * sym,
const char ** namep ATTRIBUTE_UNUSED,
flagword * flagsp ATTRIBUTE_UNUSED,
asection ** secp ATTRIBUTE_UNUSED,
bfd_vma * valp ATTRIBUTE_UNUSED)
{
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 952d819..0058da4 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -4842,9 +4842,10 @@ elf_m68k_add_symbol_hook (bfd *abfd,
asection **secp ATTRIBUTE_UNUSED,
bfd_vma *valp ATTRIBUTE_UNUSED)
{
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 6fb603d..04c2d6a 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -3636,9 +3636,10 @@ ppc_elf_add_symbol_hook (bfd *abfd,
*valp = sym->st_size;
}
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index ecfa165..b2a1f0f 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -173,16 +173,17 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
static bfd_boolean
elf32_sparc_add_symbol_hook (bfd * abfd,
- struct bfd_link_info * info ATTRIBUTE_UNUSED,
+ struct bfd_link_info * info,
Elf_Internal_Sym * sym,
const char ** namep ATTRIBUTE_UNUSED,
flagword * flagsp ATTRIBUTE_UNUSED,
asection ** secp ATTRIBUTE_UNUSED,
bfd_vma * valp ATTRIBUTE_UNUSED)
{
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
}
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 974f992..bf4ab30 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -4807,19 +4807,16 @@ ppc64_elf_add_symbol_hook (bfd *ibfd,
asection **sec,
bfd_vma *value ATTRIBUTE_UNUSED)
{
- if ((ibfd->flags & DYNAMIC) == 0
- && ELF_ST_BIND (isym->st_info) == STB_GNU_UNIQUE)
+ if ((ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (isym->st_info) == STB_GNU_UNIQUE)
+ && (ibfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
- if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
- {
- if ((ibfd->flags & DYNAMIC) == 0)
- elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
- }
- else if (ELF_ST_TYPE (isym->st_info) == STT_FUNC)
- ;
- else if (*sec != NULL
- && strcmp ((*sec)->name, ".opd") == 0)
+ if (!(ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_TYPE (isym->st_info) == STT_FUNC)
+ && *sec != NULL
+ && strcmp ((*sec)->name, ".opd") == 0)
isym->st_info = ELF_ST_INFO (ELF_ST_BIND (isym->st_info), STT_FUNC);
if ((STO_PPC64_LOCAL_MASK & isym->st_other) != 0)
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 0866c0d..eeb94a9 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -424,9 +424,10 @@ elf64_sparc_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
{
static const char *const stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" };
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
if (ELF_ST_TYPE (sym->st_info) == STT_REGISTER)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 38c837a..6c3a65a 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -5541,9 +5541,10 @@ elf_x86_64_add_symbol_hook (bfd *abfd,
return TRUE;
}
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index b30e730..6ae4adf 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -481,9 +481,10 @@ _bfd_aarch64_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
asection **secp ATTRIBUTE_UNUSED,
bfd_vma *valp ATTRIBUTE_UNUSED)
{
- if ((abfd->flags & DYNAMIC) == 0
- && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
- || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+ if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+ || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)
+ && (abfd->flags & DYNAMIC) == 0
+ && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
return TRUE;