edir = (struct riscv_elf_link_hash_entry *) dir;
eind = (struct riscv_elf_link_hash_entry *) ind;
- if (ind->dyn_relocs != NULL)
- {
- if (dir->dyn_relocs != NULL)
- {
- struct elf_dyn_relocs **pp;
- struct elf_dyn_relocs *p;
-
- /* Add reloc counts against the indirect sym to the direct sym
- list. Merge any entries against the same section. */
- for (pp = &ind->dyn_relocs; (p = *pp) != NULL; )
- {
- struct elf_dyn_relocs *q;
-
- for (q = dir->dyn_relocs; q != NULL; q = q->next)
- if (q->sec == p->sec)
- {
- q->pc_count += p->pc_count;
- q->count += p->count;
- *pp = p->next;
- break;
- }
- if (q == NULL)
- pp = &p->next;
- }
- *pp = dir->dyn_relocs;
- }
-
- dir->dyn_relocs = ind->dyn_relocs;
- ind->dyn_relocs = NULL;
- }
-
if (ind->root.type == bfd_link_hash_indirect
&& dir->got.refcount <= 0)
{
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
}
-/* Find dynamic relocs for H that apply to read-only sections. */
-
-static asection *
-readonly_dynrelocs (struct elf_link_hash_entry *h)
-{
- struct elf_dyn_relocs *p;
-
- for (p = h->dyn_relocs; p != NULL; p = p->next)
- {
- asection *s = p->sec->output_section;
-
- if (s != NULL && (s->flags & SEC_READONLY) != 0)
- return p->sec;
- }
- return NULL;
-}
-
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
/* If we don't find any dynamic relocs in read-only sections, then
we'll be keeping the dynamic relocs and avoiding the copy reloc. */
- if (!readonly_dynrelocs (h))
+ if (!_bfd_elf_readonly_dynrelocs (h))
{
h->non_got_ref = 0;
return TRUE;
return TRUE;
}
-/* Set DF_TEXTREL if we find any dynamic relocs that apply to
- read-only sections. */
-
-static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
-{
- asection *sec;
-
- if (h->root.type == bfd_link_hash_indirect)
- return TRUE;
-
- sec = readonly_dynrelocs (h);
- if (sec != NULL)
- {
- struct bfd_link_info *info = (struct bfd_link_info *) info_p;
-
- info->flags |= DF_TEXTREL;
- info->callbacks->minfo
- (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"),
- sec->owner, h->root.root.string, sec);
-
- /* Not an error, just cut short the traversal. */
- return FALSE;
- }
- return TRUE;
-}
-
static bfd_boolean
riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
{
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info);
+ elf_link_hash_traverse (&htab->elf,
+ _bfd_elf_maybe_set_textrel, info);
if (info->flags & DF_TEXTREL)
{
obj_attribute *in_attr;
obj_attribute *out_attr;
bfd_boolean result = TRUE;
+ bfd_boolean priv_may_conflict = FALSE;
+ bfd_boolean in_priv_zero = TRUE;
+ bfd_boolean out_priv_zero = TRUE;
const char *sec_name = get_elf_backend_data (ibfd)->obj_attrs_section;
unsigned int i;
out_attr[Tag_RISCV_arch].s = merged_arch;
}
break;
+
case Tag_RISCV_priv_spec:
case Tag_RISCV_priv_spec_minor:
case Tag_RISCV_priv_spec_revision:
+ if (in_attr[i].i != 0)
+ in_priv_zero = FALSE;
+ if (out_attr[i].i != 0)
+ out_priv_zero = FALSE;
if (out_attr[i].i != in_attr[i].i)
+ priv_may_conflict = TRUE;
+
+ /* We check the priv version conflict when parsing the
+ revision version. */
+ if (i != Tag_RISCV_priv_spec_revision)
+ break;
+
+ /* Allow to link the object without the priv setting. */
+ if (out_priv_zero)
+ {
+ out_attr[i].i = in_attr[i].i;
+ out_attr[Tag_RISCV_priv_spec].i =
+ in_attr[Tag_RISCV_priv_spec].i;
+ out_attr[Tag_RISCV_priv_spec_minor].i =
+ in_attr[Tag_RISCV_priv_spec_minor].i;
+ }
+ else if (!in_priv_zero
+ && priv_may_conflict)
{
_bfd_error_handler
- (_("error: %pB: conflicting priv spec version "
- "(major/minor/revision)."), ibfd);
+ (_("error: %pB use privilege spec version %u.%u.%u but "
+ "the output use version %u.%u.%u."),
+ ibfd,
+ in_attr[Tag_RISCV_priv_spec].i,
+ in_attr[Tag_RISCV_priv_spec_minor].i,
+ in_attr[i].i,
+ out_attr[Tag_RISCV_priv_spec].i,
+ out_attr[Tag_RISCV_priv_spec_minor].i,
+ out_attr[i].i);
result = FALSE;
}
break;
+
case Tag_RISCV_unaligned_access:
out_attr[i].i |= in_attr[i].i;
break;
+
case Tag_RISCV_stack_align:
if (out_attr[i].i == 0)
out_attr[i].i = in_attr[i].i;
result = FALSE;
}
break;
+
default:
result &= _bfd_elf_merge_unknown_attribute_low (ibfd, obfd, i);
}