+2014-12-12 Alan Modra <amodra@gmail.com>
+
+ PR 15228
+ * elflink.c (_bfd_elf_adjust_dynamic_copy): Add "info" param.
+ Error on copy relocs against protected symbols.
+ (elf_merge_st_other): Set h->protected_def.
+ * elf-bfd.h (struct elf_link_hash_entry): Add "protected_def".
+ (_bfd_elf_adjust_dynamic_copy): Update prototype.
+ * elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Update
+ _bfd_elf_adjust_dynamic_copy call.
+ * elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
+ * elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
+ * elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
+ * elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
+ * elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
+ * elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
+ * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
+ * elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
+ * elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol): Likewise.
+ * elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
+ * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
+ * elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
+ * elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
+ * elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+ * elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
+ * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
+ * elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
+ * elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol): Likewise.
+
2014-12-11 Keith Seitz <keiths@redhat.com>
* elf.c (elf_parse_notes): Define convenience macro
unsigned int pointer_equality_needed : 1;
/* Symbol is a unique global symbol. */
unsigned int unique_global : 1;
+ /* Symbol is defined with non-default visibility. */
+ unsigned int protected_def : 1;
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
struct elf_link_hash_entry **);
extern bfd_boolean _bfd_elf_adjust_dynamic_copy
- (struct elf_link_hash_entry *, asection *);
+ (struct bfd_link_info *, struct elf_link_hash_entry *, asection *);
extern bfd_boolean _bfd_elf_dynamic_symbol_p
(struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean);
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Set the sizes of the dynamic sections. */
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Set the sizes of the dynamic sections. */
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Adjust our "subclass" elements for an indirect symbol. */
sec = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (eh, sec);
+ return _bfd_elf_adjust_dynamic_copy (info, eh, sec);
}
/* Allocate space in the .plt for entries that won't have relocations.
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
\f
/* Increment the index of a dynamic symbol by a given amount. Called
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Set the sizes of the dynamic sections. */
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (eh, s);
+ return _bfd_elf_adjust_dynamic_copy (info, eh, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
\f
/* Generate a symbol to mark plt call stubs. For non-PIC code the sym is
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
static bfd_boolean
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss);
+ return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdynbss);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* This function is called via elf_link_hash_traverse. It resets GOT
s = htab->dynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* If given a function descriptor symbol, hide both the function code
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* This function is called via sh_elf_link_hash_traverse if we are
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
if (symvis - 1 < hvis - 1)
h->other = symvis | (h->other & ~ELF_ST_VISIBILITY (-1));
}
+ else if (definition && ELF_ST_VISIBILITY (isym->st_other) != STV_DEFAULT)
+ h->protected_def = 1;
}
/* This function is called when we want to merge a new symbol with an
DYNBSS. */
bfd_boolean
-_bfd_elf_adjust_dynamic_copy (struct elf_link_hash_entry *h,
+_bfd_elf_adjust_dynamic_copy (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h,
asection *dynbss)
{
unsigned int power_of_two;
/* Increment the size of DYNBSS to make room for the symbol. */
dynbss->size += h->size;
+ if (h->protected_def)
+ {
+ info->callbacks->einfo
+ (_("%P: copy reloc against protected `%T' is invalid\n"),
+ h->root.root.string);
+ return FALSE;
+ }
+
return TRUE;
}
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
dynamic will now refer to the local copy instead. */
hmips->possibly_dynamic_relocs = 0;
- return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss);
+ return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdynbss);
}
\f
/* This function is called after all the input files have been read,
s = htab->sdynbss;
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss);
+ return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdynbss);
}
/* Allocate space in .plt, .got and associated reloc sections for