/* Xtensa-specific support for 32-bit ELF.
- Copyright 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
static bfd_boolean xtensa_is_proptable_section (asection *);
static int internal_reloc_compare (const void *, const void *);
static int internal_reloc_matches (const void *, const void *);
-extern asection *xtensa_get_property_section (asection *, const char *);
+static asection *xtensa_get_property_section (asection *, const char *);
+extern asection *xtensa_make_property_section (asection *, const char *);
static flagword xtensa_get_property_predef_flags (asection *);
/* Other functions called directly by the linker. */
bfd_signed_vma *local_got_refcounts;
const Elf_Internal_Rela *rel, *relend;
+ if (info->relocatable)
+ return TRUE;
+
if ((sec->flags & SEC_ALLOC) == 0)
return TRUE;
len = orig_len + strlen (fmt) + arglen + 20;
if (len > alloc_size)
{
- message = (char *) bfd_realloc (message, len);
+ message = (char *) bfd_realloc_or_free (message, len);
alloc_size = len;
}
- if (!is_append)
- memcpy (message, origmsg, orig_len);
- vsprintf (message + orig_len, fmt, ap);
+ if (message != NULL)
+ {
+ if (!is_append)
+ memcpy (message, origmsg, orig_len);
+ vsprintf (message + orig_len, fmt, ap);
+ }
VA_CLOSE (ap);
return message;
}
(info, error_message, input_bfd, input_section,
rel->r_offset)))
return FALSE;
+ continue;
}
else if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
&& (input_section->flags & SEC_ALLOC) != 0
BFD_ASSERT (sizeof (Elf32_External_Rela) * srel->reloc_count
<= srel->size);
}
+ else if (r_type == R_XTENSA_ASM_EXPAND && dynamic_symbol)
+ {
+ /* This should only happen for non-PIC code, which is not
+ supposed to be used on systems with dynamic linking.
+ Just ignore these relocations. */
+ continue;
+ }
}
/* Dynamic relocs are not propagated for SEC_DEBUGGING sections
bfd *dynobj;
asection *sdyn, *srelplt, *sgot, *sxtlit, *sgotloc;
Elf32_External_Dyn *dyncon, *dynconend;
- int num_xtlit_entries;
+ int num_xtlit_entries = 0;
if (! elf_hash_table (info)->dynamic_sections_created)
return TRUE;
BFD_ASSERT (! info->relocatable);
sxtlit = bfd_get_section_by_name (output_bfd, ".xt.lit");
sgotloc = htab->sgotloc;
- BFD_ASSERT (sxtlit && sgotloc);
- num_xtlit_entries =
- elf_xtensa_combine_prop_entries (output_bfd, sxtlit, sgotloc);
- if (num_xtlit_entries < 0)
- return FALSE;
+ BFD_ASSERT (sgotloc);
+ if (sxtlit)
+ {
+ num_xtlit_entries =
+ elf_xtensa_combine_prop_entries (output_bfd, sxtlit, sgotloc);
+ if (num_xtlit_entries < 0)
+ return FALSE;
+ }
dyncon = (Elf32_External_Dyn *) sdyn->contents;
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
pin_contents (sec, contents);
}
+
+ /* If the relocation still references a section in the same
+ input file, modify the relocation directly instead of
+ adding a "fix" record. */
+ if (target_sec->owner == abfd)
+ {
+ unsigned r_symndx = ELF32_R_SYM (new_reloc.rela.r_info);
+ irel->r_info = ELF32_R_INFO (r_symndx, r_type);
+ irel->r_addend = new_reloc.rela.r_addend;
+ pin_internal_relocs (sec, internal_relocs);
+ }
else
{
- /* If the relocation still references a section in the same
- input file, modify the relocation directly instead of
- adding a "fix" record. */
- if (target_sec->owner == abfd)
- {
- unsigned r_symndx = ELF32_R_SYM (new_reloc.rela.r_info);
- irel->r_info = ELF32_R_INFO (r_symndx, r_type);
- irel->r_addend = new_reloc.rela.r_addend;
- pin_internal_relocs (sec, internal_relocs);
- }
- else
- {
- bfd_vma addend_displacement;
- reloc_bfd_fix *fix;
-
- addend_displacement =
- new_reloc.target_offset + new_reloc.virtual_offset;
- fix = reloc_bfd_fix_init (sec, source_offset, r_type,
- target_sec,
- addend_displacement, TRUE);
- add_fix (sec, fix);
- }
+ bfd_vma addend_displacement;
+ reloc_bfd_fix *fix;
+
+ addend_displacement =
+ new_reloc.target_offset + new_reloc.virtual_offset;
+ fix = reloc_bfd_fix_init (sec, source_offset, r_type,
+ target_sec,
+ addend_displacement, TRUE);
+ add_fix (sec, fix);
}
}
}
if (section_index == SHN_UNDEF)
target_sec = bfd_und_section_ptr;
- else if (section_index > 0 && section_index < SHN_LORESERVE)
- target_sec = bfd_section_from_elf_index (abfd, section_index);
else if (section_index == SHN_ABS)
target_sec = bfd_abs_section_ptr;
else if (section_index == SHN_COMMON)
target_sec = bfd_com_section_ptr;
else
- /* Who knows? */
- target_sec = NULL;
+ target_sec = bfd_section_from_elf_index (abfd, section_index);
}
else
{
static int linkonce_len = sizeof (".gnu.linkonce.") - 1;
-asection *
-xtensa_get_property_section (asection *sec, const char *base_name)
+static char *
+xtensa_property_section_name (asection *sec, const char *base_name)
{
const char *suffix, *group_name;
char *prop_sec_name;
- asection *prop_sec;
group_name = elf_group_name (sec);
if (group_name)
else
prop_sec_name = strdup (base_name);
+ return prop_sec_name;
+}
+
+
+static asection *
+xtensa_get_property_section (asection *sec, const char *base_name)
+{
+ char *prop_sec_name;
+ asection *prop_sec;
+
+ prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
+ match_section_group,
+ (void *) elf_group_name (sec));
+ free (prop_sec_name);
+ return prop_sec;
+}
+
+
+asection *
+xtensa_make_property_section (asection *sec, const char *base_name)
+{
+ char *prop_sec_name;
+ asection *prop_sec;
+
/* Check if the section already exists. */
+ prop_sec_name = xtensa_property_section_name (sec, base_name);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
- (void *) group_name);
+ (void *) elf_group_name (sec));
/* If not, create it. */
if (! prop_sec)
{
if (! prop_sec)
return 0;
- elf_group_name (prop_sec) = group_name;
+ elf_group_name (prop_sec) = elf_group_name (sec);
}
free (prop_sec_name);