long symtab_size;
Elf_Internal_Shdr *hdr = &elf_tdata (abfd)->dynsymtab_hdr;
+ if (elf_dynsymtab (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return -1;
+ }
+
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *));
with the new definition. */
h->root.type = bfd_link_hash_undefined;
h->root.u.undef.abfd = h->root.u.def.section->owner;
+ h->elf_link_hash_flags &=~ ELF_LINK_HASH_DEFINED_WEAK;
}
+
+ /* If this is a weak definition which we are going to use,
+ and the symbol is currently undefined, record that the
+ definition is weak. */
+ if (definition
+ && (flags & BSF_WEAK) != 0
+ && ! bfd_is_und_section (sec)
+ && (h->root.type == bfd_link_hash_new
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_weak))
+ h->elf_link_hash_flags |= ELF_LINK_HASH_DEFINED_WEAK;
}
if (! (_bfd_generic_link_add_one_symbol
addresses of the various sections. */
boolean
-NAME(bfd_elf,size_dynamic_sections) (output_bfd, info, sinterpptr)
+NAME(bfd_elf,size_dynamic_sections) (output_bfd, rpath, info, sinterpptr)
bfd *output_bfd;
+ const char *rpath;
struct bfd_link_info *info;
asection **sinterpptr;
{
elf_hash_table (info)->bucketcount = bucketcount;
+ if (rpath != NULL)
+ {
+ unsigned long indx;
+
+ indx = bfd_add_to_strtab (dynobj, elf_hash_table (info)->dynstr, rpath);
+ if (indx == (unsigned long) -1
+ || ! elf_add_dynamic_entry (info, DT_RPATH, indx))
+ return false;
+ }
+
s = bfd_get_section_by_name (dynobj, ".dynstr");
BFD_ASSERT (s != NULL);
s->_raw_size = elf_hash_table (info)->dynstr->length;
sym.st_value = 0;
sym.st_size = h->size;
- sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
sym.st_other = 0;
+ if (h->root.type == bfd_link_hash_weak
+ || (h->elf_link_hash_flags & ELF_LINK_HASH_DEFINED_WEAK) != 0)
+ sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
+ else
+ sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
switch (h->root.type)
{
case bfd_link_hash_weak:
input_sec = bfd_und_section_ptr;
sym.st_shndx = SHN_UNDEF;
- sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
break;
case bfd_link_hash_defined: