+2005-02-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR 757
+ * elf-bfd.h (_bfd_elf_merge_symbol): Add a pointer to unsigned
+ int.
+
+ * elf32-sh-symbian.c (sh_symbian_relocate_section): Pass NULL
+ to _bfd_elf_merge_symbol.
+
+ * elflink.c (_bfd_elf_merge_symbol): Use the pointer to
+ unsigned int to return the alignment of the old common symbol
+ in the dynamic object.
+ (_bfd_elf_add_default_symbol): Pass NULL to
+ _bfd_elf_merge_symbol.
+ (elf_link_add_object_symbols): Pass &old_alignment to
+ _bfd_elf_merge_symbol. Get the alignment of the new common
+ symbol in the dynamic object.
+
2005-02-24 Ben Elliston <bje@au.ibm.com>
* coffcode.h (coff_sym_filepos): Remove GNU960 conditional code.
extern bfd_boolean _bfd_elf_merge_symbol
(bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
- asection **, bfd_vma *, struct elf_link_hash_entry **, bfd_boolean *,
+ asection **, bfd_vma *, unsigned int *,
+ struct elf_link_hash_entry **, bfd_boolean *,
bfd_boolean *, bfd_boolean *, bfd_boolean *);
extern bfd_boolean _bfd_elf_add_default_symbol
new_sym.st_other = ELF_ST_VISIBILITY (STV_DEFAULT);
new_sym.st_shndx = SHN_UNDEF;
- if (! _bfd_elf_merge_symbol (input_bfd, info, ptr->new_name, & new_sym, & psec,
- & new_value, & new_hash, & skip, & override, & type_change_ok,
+ if (! _bfd_elf_merge_symbol (input_bfd, info,
+ ptr->new_name, & new_sym,
+ & psec, & new_value, NULL,
+ & new_hash, & skip,
+ & override, & type_change_ok,
& size_change_ok))
{
_bfd_error_handler (_("%B: Failed to add renamed symbol %s"),
TYPE_CHANGE_OK if it is OK for the type to change. We set
SIZE_CHANGE_OK if it is OK for the size to change. By OK to
change, we mean that we shouldn't warn if the type or size does
- change. */
+ change. We set POLD_ALIGNMENT if an old common symbol in a dynamic
+ object is overridden by a regular object. */
bfd_boolean
_bfd_elf_merge_symbol (bfd *abfd,
Elf_Internal_Sym *sym,
asection **psec,
bfd_vma *pvalue,
+ unsigned int *pold_alignment,
struct elf_link_hash_entry **sym_hash,
bfd_boolean *skip,
bfd_boolean *override,
if (h->size > *pvalue)
*pvalue = h->size;
- /* FIXME: We no longer know the alignment required by the symbol
- in the dynamic object, so we just wind up using the one from
- the regular object. */
+ /* We need to remember the alignment required by the symbol
+ in the dynamic object. */
+ BFD_ASSERT (pold_alignment);
+ *pold_alignment = h->root.u.def.section->alignment_power;
olddef = FALSE;
olddyncommon = FALSE;
size_change_ok = FALSE;
sec = *psec;
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
- &hi, &skip, &override, &type_change_ok,
- &size_change_ok))
+ NULL, &hi, &skip, &override,
+ &type_change_ok, &size_change_ok))
return FALSE;
if (skip)
size_change_ok = FALSE;
sec = *psec;
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
- &hi, &skip, &override, &type_change_ok,
- &size_change_ok))
+ NULL, &hi, &skip, &override,
+ &type_change_ok, &size_change_ok))
return FALSE;
if (skip)
{
int bind;
bfd_vma value;
- asection *sec;
+ asection *sec, *new_sec;
flagword flags;
const char *name;
struct elf_link_hash_entry *h;
type_change_ok = get_elf_backend_data (abfd)->type_change_ok;
old_alignment = 0;
old_bfd = NULL;
+ new_sec = sec;
if (is_elf_hash_table (hash_table))
{
name = newname;
}
- if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value,
+ if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec,
+ &value, &old_alignment,
sym_hash, &skip, &override,
&type_change_ok, &size_change_ok))
goto error_free_vers;
}
/* Set the alignment of a common symbol. */
- if (isym->st_shndx == SHN_COMMON
+ if ((isym->st_shndx == SHN_COMMON
+ || bfd_is_com_section (sec))
&& h->root.type == bfd_link_hash_common)
{
unsigned int align;
- align = bfd_log2 (isym->st_value);
+ if (isym->st_shndx == SHN_COMMON)
+ align = bfd_log2 (isym->st_value);
+ else
+ {
+ /* The new symbol is a common symbol in a shared object.
+ We need to get the alignment from the section. */
+ align = new_sec->alignment_power;
+ }
if (align > old_alignment
/* Permit an alignment power of zero if an alignment of one
is specified and no other alignments have been specified. */