/* ADI Blackfin BFD support for 32-bit ELF.
- Copyright 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
extern const bfd_target bfd_elf32_bfinfdpic_vec;
#define IS_FDPIC(bfd) ((bfd)->xvec == &bfd_elf32_bfinfdpic_vec)
-/* An extension of the elf hash table data structure, containing some
- additional Blackfin-specific data. */
+/* An extension of the elf hash table data structure,
+ containing some additional Blackfin-specific data. */
struct bfinfdpic_elf_link_hash_table
{
struct elf_link_hash_table elf;
/* Get the Blackfin ELF linker hash table from a link_info structure. */
#define bfinfdpic_hash_table(info) \
- ((struct bfinfdpic_elf_link_hash_table *) ((info)->hash))
+ (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
+ == BFIN_ELF_DATA ? ((struct bfinfdpic_elf_link_hash_table *) ((info)->hash)) : NULL)
#define bfinfdpic_got_section(info) \
(bfinfdpic_hash_table (info)->sgot)
if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
_bfd_elf_link_hash_newfunc,
- sizeof (struct elf_link_hash_entry)))
+ sizeof (struct elf_link_hash_entry),
+ BFIN_ELF_DATA))
{
free (ret);
return NULL;
const struct bfinfdpic_relocs_info *entry,
enum insert_option insert)
{
- struct bfinfdpic_relocs_info **loc =
- (struct bfinfdpic_relocs_info **) htab_find_slot (ht, entry, insert);
+ struct bfinfdpic_relocs_info **loc;
+
+ if (!ht)
+ return NULL;
+
+ loc = (struct bfinfdpic_relocs_info **) htab_find_slot (ht, entry, insert);
if (! loc)
return NULL;
struct elf_link_hash_entry *h;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
int ptralign;
- int offset;
/* This function may be called more than once. */
s = bfd_get_section_by_name (abfd, ".got");
return FALSE;
bfinfdpic_gotfixup_section (info) = s;
- offset = -2048;
flags = BSF_GLOBAL;
}
else
{
- offset = 2048;
flags = BSF_GLOBAL | BSF_WEAK;
}
{
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
- struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
if (! info->shared)
{
s = bfd_make_section_with_flags (abfd,
- (bed->default_use_rela_p
- ? ".rela.bss" : ".rel.bss"),
+ ".rela.bss",
flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
}
if (elf_hash_table (info)->dynamic_sections_created)
+ bfinfdpic_pltrel_section (info)->size =
+ gpinfop->g.lzplt / LZPLT_NORMAL_SIZE * get_elf_backend_data (output_bfd)->s->sizeof_rel;
+ if (bfinfdpic_pltrel_section (info)->size == 0)
+ bfinfdpic_pltrel_section (info)->flags |= SEC_EXCLUDE;
+ else
{
- bfinfdpic_pltrel_section (info)->size =
- gpinfop->g.lzplt / LZPLT_NORMAL_SIZE * get_elf_backend_data (output_bfd)->s->sizeof_rel;
- if (bfinfdpic_pltrel_section (info)->size == 0)
- bfinfdpic_pltrel_section (info)->flags |= SEC_EXCLUDE;
- else
- {
- bfinfdpic_pltrel_section (info)->contents =
- (bfd_byte *) bfd_zalloc (dynobj,
- bfinfdpic_pltrel_section (info)->size);
- if (bfinfdpic_pltrel_section (info)->contents == NULL)
- return FALSE;
- }
+ bfinfdpic_pltrel_section (info)->contents =
+ (bfd_byte *) bfd_zalloc (dynobj,
+ bfinfdpic_pltrel_section (info)->size);
+ if (bfinfdpic_pltrel_section (info)->contents == NULL)
+ return FALSE;
}
/* Add 4 bytes for every block of at most 65535 lazy PLT entries,
/* Allocate the PLT section contents only after
_bfinfdpic_assign_plt_entries has a chance to add the size of the
non-lazy PLT entries. */
- if (elf_hash_table (info)->dynamic_sections_created)
+ if (bfinfdpic_plt_section (info)->size == 0)
+ bfinfdpic_plt_section (info)->flags |= SEC_EXCLUDE;
+ else
{
- if (bfinfdpic_plt_section (info)->size == 0)
- bfinfdpic_plt_section (info)->flags |= SEC_EXCLUDE;
- else
- {
- bfinfdpic_plt_section (info)->contents =
- (bfd_byte *) bfd_zalloc (dynobj,
- bfinfdpic_plt_section (info)->size);
- if (bfinfdpic_plt_section (info)->contents == NULL)
- return FALSE;
- }
+ bfinfdpic_plt_section (info)->contents =
+ (bfd_byte *) bfd_zalloc (dynobj,
+ bfinfdpic_plt_section (info)->size);
+ if (bfinfdpic_plt_section (info)->contents == NULL)
+ return FALSE;
}
return TRUE;
return FALSE;
}
+ s = bfd_get_section_by_name (dynobj, ".dynbss");
+ if (s && s->size == 0)
+ s->flags |= SEC_EXCLUDE;
+
+ s = bfd_get_section_by_name (dynobj, ".rela.bss");
+ if (s && s->size == 0)
+ s->flags |= SEC_EXCLUDE;
+
return TRUE;
}
if (new_flags & EF_BFIN_FDPIC)
new_flags &= ~EF_BFIN_PIC;
-#ifdef DEBUG
+#ifndef DEBUG
+ if (0)
+#endif
(*_bfd_error_handler) ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %s",
old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no",
bfd_get_filename (ibfd));
-#endif
if (!elf_flags_init (obfd)) /* First call, no flags set. */
{
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
bfin_link_hash_newfunc,
- sizeof (struct elf_link_hash_entry)))
+ sizeof (struct elf_link_hash_entry),
+ BFIN_ELF_DATA))
{
free (ret);
return NULL;