/* Xtensa-specific support for 32-bit ELF.
- Copyright 2003, 2004 Free Software Foundation, Inc.
+ Copyright 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
#include "bfd.h"
#include "sysdep.h"
if (a->address == b->address)
{
- /* The only circumstance where two entries may legitimately have the
- same address is when one of them is a zero-size placeholder to
- mark a place where fill can be inserted. The zero-size entry should
- come first. */
- BFD_ASSERT ((a->size == 0 || b->size == 0));
-
if (a->size != b->size)
return (a->size - b->size);
bfd_size_type table_size = 0;
bfd_byte *table_data;
property_table_entry *blocks;
- int block_count;
+ int blk, block_count;
bfd_size_type num_records;
Elf_Internal_Rela *internal_relocs;
bfd_vma section_addr;
/* Now sort them into address order for easy reference. */
qsort (blocks, block_count, sizeof (property_table_entry),
property_table_compare);
+
+ /* Check that the table contents are valid. Problems may occur,
+ for example, if an unrelocated object file is stripped. */
+ for (blk = 1; blk < block_count; blk++)
+ {
+ /* The only circumstance where two entries may legitimately
+ have the same address is when one of them is a zero-size
+ placeholder to mark a place where fill can be inserted.
+ The zero-size entry should come first. */
+ if (blocks[blk - 1].address == blocks[blk].address &&
+ blocks[blk - 1].size != 0)
+ {
+ (*_bfd_error_handler) (_("%B(%A): invalid property table"),
+ abfd, section);
+ bfd_set_error (bfd_error_bad_value);
+ free (blocks);
+ return -1;
+ }
+ }
}
*table_p = blocks;
r_symndx = ELF32_R_SYM (rel->r_info);
if (r_symndx >= symtab_hdr->sh_info)
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ {
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ while (h->root.type == bfd_link_hash_indirect
+ || h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ }
r_type = ELF32_R_TYPE (rel->r_info);
switch (r_type)
return FALSE;
/* Create ".rela.got". */
- s = bfd_make_section (dynobj, ".rela.got");
+ s = bfd_make_section_with_flags (dynobj, ".rela.got", flags);
if (s == NULL
- || ! bfd_set_section_flags (dynobj, s, flags)
|| ! bfd_set_section_alignment (dynobj, s, 2))
return FALSE;
/* Create ".got.loc" (literal tables for use by dynamic linker). */
- s = bfd_make_section (dynobj, ".got.loc");
+ s = bfd_make_section_with_flags (dynobj, ".got.loc", flags);
if (s == NULL
- || ! bfd_set_section_flags (dynobj, s, flags)
|| ! bfd_set_section_alignment (dynobj, s, 2))
return FALSE;
/* Create ".xt.lit.plt" (literal table for ".got.plt*"). */
- s = bfd_make_section (dynobj, ".xt.lit.plt");
+ s = bfd_make_section_with_flags (dynobj, ".xt.lit.plt",
+ noalloc_flags);
if (s == NULL
- || ! bfd_set_section_flags (dynobj, s, noalloc_flags)
|| ! bfd_set_section_alignment (dynobj, s, 2))
return FALSE;
sname = (char *) bfd_malloc (10);
sprintf (sname, ".plt.%u", chunk);
- s = bfd_make_section (dynobj, sname);
+ s = bfd_make_section_with_flags (dynobj, sname,
+ flags | SEC_CODE);
if (s == NULL
- || ! bfd_set_section_flags (dynobj, s, flags | SEC_CODE)
|| ! bfd_set_section_alignment (dynobj, s, 2))
return FALSE;
sname = (char *) bfd_malloc (14);
sprintf (sname, ".got.plt.%u", chunk);
- s = bfd_make_section (dynobj, sname);
+ s = bfd_make_section_with_flags (dynobj, sname, flags);
if (s == NULL
- || ! bfd_set_section_flags (dynobj, s, flags)
|| ! bfd_set_section_alignment (dynobj, s, 2))
return FALSE;
}
}
if (strip)
- _bfd_strip_section_from_output (info, s);
+ s->flags |= SEC_EXCLUDE;
else
{
/* Allocate memory for the section contents. */
sec_or_hash = r_reloc_get_section (&src->r_rel);
else
sec_or_hash = r_reloc_get_hash_entry (&src->r_rel);
- hash_val += hash_bfd_vma ((bfd_vma) (unsigned) sec_or_hash);
+ hash_val += hash_bfd_vma ((bfd_vma) (size_t) sec_or_hash);
}
return hash_val;
}
static void
ebb_propose_action (ebb_constraint *c,
- bfd_vma alignment_pow,
enum ebb_target_enum align_type,
+ bfd_vma alignment_pow,
text_action_t action,
bfd_vma offset,
int removed_bytes,
char *linkonce_kind = 0;
if (strcmp (base_name, XTENSA_INSN_SEC_NAME) == 0)
- linkonce_kind = "x";
+ linkonce_kind = "x.";
else if (strcmp (base_name, XTENSA_LIT_SEC_NAME) == 0)
- linkonce_kind = "p";
+ linkonce_kind = "p.";
else if (strcmp (base_name, XTENSA_PROP_SEC_NAME) == 0)
linkonce_kind = "prop.";
else
/* The default literal sections should always be marked as "code" (i.e.,
SHF_EXECINSTR). This is particularly important for the Linux kernel
module loader so that the literals are not placed after the text. */
-static struct bfd_elf_special_section const elf_xtensa_special_sections[]=
+static struct bfd_elf_special_section const
+ xtensa_special_sections_f[]=
{
- { ".literal", 8, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
- { ".init.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ ".fini.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
{ NULL, 0, 0, 0, 0 }
};
+static struct bfd_elf_special_section const
+ xtensa_special_sections_i[]=
+{
+ { ".init.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
+ { NULL, 0, 0, 0, 0 }
+};
+static struct bfd_elf_special_section const
+ xtensa_special_sections_l[]=
+{
+ { ".literal", 8, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
+ { NULL, 0, 0, 0, 0 }
+};
+
+static struct bfd_elf_special_section const *
+ elf_xtensa_special_sections[27] =
+{
+ NULL, /* 'a' */
+ NULL, /* 'b' */
+ NULL, /* 'c' */
+ NULL, /* 'd' */
+ NULL, /* 'e' */
+ xtensa_special_sections_f, /* 'f' */
+ NULL, /* 'g' */
+ NULL, /* 'h' */
+ xtensa_special_sections_i, /* 'i' */
+ NULL, /* 'j' */
+ NULL, /* 'k' */
+ xtensa_special_sections_l, /* 'l' */
+ NULL, /* 'm' */
+ NULL, /* 'n' */
+ NULL, /* 'o' */
+ NULL, /* 'p' */
+ NULL, /* 'q' */
+ NULL, /* 'r' */
+ NULL, /* 's' */
+ NULL, /* 't' */
+ NULL, /* 'u' */
+ NULL, /* 'v' */
+ NULL, /* 'w' */
+ NULL, /* 'x' */
+ NULL, /* 'y' */
+ NULL, /* 'z' */
+ NULL /* other */
+};
+
\f
#ifndef ELF_ARCH
#define TARGET_LITTLE_SYM bfd_elf32_xtensa_le_vec