int elf32xtensa_no_literal_movement = 1;
+/* Place property records for a section into individual property section
+ with xt.prop. prefix. */
+
+bfd_boolean elf32xtensa_separate_props = FALSE;
+
/* Rename one of the generic section flags to better document how it
is used here. */
/* Whether relocations have been processed. */
break;
}
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, (int) code);
+ bfd_set_error (bfd_error_bad_value);
TRACE ("Unknown");
return NULL;
}
/* Given an ELF "rela" relocation, find the corresponding howto and record
it in the BFD internal arelent representation of the relocation. */
-static void
+static bfd_boolean
elf_xtensa_info_to_howto_rela (bfd *abfd,
arelent *cache_ptr,
Elf_Internal_Rela *dst)
/* xgettext:c-format */
_bfd_error_handler (_("%pB: unsupported relocation type %#x"),
abfd, r_type);
- r_type = 0;
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
}
cache_ptr->howto = &elf_howto_table[r_type];
+ return TRUE;
}
\f
section. Sets TABLE_P and returns the number of entries. On
error, returns a negative value. */
-static int
+int
xtensa_read_table_entries (bfd *abfd,
asection *section,
property_table_entry **table_p,
if (! elf_xtensa_dynamic_symbol_p (h, info))
elf_xtensa_make_sym_local (info, h);
+ if (! elf_xtensa_dynamic_symbol_p (h, info)
+ && h->root.type == bfd_link_hash_undefweak)
+ return TRUE;
+
if (h->plt.refcount > 0)
htab->elf.srelplt->size += (h->plt.refcount * sizeof (Elf32_External_Rela));
}
unresolved_reloc = FALSE;
}
- else
+ else if (!is_weak_undef)
{
/* Generate a RELATIVE relocation. */
outrel.r_info = ELF32_R_INFO (0, R_XTENSA_RELATIVE);
outrel.r_addend = 0;
}
+ else
+ {
+ continue;
+ }
}
loc = (srel->contents
{
struct elf_xtensa_link_hash_table *htab;
bfd *dynobj;
- asection *sdyn, *srelplt, *sgot, *sxtlit, *sgotloc;
+ asection *sdyn, *srelplt, *srelgot, *sgot, *sxtlit, *sgotloc;
Elf32_External_Dyn *dyncon, *dynconend;
int num_xtlit_entries = 0;
}
srelplt = htab->elf.srelplt;
+ srelgot = htab->elf.srelgot;
if (srelplt && srelplt->size != 0)
{
- asection *sgotplt, *srelgot, *spltlittbl;
+ asection *sgotplt, *spltlittbl;
int chunk, plt_chunks, plt_entries;
Elf_Internal_Rela irela;
bfd_byte *loc;
unsigned rtld_reloc;
- srelgot = htab->elf.srelgot;
spltlittbl = htab->spltlittbl;
BFD_ASSERT (srelgot != NULL && spltlittbl != NULL);
spltlittbl->contents + (chunk * 8) + 4);
}
- /* All the dynamic relocations have been emitted at this point.
- Make sure the relocation sections are the correct size. */
- if (srelgot->size != (sizeof (Elf32_External_Rela)
- * srelgot->reloc_count)
- || srelplt->size != (sizeof (Elf32_External_Rela)
- * srelplt->reloc_count))
- abort ();
-
/* The .xt.lit.plt section has just been modified. This must
happen before the code below which combines adjacent literal
table entries, and the .xt.lit.plt contents have to be forced to
spltlittbl->flags &= ~SEC_HAS_CONTENTS;
}
+ /* All the dynamic relocations have been emitted at this point.
+ Make sure the relocation sections are the correct size. */
+ if ((srelgot && srelgot->size != (sizeof (Elf32_External_Rela)
+ * srelgot->reloc_count))
+ || (srelplt && srelplt->size != (sizeof (Elf32_External_Rela)
+ * srelplt->reloc_count)))
+ abort ();
+
/* Combine adjacent literal table entries. */
BFD_ASSERT (! bfd_link_relocatable (info));
sxtlit = bfd_get_section_by_name (output_bfd, ".xt.lit");
static bfd_boolean check_section_ebb_reduces (const ebb_constraint *);
static void text_action_add_proposed
(text_action_list *, const ebb_constraint *, asection *);
-static int compute_fill_extra_space (property_table_entry *);
/* First pass: */
static bfd_boolean compute_removed_literals
BFD_ASSERT (action->action == ta_fill);
BFD_ASSERT (ebb->ends_unreachable->flags & XTENSA_PROP_UNREACHABLE);
- extra_space = compute_fill_extra_space (ebb->ends_unreachable);
+ extra_space = xtensa_compute_fill_extra_space (ebb->ends_unreachable);
br = action->removed_bytes + removed_bytes + extra_space;
br = br & ((1 << ebb->sec->alignment_power ) - 1);
struct xlate_map_entry
{
- unsigned orig_address;
- unsigned new_address;
+ bfd_vma orig_address;
+ bfd_vma new_address;
unsigned size;
};
{
void *r;
xlate_map_entry_t *e;
+ struct xlate_map_entry se;
if (map == NULL)
return offset_with_removed_text (action_list, offset);
if (map->entry_count == 0)
return offset;
- r = bsearch (&offset, map->entry, map->entry_count,
+ se.orig_address = offset;
+ r = bsearch (&se, map->entry, map->entry_count,
sizeof (xlate_map_entry_t), &xlate_compare);
e = (xlate_map_entry_t *) r;
+ /* There could be a jump past the end of the section,
+ allow it using the last xlate map entry to translate its address. */
+ if (e == NULL)
+ {
+ e = map->entry + map->entry_count - 1;
+ if (xlate_compare (&se, e) <= 0)
+ e = NULL;
+ }
BFD_ASSERT (e != NULL);
if (e == NULL)
return offset;
int
-compute_fill_extra_space (property_table_entry *entry)
+xtensa_compute_fill_extra_space (property_table_entry *entry)
{
int fill_extra_space;
do not add fill. */
the_add_entry = elf_xtensa_find_property_entry (prop_table, ptblsize,
entry_sec_offset);
- fill_extra_space = compute_fill_extra_space (the_add_entry);
+ fill_extra_space = xtensa_compute_fill_extra_space (the_add_entry);
fa = find_fill_action (&relax_info->action_list, sec, entry_sec_offset);
removed_diff = compute_removed_action_diff (fa, sec, entry_sec_offset,
if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
&& (input_section->flags & SEC_ALLOC) != 0
- && (dynamic_symbol || bfd_link_pic (info)))
+ && (dynamic_symbol || bfd_link_pic (info))
+ && (!h || h->root.type != bfd_link_hash_undefweak
+ || (dynamic_symbol && bfd_link_dll (info))))
{
asection *srel;
bfd_boolean is_plt = FALSE;
}
+static char *
+xtensa_add_names (const char *base, const char *suffix)
+{
+ if (suffix)
+ {
+ size_t base_len = strlen (base);
+ size_t suffix_len = strlen (suffix);
+ char *str = bfd_malloc (base_len + suffix_len + 1);
+
+ memcpy (str, base, base_len);
+ memcpy (str + base_len, suffix, suffix_len + 1);
+ return str;
+ }
+ else
+ {
+ return strdup (base);
+ }
+}
+
static int linkonce_len = sizeof (".gnu.linkonce.") - 1;
static char *
-xtensa_property_section_name (asection *sec, const char *base_name)
+xtensa_property_section_name (asection *sec, const char *base_name,
+ bfd_boolean separate_sections)
{
const char *suffix, *group_name;
char *prop_sec_name;
suffix = strrchr (sec->name, '.');
if (suffix == sec->name)
suffix = 0;
- prop_sec_name = (char *) bfd_malloc (strlen (base_name) + 1
- + (suffix ? strlen (suffix) : 0));
- strcpy (prop_sec_name, base_name);
- if (suffix)
- strcat (prop_sec_name, suffix);
+ prop_sec_name = xtensa_add_names (base_name, suffix);
}
else if (strncmp (sec->name, ".gnu.linkonce.", linkonce_len) == 0)
{
strcat (prop_sec_name + linkonce_len, suffix);
}
else
- prop_sec_name = strdup (base_name);
+ {
+ prop_sec_name = xtensa_add_names (base_name,
+ separate_sections ? sec->name : NULL);
+ }
return prop_sec_name;
}
static asection *
-xtensa_get_property_section (asection *sec, const char *base_name)
+xtensa_get_separate_property_section (asection *sec, const char *base_name,
+ bfd_boolean separate_section)
{
char *prop_sec_name;
asection *prop_sec;
- prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec_name = xtensa_property_section_name (sec, base_name,
+ separate_section);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
(void *) elf_group_name (sec));
return prop_sec;
}
+static asection *
+xtensa_get_property_section (asection *sec, const char *base_name)
+{
+ asection *prop_sec;
+
+ /* Try individual property section first. */
+ prop_sec = xtensa_get_separate_property_section (sec, base_name, TRUE);
+
+ /* Refer to a common property section if individual is not present. */
+ if (!prop_sec)
+ prop_sec = xtensa_get_separate_property_section (sec, base_name, FALSE);
+
+ return prop_sec;
+}
+
asection *
xtensa_make_property_section (asection *sec, const char *base_name)
asection *prop_sec;
/* Check if the section already exists. */
- prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec_name = xtensa_property_section_name (sec, base_name,
+ elf32xtensa_separate_props);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
(void *) elf_group_name (sec));