/* SPU specific support for 32-bit ELF
- Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
{
struct spu_link_hash_table *htab;
- htab = bfd_malloc (sizeof (*htab));
+ htab = bfd_zmalloc (sizeof (*htab));
if (htab == NULL)
return NULL;
return NULL;
}
- memset (&htab->ovtab, 0,
- sizeof (*htab) - offsetof (struct spu_link_hash_table, ovtab));
-
htab->elf.init_got_refcount.refcount = 0;
htab->elf.init_got_refcount.glist = NULL;
htab->elf.init_got_offset.offset = 0;
struct spu_link_hash_table *htab = spu_hash_table (info);
bfd *ibfd;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
if (bfd_get_section_by_name (ibfd, SPU_PTNOTE_SPUNAME) != NULL)
break;
}
/* Support two sizes of overlay stubs, a slower more compact stub of two
- intructions, and a faster stub of four instructions.
+ instructions, and a faster stub of four instructions.
Soft-icache stubs are four or eight words. */
static unsigned int
add = (int) irela->r_addend & 0xffffffff;
if (add != 0)
len += 1 + 8;
- name = bfd_malloc (len);
+ name = bfd_malloc (len + 1);
if (name == NULL)
return FALSE;
{
return count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
}
-
+
return TRUE;
}
return build_stub (info, NULL, NULL, nonovl_stub, h, NULL,
h->root.u.def.value, sym_sec);
}
-
+
return TRUE;
}
struct spu_link_hash_table *htab = spu_hash_table (info);
bfd *ibfd;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
Elf_Internal_Shdr *symtab_hdr;
asection *isec;
Elf_Internal_Sym *local_syms = NULL;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
/* We'll need the symbol table in a second. */
return count;
}
+static int
+ovl_mgr_stat (struct bfd *abfd ATTRIBUTE_UNUSED,
+ void *stream,
+ struct stat *sb)
+{
+ struct _ovl_stream *os = (struct _ovl_stream *) stream;
+
+ memset (sb, 0, sizeof (*sb));
+ sb->st_size = (const char *) os->end - (const char *) os->start;
+ return 0;
+}
+
bfd_boolean
spu_elf_open_builtin_lib (bfd **ovl_bfd, const struct _ovl_stream *stream)
{
(void *) stream,
ovl_mgr_pread,
NULL,
- NULL);
+ ovl_mgr_stat);
return *ovl_bfd != NULL;
}
htab->local_store = hi + 1 - lo;
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ for (m = elf_seg_map (abfd); m != NULL; m = m->next)
if (m->p_type == PT_LOAD)
for (i = 0; i < m->count; i++)
if (m->sections[i]->size != 0
bfd_boolean gaps = FALSE;
bfd_idx = 0;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
bfd_idx++;
psym_arr = bfd_zmalloc (bfd_idx * sizeof (*psym_arr));
sec_arr = bfd_zmalloc (bfd_idx * sizeof (*sec_arr));
if (sec_arr == NULL)
return FALSE;
-
+
for (ibfd = info->input_bfds, bfd_idx = 0;
ibfd != NULL;
- ibfd = ibfd->link_next, bfd_idx++)
+ ibfd = ibfd->link.next, bfd_idx++)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
Elf_Internal_Shdr *symtab_hdr;
asection *sec;
size_t symcount;
Elf_Internal_Sym *syms, *sy, **psyms, **psy;
asection **psecs, **p;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
/* Read all the symbols. */
if (symtab_hdr->contents != NULL)
{
/* Don't use cached symbols since the generic ELF linker
- code only reads local symbols, and we need globals too. */
+ code only reads local symbols, and we need globals too. */
free (symtab_hdr->contents);
symtab_hdr->contents = NULL;
}
relocations. */
for (ibfd = info->input_bfds, bfd_idx = 0;
ibfd != NULL;
- ibfd = ibfd->link_next, bfd_idx++)
+ ibfd = ibfd->link.next, bfd_idx++)
{
asection *sec;
for (ibfd = info->input_bfds, bfd_idx = 0;
ibfd != NULL;
- ibfd = ibfd->link_next, bfd_idx++)
+ ibfd = ibfd->link.next, bfd_idx++)
{
Elf_Internal_Shdr *symtab_hdr;
asection *sec;
}
}
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
asection *sec;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
/* Some of the symbols we've installed as marking the
for (ibfd = info->input_bfds, bfd_idx = 0;
ibfd != NULL;
- ibfd = ibfd->link_next, bfd_idx++)
+ ibfd = ibfd->link.next, bfd_idx++)
{
if (psym_arr[bfd_idx] == NULL)
continue;
{
bfd *ibfd;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
asection *sec;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
bfd *ibfd;
unsigned int depth;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
asection *sec;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
memset (&dummy_caller, 0, sizeof (dummy_caller));
lib_count = 0;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
asection *sec;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
struct bfd_link_info *info)
{
unsigned int j;
-
+
for (j = base; j < count && ovly_map[j] == ovlynum; j++)
{
asection *sec = ovly_sections[2 * j];
/* Find the extents of our loadable image. */
lo = (unsigned int) -1;
hi = 0;
- for (m = elf_tdata (info->output_bfd)->segment_map; m != NULL; m = m->next)
+ for (m = elf_seg_map (info->output_bfd); m != NULL; m = m->next)
if (m->p_type == PT_LOAD)
for (i = 0; i < m->count; i++)
if (m->sections[i]->size != 0)
goto err_exit;
bfd_count = 0;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
++bfd_count;
bfd_arr = bfd_malloc (bfd_count * sizeof (*bfd_arr));
if (bfd_arr == NULL)
count = 0;
bfd_count = 0;
total_overlay_size = 0;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
- extern const bfd_target bfd_elf32_spu_vec;
+ extern const bfd_target spu_elf32_vec;
asection *sec;
unsigned int old_count;
- if (ibfd->xvec != &bfd_elf32_spu_vec)
+ if (ibfd->xvec != &spu_elf32_vec)
continue;
old_count = count;
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ if (info->wrap_hash != NULL
+ && (input_section->flags & SEC_DEBUGGING) != 0)
+ h = ((struct elf_link_hash_entry *)
+ unwrap_hash_lookup (info, input_bfd, &h->root));
+
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;
sym_name = h->root.root.string;
}
- if (sec != NULL && elf_discarded_section (sec))
+ if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel, relend, howto, contents);
+ rel, 1, relend, howto, 0, contents);
if (info->relocatable)
continue;
&& !(h->def_regular || ELF_COMMON_DEF_P (h)))
{
bfd_byte *loc = contents + rel->r_offset;
- loc[0] = 0x1c;
- loc[1] = 0x00;
+ loc[0] = 0x1c;
+ loc[1] = 0x00;
loc[2] &= 0x3f;
}
/* Set ELF header e_type for plugins. */
static void
-spu_elf_post_process_headers (bfd *abfd,
- struct bfd_link_info *info ATTRIBUTE_UNUSED)
+spu_elf_post_process_headers (bfd *abfd, struct bfd_link_info *info)
{
if (spu_plugin)
{
i_ehdrp->e_type = ET_DYN;
}
+
+ _bfd_elf_post_process_headers (abfd, info);
}
/* We may add an extra PT_LOAD segment for .toe. We also need extra
return TRUE;
toe = bfd_get_section_by_name (abfd, ".toe");
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+ for (m = elf_seg_map (abfd); m != NULL; m = m->next)
if (m->p_type == PT_LOAD && m->count > 1)
for (i = 0; i < m->count; i++)
if ((s = m->sections[i]) == toe
as PF_OVERLAY) will be placed into SPU local store on startup. */
/* Move all overlay segments onto a separate list. */
- p = &elf_tdata (abfd)->segment_map;
+ p = &elf_seg_map (abfd);
p_overlay = &m_overlay;
while (*p != NULL)
{
}
/* Re-insert overlay segments at the head of the segment map. */
- *p_overlay = elf_tdata (abfd)->segment_map;
- elf_tdata (abfd)->segment_map = m_overlay;
+ *p_overlay = elf_seg_map (abfd);
+ elf_seg_map (abfd) = m_overlay;
return TRUE;
}
bed = get_elf_backend_data (abfd);
tdata = elf_tdata (abfd);
phdr = tdata->phdr;
- count = tdata->program_header_size / bed->s->sizeof_phdr;
+ count = elf_program_header_size (abfd) / bed->s->sizeof_phdr;
htab = spu_hash_table (info);
if (htab->num_overlays != 0)
{
struct elf_segment_map *m;
unsigned int o;
- for (i = 0, m = elf_tdata (abfd)->segment_map; m; ++i, m = m->next)
+ for (i = 0, m = elf_seg_map (abfd); m; ++i, m = m->next)
if (m->count != 0
&& (o = spu_elf_section_data (m->sections[0])->u.o.ovl_index) != 0)
{
bfd *ibfd;
size_t size;
- for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
{
asection *isec;
return TRUE;
}
-#define TARGET_BIG_SYM bfd_elf32_spu_vec
+#define TARGET_BIG_SYM spu_elf32_vec
#define TARGET_BIG_NAME "elf32-spu"
#define ELF_ARCH bfd_arch_spu
#define ELF_TARGET_ID SPU_ELF_DATA