array, so it must be declared in the order of that type. */
static reloc_howto_type elf_howto_table[] = {
array, so it must be declared in the order of that type. */
static reloc_howto_type elf_howto_table[] = {
- HOWTO (R_SPU_NONE, 0, 3, 0, FALSE, 0, complain_overflow_dont,
+ HOWTO (R_SPU_NONE, 0, 3, 0, false, 0, complain_overflow_dont,
- FALSE, 0, 0x00000000, FALSE),
- HOWTO (R_SPU_ADDR10, 4, 2, 10, FALSE, 14, complain_overflow_bitfield,
+ false, 0, 0x00000000, false),
+ HOWTO (R_SPU_ADDR10, 4, 2, 10, false, 14, complain_overflow_bitfield,
- FALSE, 0, 0x00ffc000, FALSE),
- HOWTO (R_SPU_ADDR16, 2, 2, 16, FALSE, 7, complain_overflow_bitfield,
+ false, 0, 0x00ffc000, false),
+ HOWTO (R_SPU_ADDR16, 2, 2, 16, false, 7, complain_overflow_bitfield,
- FALSE, 0, 0x007fff80, FALSE),
- HOWTO (R_SPU_ADDR16_HI, 16, 2, 16, FALSE, 7, complain_overflow_bitfield,
+ false, 0, 0x007fff80, false),
+ HOWTO (R_SPU_ADDR16_HI, 16, 2, 16, false, 7, complain_overflow_bitfield,
- FALSE, 0, 0x007fff80, FALSE),
- HOWTO (R_SPU_ADDR16_LO, 0, 2, 16, FALSE, 7, complain_overflow_dont,
+ false, 0, 0x007fff80, false),
+ HOWTO (R_SPU_ADDR16_LO, 0, 2, 16, false, 7, complain_overflow_dont,
- FALSE, 0, 0x007fff80, FALSE),
- HOWTO (R_SPU_ADDR18, 0, 2, 18, FALSE, 7, complain_overflow_bitfield,
+ false, 0, 0x007fff80, false),
+ HOWTO (R_SPU_ADDR18, 0, 2, 18, false, 7, complain_overflow_bitfield,
- FALSE, 0, 0x01ffff80, FALSE),
- HOWTO (R_SPU_ADDR32, 0, 2, 32, FALSE, 0, complain_overflow_dont,
+ false, 0, 0x01ffff80, false),
+ HOWTO (R_SPU_ADDR32, 0, 2, 32, false, 0, complain_overflow_dont,
- FALSE, 0, 0xffffffff, FALSE),
- HOWTO (R_SPU_REL16, 2, 2, 16, TRUE, 7, complain_overflow_bitfield,
+ false, 0, 0xffffffff, false),
+ HOWTO (R_SPU_REL16, 2, 2, 16, true, 7, complain_overflow_bitfield,
- FALSE, 0, 0x007fff80, TRUE),
- HOWTO (R_SPU_ADDR7, 0, 2, 7, FALSE, 14, complain_overflow_dont,
+ false, 0, 0x007fff80, true),
+ HOWTO (R_SPU_ADDR7, 0, 2, 7, false, 14, complain_overflow_dont,
- FALSE, 0, 0x001fc000, FALSE),
- HOWTO (R_SPU_REL9, 2, 2, 9, TRUE, 0, complain_overflow_signed,
+ false, 0, 0x001fc000, false),
+ HOWTO (R_SPU_REL9, 2, 2, 9, true, 0, complain_overflow_signed,
- FALSE, 0, 0x0180007f, TRUE),
- HOWTO (R_SPU_REL9I, 2, 2, 9, TRUE, 0, complain_overflow_signed,
+ false, 0, 0x0180007f, true),
+ HOWTO (R_SPU_REL9I, 2, 2, 9, true, 0, complain_overflow_signed,
- FALSE, 0, 0x0000c07f, TRUE),
- HOWTO (R_SPU_ADDR10I, 0, 2, 10, FALSE, 14, complain_overflow_signed,
+ false, 0, 0x0000c07f, true),
+ HOWTO (R_SPU_ADDR10I, 0, 2, 10, false, 14, complain_overflow_signed,
- FALSE, 0, 0x00ffc000, FALSE),
- HOWTO (R_SPU_ADDR16I, 0, 2, 16, FALSE, 7, complain_overflow_signed,
+ false, 0, 0x00ffc000, false),
+ HOWTO (R_SPU_ADDR16I, 0, 2, 16, false, 7, complain_overflow_signed,
- FALSE, 0, 0x007fff80, FALSE),
- HOWTO (R_SPU_REL32, 0, 2, 32, TRUE, 0, complain_overflow_dont,
+ false, 0, 0x007fff80, false),
+ HOWTO (R_SPU_REL32, 0, 2, 32, true, 0, complain_overflow_dont,
- FALSE, 0, 0xffffffff, TRUE),
- HOWTO (R_SPU_ADDR16X, 0, 2, 16, FALSE, 7, complain_overflow_bitfield,
+ false, 0, 0xffffffff, true),
+ HOWTO (R_SPU_ADDR16X, 0, 2, 16, false, 7, complain_overflow_bitfield,
- FALSE, 0, 0x007fff80, FALSE),
- HOWTO (R_SPU_PPU32, 0, 2, 32, FALSE, 0, complain_overflow_dont,
+ false, 0, 0x007fff80, false),
+ HOWTO (R_SPU_PPU32, 0, 2, 32, false, 0, complain_overflow_dont,
- FALSE, 0, 0xffffffff, FALSE),
- HOWTO (R_SPU_PPU64, 0, 4, 64, FALSE, 0, complain_overflow_dont,
+ false, 0, 0xffffffff, false),
+ HOWTO (R_SPU_PPU64, 0, 4, 64, false, 0, complain_overflow_dont,
- FALSE, 0, -1, FALSE),
- HOWTO (R_SPU_ADD_PIC, 0, 0, 0, FALSE, 0, complain_overflow_dont,
+ false, 0, -1, false),
+ HOWTO (R_SPU_ADD_PIC, 0, 0, 0, false, 0, complain_overflow_dont,
- FALSE, 0, 0x00000000, FALSE),
+ false, 0, 0x00000000, false),
_bfd_error_handler (_("%pB: unsupported relocation type %#x"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
_bfd_error_handler (_("%pB: unsupported relocation type %#x"),
abfd, r_type);
bfd_set_error (bfd_error_bad_value);
to (hash, NULL) for global symbols, and (NULL, sym) for locals. Set
*SYMSECP to the symbol's section. *LOCSYMSP caches local syms. */
to (hash, NULL) for global symbols, and (NULL, sym) for locals. Set
*SYMSECP to the symbol's section. *LOCSYMSP caches local syms. */
}
/* Create the note section if not already present. This is done early so
that the linker maps the sections to the right place in the output. */
}
/* Create the note section if not already present. This is done early so
that the linker maps the sections to the right place in the output. */
spu_elf_create_sections (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
spu_elf_create_sections (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
s = bfd_make_section_anyway_with_flags (ibfd, SPU_PTNOTE_SPUNAME, flags);
if (s == NULL
|| !bfd_set_section_alignment (s, 4))
s = bfd_make_section_anyway_with_flags (ibfd, SPU_PTNOTE_SPUNAME, flags);
if (s == NULL
|| !bfd_set_section_alignment (s, 4))
size += (name_len + 3) & -4;
if (!bfd_set_section_size (s, size))
size += (name_len + 3) & -4;
if (!bfd_set_section_size (s, size))
bfd_put_32 (ibfd, sizeof (SPU_PLUGIN_NAME), data + 0);
bfd_put_32 (ibfd, name_len, data + 4);
bfd_put_32 (ibfd, sizeof (SPU_PLUGIN_NAME), data + 0);
bfd_put_32 (ibfd, name_len, data + 4);
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
s = bfd_make_section_anyway_with_flags (ibfd, ".fixup", flags);
if (s == NULL || !bfd_set_section_alignment (s, 2))
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
s = bfd_make_section_anyway_with_flags (ibfd, ".fixup", flags);
if (s == NULL || !bfd_set_section_alignment (s, 2))
- h = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE);
+ h = elf_link_hash_lookup (&htab->elf, name, true, false, false);
is_indirect_branch (const unsigned char *insn)
{
return (insn[0] & 0xef) == 0x25 && (insn[1] & 0x80) == 0;
is_indirect_branch (const unsigned char *insn)
{
return (insn[0] & 0xef) == 0x25 && (insn[1] & 0x80) == 0;
maybe_needs_stubs (asection *input_section)
{
/* No stubs for debug sections and suchlike. */
if ((input_section->flags & SEC_ALLOC) == 0)
maybe_needs_stubs (asection *input_section)
{
/* No stubs for debug sections and suchlike. */
if ((input_section->flags & SEC_ALLOC) == 0)
/* No stubs for link-once sections that will be discarded. */
if (input_section->output_section == bfd_abs_section_ptr)
/* No stubs for link-once sections that will be discarded. */
if (input_section->output_section == bfd_abs_section_ptr)
/* Don't create stubs for .eh_frame references. */
if (strcmp (input_section->name, ".eh_frame") == 0)
/* Don't create stubs for .eh_frame references. */
if (strcmp (input_section->name, ".eh_frame") == 0)
* sizeof (*elf_local_got_ents (ibfd)));
elf_local_got_ents (ibfd) = bfd_zmalloc (amt);
if (elf_local_got_ents (ibfd) == NULL)
* sizeof (*elf_local_got_ents (ibfd)));
elf_local_got_ents (ibfd) = bfd_zmalloc (amt);
if (elf_local_got_ents (ibfd) == NULL)
- h = elf_link_hash_lookup (&htab->elf, name, TRUE, TRUE, FALSE);
+ h = elf_link_hash_lookup (&htab->elf, name, true, true, false);
allocate_spuear_stubs (struct elf_link_hash_entry *h, void *inf)
{
/* Symbols starting with _SPUEAR_ need a stub because they may be
allocate_spuear_stubs (struct elf_link_hash_entry *h, void *inf)
{
/* Symbols starting with _SPUEAR_ need a stub because they may be
return count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
}
return count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
}
build_spuear_stubs (struct elf_link_hash_entry *h, void *inf)
{
/* Symbols starting with _SPUEAR_ need a stub because they may be
build_spuear_stubs (struct elf_link_hash_entry *h, void *inf)
{
/* Symbols starting with _SPUEAR_ need a stub because they may be
spu_elf_open_builtin_lib (bfd **ovl_bfd, const struct _ovl_stream *stream)
{
*ovl_bfd = bfd_openr_iovec ("builtin ovl_mgr",
spu_elf_open_builtin_lib (bfd **ovl_bfd, const struct _ovl_stream *stream)
{
*ovl_bfd = bfd_openr_iovec ("builtin ovl_mgr",
- h = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE);
+ h = elf_link_hash_lookup (&htab->elf, name, true, false, false);
spu_elf_build_stubs (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
spu_elf_build_stubs (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
_bfd_error_handler (_("%s in overlay section"),
h->root.root.string);
bfd_set_error (bfd_error_bad_value);
_bfd_error_handler (_("%s in overlay section"),
h->root.root.string);
bfd_set_error (bfd_error_bad_value);
htab->stub_sec[i]->contents = bfd_zalloc (htab->stub_sec[i]->owner,
htab->stub_sec[i]->size);
if (htab->stub_sec[i]->contents == NULL)
htab->stub_sec[i]->contents = bfd_zalloc (htab->stub_sec[i]->owner,
htab->stub_sec[i]->size);
if (htab->stub_sec[i]->contents == NULL)
htab->stub_sec[i]->rawsize = htab->stub_sec[i]->size;
htab->stub_sec[i]->size = 0;
}
/* Fill in all the stubs. */
htab->stub_sec[i]->rawsize = htab->stub_sec[i]->size;
htab->stub_sec[i]->size = 0;
}
/* Fill in all the stubs. */
htab->ovtab->contents = bfd_zalloc (htab->ovtab->owner, htab->ovtab->size);
if (htab->ovtab->contents == NULL)
htab->ovtab->contents = bfd_zalloc (htab->ovtab->owner, htab->ovtab->size);
if (htab->ovtab->contents == NULL)
h->root.u.def.value = 0;
h->size = 16 << htab->num_lines_log2;
off = h->size;
h = define_ovtab_symbol (htab, "__icache_tag_array_size");
if (h == NULL)
h->root.u.def.value = 0;
h->size = 16 << htab->num_lines_log2;
off = h->size;
h = define_ovtab_symbol (htab, "__icache_tag_array_size");
if (h == NULL)
h->root.u.def.value = 16 << htab->num_lines_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_rewrite_to");
if (h == NULL)
h->root.u.def.value = 16 << htab->num_lines_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_rewrite_to");
if (h == NULL)
h->root.u.def.value = off;
h->size = 16 << htab->num_lines_log2;
off += h->size;
h = define_ovtab_symbol (htab, "__icache_rewrite_to_size");
if (h == NULL)
h->root.u.def.value = off;
h->size = 16 << htab->num_lines_log2;
off += h->size;
h = define_ovtab_symbol (htab, "__icache_rewrite_to_size");
if (h == NULL)
h->root.u.def.value = 16 << htab->num_lines_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_rewrite_from");
if (h == NULL)
h->root.u.def.value = 16 << htab->num_lines_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_rewrite_from");
if (h == NULL)
h->root.u.def.value = off;
h->size = 16 << (htab->fromelem_size_log2 + htab->num_lines_log2);
off += h->size;
h = define_ovtab_symbol (htab, "__icache_rewrite_from_size");
if (h == NULL)
h->root.u.def.value = off;
h->size = 16 << (htab->fromelem_size_log2 + htab->num_lines_log2);
off += h->size;
h = define_ovtab_symbol (htab, "__icache_rewrite_from_size");
if (h == NULL)
h->root.u.def.value = 16 << (htab->fromelem_size_log2
+ htab->num_lines_log2);
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_fromelemsize");
if (h == NULL)
h->root.u.def.value = 16 << (htab->fromelem_size_log2
+ htab->num_lines_log2);
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_fromelemsize");
if (h == NULL)
h->root.u.def.value = htab->fromelem_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_base");
if (h == NULL)
h->root.u.def.value = htab->fromelem_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_base");
if (h == NULL)
h->root.u.def.value = htab->ovl_sec[0]->vma;
h->root.u.def.section = bfd_abs_section_ptr;
h->size = htab->num_buf << htab->line_size_log2;
h = define_ovtab_symbol (htab, "__icache_linesize");
if (h == NULL)
h->root.u.def.value = htab->ovl_sec[0]->vma;
h->root.u.def.section = bfd_abs_section_ptr;
h->size = htab->num_buf << htab->line_size_log2;
h = define_ovtab_symbol (htab, "__icache_linesize");
if (h == NULL)
h->root.u.def.value = 1 << htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_linesize");
if (h == NULL)
h->root.u.def.value = 1 << htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_linesize");
if (h == NULL)
h->root.u.def.value = htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_neg_log2_linesize");
if (h == NULL)
h->root.u.def.value = htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_neg_log2_linesize");
if (h == NULL)
h->root.u.def.value = -htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_cachesize");
if (h == NULL)
h->root.u.def.value = -htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_cachesize");
if (h == NULL)
h->root.u.def.value = 1 << (htab->num_lines_log2 + htab->line_size_log2);
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_cachesize");
if (h == NULL)
h->root.u.def.value = 1 << (htab->num_lines_log2 + htab->line_size_log2);
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_log2_cachesize");
if (h == NULL)
h->root.u.def.value = htab->num_lines_log2 + htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_neg_log2_cachesize");
if (h == NULL)
h->root.u.def.value = htab->num_lines_log2 + htab->line_size_log2;
h->root.u.def.section = bfd_abs_section_ptr;
h = define_ovtab_symbol (htab, "__icache_neg_log2_cachesize");
if (h == NULL)
h->root.u.def.value = -(htab->num_lines_log2 + htab->line_size_log2);
h->root.u.def.section = bfd_abs_section_ptr;
h->root.u.def.value = -(htab->num_lines_log2 + htab->line_size_log2);
h->root.u.def.section = bfd_abs_section_ptr;
htab->init->contents = bfd_zalloc (htab->init->owner,
htab->init->size);
if (htab->init->contents == NULL)
htab->init->contents = bfd_zalloc (htab->init->owner,
htab->init->size);
if (htab->init->contents == NULL)
h->root.u.def.value = 16;
h->size = htab->num_overlays * 16;
h = define_ovtab_symbol (htab, "_ovly_table_end");
if (h == NULL)
h->root.u.def.value = 16;
h->size = htab->num_overlays * 16;
h = define_ovtab_symbol (htab, "_ovly_table_end");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16;
h->size = 0;
h = define_ovtab_symbol (htab, "_ovly_buf_table");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16;
h->size = 0;
h = define_ovtab_symbol (htab, "_ovly_buf_table");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16;
h->size = htab->num_buf * 4;
h = define_ovtab_symbol (htab, "_ovly_buf_table_end");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16;
h->size = htab->num_buf * 4;
h = define_ovtab_symbol (htab, "_ovly_buf_table_end");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16 + htab->num_buf * 4;
h->size = 0;
}
h = define_ovtab_symbol (htab, "_EAR_");
if (h == NULL)
h->root.u.def.value = htab->num_overlays * 16 + 16 + htab->num_buf * 4;
h->size = 0;
}
h = define_ovtab_symbol (htab, "_EAR_");
if (h == NULL)
static struct function_info *
maybe_insert_function (asection *sec,
void *sym_h,
static struct function_info *
maybe_insert_function (asection *sec,
void *sym_h,
{
struct _spu_elf_section_data *sec_data = spu_elf_section_data (sec);
struct spu_elf_stack_info *sinfo = sec_data->u.i.stack_info;
{
struct _spu_elf_section_data *sec_data = spu_elf_section_data (sec);
struct spu_elf_stack_info *sinfo = sec_data->u.i.stack_info;
/* Read the instruction at OFF in SEC. Return true iff the instruction
is a nop, lnop, or stop 0 (all zero insn). */
/* Read the instruction at OFF in SEC. Return true iff the instruction
is a nop, lnop, or stop 0 (all zero insn). */
is_nop (asection *sec, bfd_vma off)
{
unsigned char insn[4];
if (off + 4 > sec->size
|| !bfd_get_section_contents (sec->owner, sec, insn, off, 4))
is_nop (asection *sec, bfd_vma off)
{
unsigned char insn[4];
if (off + 4 > sec->size
|| !bfd_get_section_contents (sec->owner, sec, insn, off, 4))
}
/* Extend the range of FUN to cover nop padding up to LIMIT.
Return TRUE iff some instruction other than a NOP was found. */
}
/* Extend the range of FUN to cover nop padding up to LIMIT.
Return TRUE iff some instruction other than a NOP was found. */
insns_at_end (struct function_info *fun, bfd_vma limit)
{
bfd_vma off = (fun->hi + 3) & -4;
insns_at_end (struct function_info *fun, bfd_vma limit)
{
bfd_vma off = (fun->hi + 3) & -4;
}
/* Check and fix overlapping function ranges. Return TRUE iff there
are gaps in the current info we have about functions in SEC. */
}
/* Check and fix overlapping function ranges. Return TRUE iff there
are gaps in the current info we have about functions in SEC. */
check_function_ranges (asection *sec, struct bfd_link_info *info)
{
struct _spu_elf_section_data *sec_data = spu_elf_section_data (sec);
struct spu_elf_stack_info *sinfo = sec_data->u.i.stack_info;
int i;
check_function_ranges (asection *sec, struct bfd_link_info *info)
{
struct _spu_elf_section_data *sec_data = spu_elf_section_data (sec);
struct spu_elf_stack_info *sinfo = sec_data->u.i.stack_info;
int i;
sinfo->fun[i - 1].hi = sinfo->fun[i].lo;
}
else if (insns_at_end (&sinfo->fun[i - 1], sinfo->fun[i].lo))
sinfo->fun[i - 1].hi = sinfo->fun[i].lo;
}
else if (insns_at_end (&sinfo->fun[i - 1], sinfo->fun[i].lo))
if (sinfo->fun[sinfo->num_fun - 1].hi > sec->size)
{
const char *f1 = func_name (&sinfo->fun[sinfo->num_fun - 1]);
if (sinfo->fun[sinfo->num_fun - 1].hi > sec->size)
{
const char *f1 = func_name (&sinfo->fun[sinfo->num_fun - 1]);
sinfo->fun[sinfo->num_fun - 1].hi = sec->size;
}
else if (insns_at_end (&sinfo->fun[sinfo->num_fun - 1], sec->size))
sinfo->fun[sinfo->num_fun - 1].hi = sec->size;
}
else if (insns_at_end (&sinfo->fun[sinfo->num_fun - 1], sec->size))
insert_callee (struct function_info *caller, struct call_info *callee)
{
struct call_info **pp, *p;
insert_callee (struct function_info *caller, struct call_info *callee)
{
struct call_info **pp, *p;
}
p->count += callee->count;
/* Reorder list so most recent call is first. */
*pp = p->next;
p->next = caller->call_list;
caller->call_list = p;
}
p->count += callee->count;
/* Reorder list so most recent call is first. */
*pp = p->next;
p->next = caller->call_list;
caller->call_list = p;
copy_callee (struct function_info *caller, const struct call_info *call)
{
struct call_info *callee;
callee = bfd_malloc (sizeof (*callee));
if (callee == NULL)
copy_callee (struct function_info *caller, const struct call_info *call)
{
struct call_info *callee;
callee = bfd_malloc (sizeof (*callee));
if (callee == NULL)
look at branches, which may be tail calls or go to hot/cold
section part of same function. */
look at branches, which may be tail calls or go to hot/cold
section part of same function. */
mark_functions_via_relocs (asection *sec,
struct bfd_link_info *info,
int call_tree)
mark_functions_via_relocs (asection *sec,
struct bfd_link_info *info,
int call_tree)
internal_relocs = _bfd_elf_link_read_relocs (sec->owner, sec, NULL, NULL,
info->keep_memory);
if (internal_relocs == NULL)
internal_relocs = _bfd_elf_link_read_relocs (sec->owner, sec, NULL, NULL,
info->keep_memory);
if (internal_relocs == NULL)
r_indx = ELF32_R_SYM (irela->r_info);
if (!get_sym_h (&h, &sym, &sym_sec, psyms, r_indx, sec->owner))
r_indx = ELF32_R_SYM (irela->r_info);
if (!get_sym_h (&h, &sym, &sym_sec, psyms, r_indx, sec->owner))
if (!nonbranch)
{
unsigned char insn[4];
if (!bfd_get_section_contents (sec->owner, sec, insn,
irela->r_offset, 4))
if (!nonbranch)
{
unsigned char insn[4];
if (!bfd_get_section_contents (sec->owner, sec, insn,
irela->r_offset, 4))
" %pB(%pA), analysis incomplete\n"),
sec->owner, sec, irela->r_offset,
sym_sec->owner, sym_sec);
" %pB(%pA), analysis incomplete\n"),
sec->owner, sec, irela->r_offset,
sym_sec->owner, sym_sec);
- fun = maybe_insert_function (sym_sec, sym, FALSE, is_call);
+ fun = maybe_insert_function (sym_sec, sym, false, is_call);
- fun = maybe_insert_function (sym_sec, h, TRUE, is_call);
+ fun = maybe_insert_function (sym_sec, h, true, is_call);
callee->priority = priority;
callee->count = nonbranch? 0 : 1;
if (callee->fun->last_caller != sec)
callee->priority = priority;
callee->count = nonbranch? 0 : 1;
if (callee->fun->last_caller != sec)
}
/* Handle something like .init or .fini, which has a piece of a function.
These sections are pasted together to form a single function. */
}
/* Handle something like .init or .fini, which has a piece of a function.
These sections are pasted together to form a single function. */
fake->st_value = 0;
fake->st_size = sec->size;
fake->st_shndx
= _bfd_elf_section_from_bfd_section (sec->owner, sec);
fake->st_value = 0;
fake->st_size = sec->size;
fake->st_shndx
= _bfd_elf_section_from_bfd_section (sec->owner, sec);
- fun = maybe_insert_function (sec, fake, FALSE, FALSE);
+ fun = maybe_insert_function (sec, fake, false, false);
- callee->is_tail = TRUE;
- callee->is_pasted = TRUE;
- callee->broken_cycle = FALSE;
+ callee->is_tail = true;
+ callee->is_pasted = true;
+ callee->broken_cycle = false;
/* Don't return an error if we did not find a function preceding this
section. The section may have incorrect flags. */
/* Don't return an error if we did not find a function preceding this
section. The section may have incorrect flags. */
/* Select defined function symbols that are going to be output. */
psyms = bfd_malloc ((symcount + 1) * sizeof (*psyms));
if (psyms == NULL)
/* Select defined function symbols that are going to be output. */
psyms = bfd_malloc ((symcount + 1) * sizeof (*psyms));
if (psyms == NULL)
sec_arr[bfd_idx] = psecs;
for (psy = psyms, p = psecs, sy = syms; sy < syms + symcount; ++p, ++sy)
if (ELF_ST_TYPE (sy->st_info) == STT_NOTYPE
sec_arr[bfd_idx] = psecs;
for (psy = psyms, p = psecs, sy = syms; sy < syms + symcount; ++p, ++sy)
if (ELF_ST_TYPE (sy->st_info) == STT_NOTYPE
- if (!maybe_insert_function (s, sy, FALSE, TRUE))
- return FALSE;
+ if (!maybe_insert_function (s, sy, false, true))
+ return false;
for (sec = ibfd->sections; sec != NULL && !gaps; sec = sec->next)
if (interesting_section (sec))
gaps |= check_function_ranges (sec, info);
for (sec = ibfd->sections; sec != NULL && !gaps; sec = sec->next)
if (interesting_section (sec))
gaps |= check_function_ranges (sec, info);
- if (!maybe_insert_function (s, sy, FALSE, FALSE))
- return FALSE;
+ if (!maybe_insert_function (s, sy, false, false))
+ return false;
}
/* Iterate over all function_info we have collected, calling DOIT on
each node if ROOT_ONLY is false. Only call DOIT on root nodes
if ROOT_ONLY. */
}
/* Iterate over all function_info we have collected, calling DOIT on
each node if ROOT_ONLY is false. Only call DOIT on root nodes
if ROOT_ONLY. */
-static bfd_boolean
-for_each_node (bfd_boolean (*doit) (struct function_info *,
- struct bfd_link_info *,
- void *),
+static bool
+for_each_node (bool (*doit) (struct function_info *,
+ struct bfd_link_info *,
+ void *),
for (i = 0; i < sinfo->num_fun; ++i)
if (!root_only || !sinfo->fun[i].non_root)
if (!doit (&sinfo->fun[i], info, param))
for (i = 0; i < sinfo->num_fun; ++i)
if (!root_only || !sinfo->fun[i].non_root)
if (!doit (&sinfo->fun[i], info, param))
}
/* Transfer call info attached to struct function_info entries for
all of a given function's sections to the first entry. */
}
/* Transfer call info attached to struct function_info entries for
all of a given function's sections to the first entry. */
transfer_calls (struct function_info *fun,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
void *param ATTRIBUTE_UNUSED)
transfer_calls (struct function_info *fun,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
void *param ATTRIBUTE_UNUSED)
mark_non_root (struct function_info *fun,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
void *param ATTRIBUTE_UNUSED)
mark_non_root (struct function_info *fun,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
void *param ATTRIBUTE_UNUSED)
remove_cycles (struct function_info *fun,
struct bfd_link_info *info,
void *param)
remove_cycles (struct function_info *fun,
struct bfd_link_info *info,
void *param)
mark_detached_root (struct function_info *fun,
struct bfd_link_info *info,
void *param)
{
if (fun->visit2)
mark_detached_root (struct function_info *fun,
struct bfd_link_info *info,
void *param)
{
if (fun->visit2)
*(unsigned int *) param = 0;
return remove_cycles (fun, info, param);
}
/* Populate call_list for each function. */
*(unsigned int *) param = 0;
return remove_cycles (fun, info, param);
}
/* Populate call_list for each function. */
}
/* Transfer call info from hot/cold section part of function
to main entry. */
if (!spu_hash_table (info)->params->auto_overlay
}
/* Transfer call info from hot/cold section part of function
to main entry. */
if (!spu_hash_table (info)->params->auto_overlay
- && !for_each_node (transfer_calls, info, 0, FALSE))
- return FALSE;
+ && !for_each_node (transfer_calls, info, 0, false))
+ return false;
- if (!for_each_node (mark_non_root, info, 0, FALSE))
- return FALSE;
+ if (!for_each_node (mark_non_root, info, 0, false))
+ return false;
/* Remove cycles from the call graph. We start from the root node(s)
so that we break cycles in a reasonable place. */
depth = 0;
/* Remove cycles from the call graph. We start from the root node(s)
so that we break cycles in a reasonable place. */
depth = 0;
- if (!for_each_node (remove_cycles, info, &depth, TRUE))
- return FALSE;
+ if (!for_each_node (remove_cycles, info, &depth, true))
+ return false;
- return for_each_node (mark_detached_root, info, &depth, FALSE);
+ return for_each_node (mark_detached_root, info, &depth, false);
mark_overlay_section (struct function_info *fun,
struct bfd_link_info *info,
void *param)
mark_overlay_section (struct function_info *fun,
struct bfd_link_info *info,
void *param)
if (!fun->sec->linker_mark
&& (htab->params->ovly_flavour != ovly_soft_icache
|| htab->params->non_ia_text
if (!fun->sec->linker_mark
&& (htab->params->ovly_flavour != ovly_soft_icache
|| htab->params->non_ia_text
memcpy (name, ".rodata", sizeof (".rodata"));
}
else if (strncmp (fun->sec->name, ".text.", 6) == 0)
memcpy (name, ".rodata", sizeof (".rodata"));
}
else if (strncmp (fun->sec->name, ".text.", 6) == 0)
memcpy (name, ".rodata", sizeof (".rodata"));
memcpy (name + 7, fun->sec->name + 5, len - 4);
}
memcpy (name, ".rodata", sizeof (".rodata"));
memcpy (name + 7, fun->sec->name + 5, len - 4);
}
unmark_overlay_section (struct function_info *fun,
struct bfd_link_info *info,
void *param)
unmark_overlay_section (struct function_info *fun,
struct bfd_link_info *info,
void *param)
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->broken_cycle
&& !unmark_overlay_section (call->fun, info, param))
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->broken_cycle
&& !unmark_overlay_section (call->fun, info, param))
for consideration as non-overlay sections. The array consist of
pairs of sections, (text,rodata), for functions in the call graph. */
for consideration as non-overlay sections. The array consist of
pairs of sections, (text,rodata), for functions in the call graph. */
collect_lib_sections (struct function_info *fun,
struct bfd_link_info *info,
void *param)
collect_lib_sections (struct function_info *fun,
struct bfd_link_info *info,
void *param)
collect_lib_param.lib_size = lib_size;
collect_lib_param.lib_sections = lib_sections;
if (!for_each_node (collect_lib_sections, info, &collect_lib_param,
collect_lib_param.lib_size = lib_size;
collect_lib_param.lib_sections = lib_sections;
if (!for_each_node (collect_lib_sections, info, &collect_lib_param,
from the parent section. The idea being to group sections to
minimise calls between different overlays. */
from the parent section. The idea being to group sections to
minimise calls between different overlays. */
collect_overlays (struct function_info *fun,
struct bfd_link_info *info,
void *param)
{
struct call_info *call;
collect_overlays (struct function_info *fun,
struct bfd_link_info *info,
void *param)
{
struct call_info *call;
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->is_pasted && !call->broken_cycle)
{
if (!collect_overlays (call->fun, info, ovly_sections))
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->is_pasted && !call->broken_cycle)
{
if (!collect_overlays (call->fun, info, ovly_sections))
/* Pasted sections must stay with the first section. We don't
put pasted sections in the array, just the first section.
/* Pasted sections must stay with the first section. We don't
put pasted sections in the array, just the first section.
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->broken_cycle
&& !collect_overlays (call->fun, info, ovly_sections))
for (call = fun->call_list; call != NULL; call = call->next)
if (!call->broken_cycle
&& !collect_overlays (call->fun, info, ovly_sections))
int i;
for (i = 0; i < sinfo->num_fun; ++i)
if (!collect_overlays (&sinfo->fun[i], info, ovly_sections))
int i;
for (i = 0; i < sinfo->num_fun; ++i)
if (!collect_overlays (&sinfo->fun[i], info, ovly_sections))
sum_stack (struct function_info *fun,
struct bfd_link_info *info,
void *param)
sum_stack (struct function_info *fun,
struct bfd_link_info *info,
void *param)
struct _sum_stack_param *sum_stack_param = param;
struct spu_link_hash_table *htab;
cum_stack = fun->stack;
sum_stack_param->cum_stack = cum_stack;
if (fun->visit3)
struct _sum_stack_param *sum_stack_param = param;
struct spu_link_hash_table *htab;
cum_stack = fun->stack;
sum_stack_param->cum_stack = cum_stack;
if (fun->visit3)
stack = sum_stack_param->cum_stack;
/* Include caller stack for normal calls, don't do so for
tail calls. fun->stack here is local stack usage for
stack = sum_stack_param->cum_stack;
/* Include caller stack for normal calls, don't do so for
tail calls. fun->stack here is local stack usage for
if (fun->global || ELF_ST_BIND (fun->u.sym->st_info) == STB_GLOBAL)
sprintf (name, "__stack_%s", f1);
else
sprintf (name, "__stack_%x_%s", fun->sec->id & 0xffffffff, f1);
if (fun->global || ELF_ST_BIND (fun->u.sym->st_info) == STB_GLOBAL)
sprintf (name, "__stack_%s", f1);
else
sprintf (name, "__stack_%x_%s", fun->sec->id & 0xffffffff, f1);
- h = elf_link_hash_lookup (&htab->elf, name, TRUE, TRUE, FALSE);
+ h = elf_link_hash_lookup (&htab->elf, name, true, true, false);
- if (!for_each_node (sum_stack, info, &sum_stack_param, TRUE))
+ if (!for_each_node (sum_stack, info, &sum_stack_param, true))
if (htab->params->ovly_flavour == ovly_soft_icache)
ovly_mgr_entry = "__icache_br_handler";
h = elf_link_hash_lookup (&htab->elf, ovly_mgr_entry,
if (htab->params->ovly_flavour == ovly_soft_icache)
ovly_mgr_entry = "__icache_br_handler";
h = elf_link_hash_lookup (&htab->elf, ovly_mgr_entry,
/* Mark overlay sections, and find max overlay section size. */
mos_param.max_overlay_size = 0;
/* Mark overlay sections, and find max overlay section size. */
mos_param.max_overlay_size = 0;
- if (!for_each_node (mark_overlay_section, info, &mos_param, TRUE))
+ if (!for_each_node (mark_overlay_section, info, &mos_param, true))
- && !for_each_node (unmark_overlay_section, info, &uos_param, TRUE))
+ && !for_each_node (unmark_overlay_section, info, &uos_param, true))
qsort (bfd_arr, bfd_count, sizeof (*bfd_arr), sort_bfds);
for (i = 1; i < bfd_count; ++i)
qsort (bfd_arr, bfd_count, sizeof (*bfd_arr), sort_bfds);
for (i = 1; i < bfd_count; ++i)
else
info->callbacks->einfo (_("%s duplicated\n"),
bfd_get_filename (bfd_arr[i]));
else
info->callbacks->einfo (_("%s duplicated\n"),
bfd_get_filename (bfd_arr[i]));
- if (!for_each_node (collect_overlays, info, &ovly_p, TRUE))
+ if (!for_each_node (collect_overlays, info, &ovly_p, true))
spu_elf_stack_analysis (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab;
struct _sum_stack_param sum_stack_param;
if (!discover_functions (info))
spu_elf_stack_analysis (struct bfd_link_info *info)
{
struct spu_link_hash_table *htab;
struct _sum_stack_param sum_stack_param;
if (!discover_functions (info))
- if (!for_each_node (sum_stack, info, &sum_stack_param, TRUE))
- return FALSE;
+ if (!for_each_node (sum_stack, info, &sum_stack_param, true))
+ return false;
if (htab->params->stack_analysis)
info->callbacks->info (_("Maximum stack required is 0x%v\n"),
(bfd_vma) sum_stack_param.overall_stack);
if (htab->params->stack_analysis)
info->callbacks->info (_("Maximum stack required is 0x%v\n"),
(bfd_vma) sum_stack_param.overall_stack);
spu_elf_final_link (bfd *output_bfd, struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
spu_elf_final_link (bfd *output_bfd, struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
Elf_Internal_Rela *rel, *relend;
struct spu_link_hash_table *htab;
asection *ea;
Elf_Internal_Rela *rel, *relend;
struct spu_link_hash_table *htab;
asection *ea;
enum _stub_type stub_type;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
howto = elf_howto_table + r_type;
enum _stub_type stub_type;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
howto = elf_howto_table + r_type;
+ elf_section_data (ea)->this_hdr.sh_offset);
rel->r_info = ELF32_R_INFO (0, r_type);
}
+ elf_section_data (ea)->this_hdr.sh_offset);
rel->r_info = ELF32_R_INFO (0, r_type);
}
if (unresolved_reloc
&& _bfd_elf_section_offset (output_bfd, info, input_section,
if (unresolved_reloc
&& _bfd_elf_section_offset (output_bfd, info, input_section,
- (info, sym_name, input_bfd, input_section, rel->r_offset, TRUE);
+ (info, sym_name, input_bfd, input_section, rel->r_offset, true);
(*info->callbacks->warning) (info, msg, sym_name, input_bfd,
input_section, rel->r_offset);
break;
(*info->callbacks->warning) (info, msg, sym_name, input_bfd,
input_section, rel->r_offset);
break;
spu_elf_finish_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
spu_elf_finish_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
spu_elf_init_file_header (bfd *abfd, struct bfd_link_info *info)
{
if (!_bfd_elf_init_file_header (abfd, info))
spu_elf_init_file_header (bfd *abfd, struct bfd_link_info *info)
{
if (!_bfd_elf_init_file_header (abfd, info))
/* Remove .toe section from other PT_LOAD segments and put it in
a segment of its own. Put overlays in separate segments too. */
/* Remove .toe section from other PT_LOAD segments and put it in
a segment of its own. Put overlays in separate segments too. */
toe = bfd_get_section_by_name (abfd, ".toe");
for (m = elf_seg_map (abfd); m != NULL; m = m->next)
toe = bfd_get_section_by_name (abfd, ".toe");
for (m = elf_seg_map (abfd); m != NULL; m = m->next)
amt += (m->count - (i + 2)) * sizeof (m->sections[0]);
m2 = bfd_zalloc (abfd, amt);
if (m2 == NULL)
amt += (m->count - (i + 2)) * sizeof (m->sections[0]);
m2 = bfd_zalloc (abfd, amt);
if (m2 == NULL)
m2->count = m->count - (i + 1);
memcpy (m2->sections, m->sections + i + 1,
m2->count * sizeof (m->sections[0]));
m2->count = m->count - (i + 1);
memcpy (m2->sections, m->sections + i + 1,
m2->count * sizeof (m->sections[0]));
amt = sizeof (struct elf_segment_map);
m2 = bfd_zalloc (abfd, amt);
if (m2 == NULL)
amt = sizeof (struct elf_segment_map);
m2 = bfd_zalloc (abfd, amt);
if (m2 == NULL)
spu_elf_fake_sections (bfd *obfd ATTRIBUTE_UNUSED,
Elf_Internal_Shdr *hdr,
asection *sec)
{
if (strcmp (sec->name, SPU_PTNOTE_SPUNAME) == 0)
hdr->sh_type = SHT_NOTE;
spu_elf_fake_sections (bfd *obfd ATTRIBUTE_UNUSED,
Elf_Internal_Shdr *hdr,
asection *sec)
{
if (strcmp (sec->name, SPU_PTNOTE_SPUNAME) == 0)
hdr->sh_type = SHT_NOTE;
spu_elf_size_sections (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
spu_elf_size_sections (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info)
{
struct spu_link_hash_table *htab = spu_hash_table (info);
_bfd_elf_link_read_relocs (ibfd, isec, NULL, NULL,
info->keep_memory);
if (internal_relocs == NULL)
_bfd_elf_link_read_relocs (ibfd, isec, NULL, NULL,
info->keep_memory);
if (internal_relocs == NULL)
/* We always have a NULL fixup as a sentinel */
size = (fixup_count + 1) * FIXUP_RECORD_SIZE;
if (!bfd_set_section_size (sfixup, size))
/* We always have a NULL fixup as a sentinel */
size = (fixup_count + 1) * FIXUP_RECORD_SIZE;
if (!bfd_set_section_size (sfixup, size))
sfixup->contents = (bfd_byte *) bfd_zalloc (info->input_bfds, size);
if (sfixup->contents == NULL)
sfixup->contents = (bfd_byte *) bfd_zalloc (info->input_bfds, size);
if (sfixup->contents == NULL)