dynsym = FALSE;
}
+ if (definition)
+ h->target_internal = isym->st_target_internal;
+
/* Check to see if we need to add an indirect symbol for
the default name. */
if (definition || h->root.type == bfd_link_hash_common)
{
struct elf_link_hash_entry *h;
bfd *element;
- bfd *subsbfd = NULL;
struct bfd_link_hash_entry *undefs_tail;
symindex mark;
undefs_tail = info->hash->undefs_tail;
- if (! (*info->callbacks->add_archive_element)
- (info, element, symdef->name, &subsbfd))
+ if (!(*info->callbacks
+ ->add_archive_element) (info, element, symdef->name, &element))
goto error_return;
- /* Potentially, the add_archive_element hook may have set a
- substitute BFD for us. */
- if (! bfd_link_add_symbols (subsbfd ? subsbfd : element, info))
+ if (!bfd_link_add_symbols (element, info))
goto error_return;
/* If there are any new undefined symbols, we need to make
{
const char *verstr, *name;
size_t namelen, verlen, newlen;
- char *newname, *p;
+ char *newname, *p, leading_char;
struct elf_link_hash_entry *newh;
+ leading_char = bfd_get_symbol_leading_char (output_bfd);
name = d->pattern;
- namelen = strlen (name);
+ namelen = strlen (name) + (leading_char != '\0');
verstr = t->name;
verlen = strlen (verstr);
newlen = namelen + verlen + 3;
newname = (char *) bfd_malloc (newlen);
if (newname == NULL)
return FALSE;
- memcpy (newname, name, namelen);
+ newname[0] = leading_char;
+ memcpy (newname + (leading_char != '\0'), name, namelen);
/* Check the hidden versioned definition. */
p = newname + namelen;
h->ref_regular ? NULL : h->root.u.undef.abfd,
NULL, 0, finfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)))
{
+ bfd_set_error (bfd_error_bad_value);
eoinfo->failed = TRUE;
return FALSE;
}
&& !h->dynamic_weak
&& ! elf_link_check_versioned_symbol (finfo->info, bed, h))
{
- (*_bfd_error_handler)
- (_("%B: %s symbol `%s' in %B is referenced by DSO"),
- finfo->output_bfd,
- h->root.u.def.section == bfd_abs_section_ptr
- ? finfo->output_bfd : h->root.u.def.section->owner,
- ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
- ? "internal"
- : ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
- ? "hidden" : "local",
- h->root.root.string);
+ bfd *def_bfd;
+ const char *msg;
+
+ if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL)
+ msg = _("%B: internal symbol `%s' in %B is referenced by DSO");
+ else if (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
+ msg = _("%B: hidden symbol `%s' in %B is referenced by DSO");
+ else
+ msg = _("%B: local symbol `%s' in %B is referenced by DSO");
+ def_bfd = finfo->output_bfd;
+ if (h->root.u.def.section != bfd_abs_section_ptr)
+ def_bfd = h->root.u.def.section->owner;
+ (*_bfd_error_handler) (msg, finfo->output_bfd, def_bfd,
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
eoinfo->failed = TRUE;
return FALSE;
}
|| h->root.type == bfd_link_hash_defweak)
&& elf_discarded_section (h->root.u.def.section))
strip = TRUE;
+ else if ((h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ && h->root.u.undef.abfd != NULL
+ && (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
+ strip = TRUE;
else
strip = FALSE;
sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
else
sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
+ sym.st_target_internal = h->target_internal;
switch (h->root.type)
{
(*_bfd_error_handler)
(_("%B: could not find output section %A for input section %A"),
finfo->output_bfd, input_sec->output_section, input_sec);
+ bfd_set_error (bfd_error_nonrepresentable_section);
eoinfo->failed = TRUE;
return FALSE;
}
&& h->root.type == bfd_link_hash_undefined
&& !h->def_regular)
{
- (*_bfd_error_handler)
- (_("%B: %s symbol `%s' isn't defined"),
- finfo->output_bfd,
- ELF_ST_VISIBILITY (sym.st_other) == STV_PROTECTED
- ? "protected"
- : ELF_ST_VISIBILITY (sym.st_other) == STV_INTERNAL
- ? "internal" : "hidden",
- h->root.root.string);
+ const char *msg;
+
+ if (ELF_ST_VISIBILITY (sym.st_other) == STV_PROTECTED)
+ msg = _("%B: protected symbol `%s' isn't defined");
+ else if (ELF_ST_VISIBILITY (sym.st_other) == STV_INTERNAL)
+ msg = _("%B: internal symbol `%s' isn't defined");
+ else
+ msg = _("%B: hidden symbol `%s' isn't defined");
+ (*_bfd_error_handler) (msg, finfo->output_bfd, h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
eoinfo->failed = TRUE;
return FALSE;
}
contents = elf_section_data (o)->this_hdr.contents;
else
{
- bfd_size_type amt = o->rawsize ? o->rawsize : o->size;
-
contents = finfo->contents;
- if (! bfd_get_section_contents (input_bfd, o, contents, 0, amt))
+ if (! bfd_get_full_section_contents (input_bfd, o, &contents))
return FALSE;
}
elfsym.st_info = 0;
elfsym.st_other = 0;
elfsym.st_shndx = SHN_UNDEF;
+ elfsym.st_target_internal = 0;
if (elf_link_output_sym (&finfo, NULL, &elfsym, bfd_und_section_ptr,
NULL) != 1)
goto error_return;
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
elfsym.st_other = 0;
elfsym.st_value = 0;
+ elfsym.st_target_internal = 0;
for (i = 1; i < elf_numsections (abfd); i++)
{
o = bfd_section_from_elf_index (abfd, i);
else
{
if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
+ {
+ if (p->type == bfd_indirect_link_order
+ && (bfd_get_flavour (sub)
+ == bfd_target_elf_flavour)
+ && (elf_elfheader (sub)->e_ident[EI_CLASS]
+ != bed->s->elfclass))
+ {
+ const char *iclass, *oclass;
+
+ if (bed->s->elfclass == ELFCLASS64)
+ {
+ iclass = "ELFCLASS32";
+ oclass = "ELFCLASS64";
+ }
+ else
+ {
+ iclass = "ELFCLASS64";
+ oclass = "ELFCLASS32";
+ }
+
+ bfd_set_error (bfd_error_wrong_format);
+ (*_bfd_error_handler)
+ (_("%B: file class %s incompatible with %s"),
+ sub, iclass, oclass);
+ }
+
+ goto error_return;
+ }
}
}
}
sym.st_name = 0;
sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
sym.st_other = 0;
+ sym.st_target_internal = 0;
for (s = abfd->sections; s != NULL; s = s->next)
{
/* Routines to support the creation of dynamic relocs. */
-/* Return true if NAME is a name of a relocation
- section associated with section S. */
-
-static bfd_boolean
-is_reloc_section (bfd_boolean rela, const char * name, asection * s)
-{
- if (rela)
- return CONST_STRNEQ (name, ".rela")
- && strcmp (bfd_get_section_name (NULL, s), name + 5) == 0;
-
- return CONST_STRNEQ (name, ".rel")
- && strcmp (bfd_get_section_name (NULL, s), name + 4) == 0;
-}
-
/* Returns the name of the dynamic reloc section associated with SEC. */
static const char *
asection * sec,
bfd_boolean is_rela)
{
- const char * name;
- unsigned int strndx = elf_elfheader (abfd)->e_shstrndx;
- unsigned int shnam = _bfd_elf_single_rel_hdr (sec)->sh_name;
+ char *name;
+ const char *old_name = bfd_get_section_name (NULL, sec);
+ const char *prefix = is_rela ? ".rela" : ".rel";
- name = bfd_elf_string_from_elf_section (abfd, strndx, shnam);
- if (name == NULL)
+ if (old_name == NULL)
return NULL;
- if (! is_reloc_section (is_rela, name, sec))
- {
- static bfd_boolean complained = FALSE;
-
- if (! complained)
- {
- (*_bfd_error_handler)
- (_("%B: bad relocation section name `%s\'"), abfd, name);
- complained = TRUE;
- }
- name = NULL;
- }
+ name = bfd_alloc (abfd, strlen (prefix) + strlen (old_name) + 1);
+ sprintf (name, "%s%s", prefix, old_name);
return name;
}
struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *)hsrc;
ehdest->type = ehsrc->type;
+ ehdest->target_internal = ehsrc->target_internal;
+}
+
+/* Append a RELA relocation REL to section S in BFD. */
+
+void
+elf_append_rela (bfd *abfd, asection *s, Elf_Internal_Rela *rel)
+{
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_byte *loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rela);
+ BFD_ASSERT (loc + bed->s->sizeof_rela <= s->contents + s->size);
+ bed->s->swap_reloca_out (abfd, rel, loc);
+}
+
+/* Append a REL relocation REL to section S in BFD. */
+
+void
+elf_append_rel (bfd *abfd, asection *s, Elf_Internal_Rela *rel)
+{
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_byte *loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rel);
+ BFD_ASSERT (loc + bed->s->sizeof_rel <= s->contents + s->size);
+ bed->s->swap_reloca_out (abfd, rel, loc);
}