X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-spu.c;h=983989081aeb755edaead2456cfc1a93f561af91;hb=1d5bcf8d88cd8bd22fe3f020435834f7d28b034b;hp=e304b55147dc2ea1f3af13c7cacb77d044e0d1d3;hpb=1a72702bb30ec3f94627cfcae684823b413f20b9;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index e304b55147..983989081a 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -1,6 +1,6 @@ /* SPU specific support for 32-bit ELF - Copyright (C) 2006-2016 Free Software Foundation, Inc. + Copyright (C) 2006-2020 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -27,6 +27,9 @@ #include "elf/spu.h" #include "elf32-spu.h" +/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */ +#define OCTETS_PER_BYTE(ABFD, SEC) 1 + /* We use RELA style relocs. Don't define USE_REL. */ static bfd_reloc_status_type spu_elf_rel9 (bfd *, arelent *, asymbol *, @@ -37,13 +40,13 @@ static bfd_reloc_status_type spu_elf_rel9 (bfd *, arelent *, asymbol *, 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, bfd_elf_generic_reloc, "SPU_NONE", FALSE, 0, 0x00000000, FALSE), - HOWTO (R_SPU_ADDR10, 4, 2, 10, FALSE, 14, complain_overflow_bitfield, + HOWTO (R_SPU_ADDR10, 4, 2, 10, FALSE, 14, complain_overflow_bitfield, bfd_elf_generic_reloc, "SPU_ADDR10", FALSE, 0, 0x00ffc000, FALSE), - HOWTO (R_SPU_ADDR16, 2, 2, 16, FALSE, 7, complain_overflow_bitfield, + HOWTO (R_SPU_ADDR16, 2, 2, 16, FALSE, 7, complain_overflow_bitfield, bfd_elf_generic_reloc, "SPU_ADDR16", FALSE, 0, 0x007fff80, FALSE), HOWTO (R_SPU_ADDR16_HI, 16, 2, 16, FALSE, 7, complain_overflow_bitfield, @@ -52,43 +55,43 @@ static reloc_howto_type elf_howto_table[] = { HOWTO (R_SPU_ADDR16_LO, 0, 2, 16, FALSE, 7, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_ADDR16_LO", FALSE, 0, 0x007fff80, FALSE), - HOWTO (R_SPU_ADDR18, 0, 2, 18, FALSE, 7, complain_overflow_bitfield, + HOWTO (R_SPU_ADDR18, 0, 2, 18, FALSE, 7, complain_overflow_bitfield, bfd_elf_generic_reloc, "SPU_ADDR18", FALSE, 0, 0x01ffff80, FALSE), - HOWTO (R_SPU_ADDR32, 0, 2, 32, FALSE, 0, complain_overflow_dont, + HOWTO (R_SPU_ADDR32, 0, 2, 32, FALSE, 0, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_ADDR32", FALSE, 0, 0xffffffff, FALSE), - HOWTO (R_SPU_REL16, 2, 2, 16, TRUE, 7, complain_overflow_bitfield, + HOWTO (R_SPU_REL16, 2, 2, 16, TRUE, 7, complain_overflow_bitfield, bfd_elf_generic_reloc, "SPU_REL16", FALSE, 0, 0x007fff80, TRUE), - HOWTO (R_SPU_ADDR7, 0, 2, 7, FALSE, 14, complain_overflow_dont, + HOWTO (R_SPU_ADDR7, 0, 2, 7, FALSE, 14, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_ADDR7", FALSE, 0, 0x001fc000, FALSE), - HOWTO (R_SPU_REL9, 2, 2, 9, TRUE, 0, complain_overflow_signed, - spu_elf_rel9, "SPU_REL9", + HOWTO (R_SPU_REL9, 2, 2, 9, TRUE, 0, complain_overflow_signed, + spu_elf_rel9, "SPU_REL9", FALSE, 0, 0x0180007f, TRUE), - HOWTO (R_SPU_REL9I, 2, 2, 9, TRUE, 0, complain_overflow_signed, - spu_elf_rel9, "SPU_REL9I", + HOWTO (R_SPU_REL9I, 2, 2, 9, TRUE, 0, complain_overflow_signed, + spu_elf_rel9, "SPU_REL9I", FALSE, 0, 0x0000c07f, TRUE), - HOWTO (R_SPU_ADDR10I, 0, 2, 10, FALSE, 14, complain_overflow_signed, + HOWTO (R_SPU_ADDR10I, 0, 2, 10, FALSE, 14, complain_overflow_signed, bfd_elf_generic_reloc, "SPU_ADDR10I", FALSE, 0, 0x00ffc000, FALSE), - HOWTO (R_SPU_ADDR16I, 0, 2, 16, FALSE, 7, complain_overflow_signed, + HOWTO (R_SPU_ADDR16I, 0, 2, 16, FALSE, 7, complain_overflow_signed, bfd_elf_generic_reloc, "SPU_ADDR16I", FALSE, 0, 0x007fff80, FALSE), - HOWTO (R_SPU_REL32, 0, 2, 32, TRUE, 0, complain_overflow_dont, + HOWTO (R_SPU_REL32, 0, 2, 32, TRUE, 0, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_REL32", FALSE, 0, 0xffffffff, TRUE), - HOWTO (R_SPU_ADDR16X, 0, 2, 16, FALSE, 7, complain_overflow_bitfield, + HOWTO (R_SPU_ADDR16X, 0, 2, 16, FALSE, 7, complain_overflow_bitfield, bfd_elf_generic_reloc, "SPU_ADDR16X", FALSE, 0, 0x007fff80, FALSE), - HOWTO (R_SPU_PPU32, 0, 2, 32, FALSE, 0, complain_overflow_dont, + HOWTO (R_SPU_PPU32, 0, 2, 32, FALSE, 0, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_PPU32", FALSE, 0, 0xffffffff, FALSE), - HOWTO (R_SPU_PPU64, 0, 4, 64, FALSE, 0, complain_overflow_dont, + HOWTO (R_SPU_PPU64, 0, 4, 64, FALSE, 0, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_PPU64", FALSE, 0, -1, FALSE), - HOWTO (R_SPU_ADD_PIC, 0, 0, 0, FALSE, 0, complain_overflow_dont, + HOWTO (R_SPU_ADD_PIC, 0, 0, 0, FALSE, 0, complain_overflow_dont, bfd_elf_generic_reloc, "SPU_ADD_PIC", FALSE, 0, 0x00000000, FALSE), }; @@ -145,8 +148,8 @@ spu_elf_bfd_to_reloc_type (bfd_reloc_code_real_type code) } } -static void -spu_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +spu_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -156,12 +159,14 @@ spu_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, /* PR 17512: file: 90c2a92e. */ if (r_type >= R_SPU_max) { - (*_bfd_error_handler) (_("%B: unrecognised SPU reloc number: %d"), - abfd, r_type); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_SPU_NONE; + return FALSE; } cache_ptr->howto = &elf_howto_table[(int) r_type]; + return TRUE; } static reloc_howto_type * @@ -210,7 +215,7 @@ spu_elf_rel9 (bfd *abfd, arelent *reloc_entry, asymbol *symbol, if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) return bfd_reloc_outofrange; - octets = reloc_entry->address * bfd_octets_per_byte (abfd); + octets = reloc_entry->address * OCTETS_PER_BYTE (abfd, input_section); /* Get symbol value. */ val = 0; @@ -578,17 +583,22 @@ spu_elf_create_sections (struct bfd_link_info *info) flagword flags; ibfd = info->input_bfds; + /* This should really be SEC_LINKER_CREATED, but then we'd need + to write out the section ourselves. */ flags = SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY; s = bfd_make_section_anyway_with_flags (ibfd, SPU_PTNOTE_SPUNAME, flags); if (s == NULL - || !bfd_set_section_alignment (ibfd, s, 4)) + || !bfd_set_section_alignment (s, 4)) return FALSE; + /* Because we didn't set SEC_LINKER_CREATED we need to set the + proper section type. */ + elf_section_type (s) = SHT_NOTE; name_len = strlen (bfd_get_filename (info->output_bfd)) + 1; size = 12 + ((sizeof (SPU_PLUGIN_NAME) + 3) & -4); size += (name_len + 3) & -4; - if (!bfd_set_section_size (ibfd, s, size)) + if (!bfd_set_section_size (s, size)) return FALSE; data = bfd_zalloc (ibfd, size); @@ -615,7 +625,7 @@ spu_elf_create_sections (struct bfd_link_info *info) flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); s = bfd_make_section_anyway_with_flags (ibfd, ".fixup", flags); - if (s == NULL || !bfd_set_section_alignment (ibfd, s, 2)) + if (s == NULL || !bfd_set_section_alignment (s, 2)) return FALSE; htab->sfixup = s; } @@ -722,16 +732,16 @@ spu_elf_find_overlays (struct bfd_link_info *info) if ((s->vma - vma_start) & (htab->params->line_size - 1)) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "does not start on a cache line.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "does not start on a cache line\n"), s); bfd_set_error (bfd_error_bad_value); return 0; } else if (s->size > htab->params->line_size) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "is larger than a cache line.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "is larger than a cache line\n"), s); bfd_set_error (bfd_error_bad_value); return 0; @@ -750,8 +760,8 @@ spu_elf_find_overlays (struct bfd_link_info *info) s = alloc_sec[i]; if (s->vma < ovl_end) { - info->callbacks->einfo (_("%X%P: overlay section %A " - "is not in cache area.\n"), + info->callbacks->einfo (_("%X%P: overlay section %pA " + "is not in cache area\n"), alloc_sec[i-1]); bfd_set_error (bfd_error_bad_value); return 0; @@ -790,9 +800,10 @@ spu_elf_find_overlays (struct bfd_link_info *info) spu_elf_section_data (s)->u.o.ovl_buf = num_buf; if (s0->vma != s->vma) { - info->callbacks->einfo (_("%X%P: overlay sections %A " - "and %A do not start at the " - "same address.\n"), + /* xgettext:c-format */ + info->callbacks->einfo (_("%X%P: overlay sections %pA " + "and %pA do not start at the " + "same address\n"), s0, s); bfd_set_error (bfd_error_bad_value); return 0; @@ -1014,9 +1025,10 @@ needs_ovl_stub (struct elf_link_hash_entry *h, sym, sym_sec); } - (*_bfd_error_handler) (_("warning: call to non-function" - " symbol %s defined in %B"), - sym_sec->owner, sym_name); + _bfd_error_handler + /* xgettext:c-format */ + (_("warning: call to non-function symbol %s defined in %pB"), + sym_name, sym_sec->owner); } } @@ -1364,7 +1376,8 @@ build_stub (struct bfd_link_info *info, if (stub_type != br000_ovl_stub && lrlive != stub_type - br000_ovl_stub) - info->callbacks->einfo (_("%A:0x%v lrlive .brinfo (%u) differs " + /* xgettext:c-format */ + info->callbacks->einfo (_("%pA:0x%v lrlive .brinfo (%u) differs " "from analysis (%u)\n"), isec, irela->r_offset, lrlive, stub_type - br000_ovl_stub); @@ -1684,7 +1697,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) stub = bfd_make_section_anyway_with_flags (ibfd, ".stub", flags); htab->stub_sec[0] = stub; if (stub == NULL - || !bfd_set_section_alignment (ibfd, stub, + || !bfd_set_section_alignment (stub, ovl_stub_size_log2 (htab->params))) return 0; stub->size = htab->stub_count[0] * ovl_stub_size (htab->params); @@ -1699,7 +1712,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) stub = bfd_make_section_anyway_with_flags (ibfd, ".stub", flags); htab->stub_sec[ovl] = stub; if (stub == NULL - || !bfd_set_section_alignment (ibfd, stub, + || !bfd_set_section_alignment (stub, ovl_stub_size_log2 (htab->params))) return 0; stub->size = htab->stub_count[ovl] * ovl_stub_size (htab->params); @@ -1717,7 +1730,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) flags = SEC_ALLOC; htab->ovtab = bfd_make_section_anyway_with_flags (ibfd, ".ovtab", flags); if (htab->ovtab == NULL - || !bfd_set_section_alignment (ibfd, htab->ovtab, 4)) + || !bfd_set_section_alignment (htab->ovtab, 4)) return 0; htab->ovtab->size = (16 + 16 + (16 << htab->fromelem_size_log2)) @@ -1726,7 +1739,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; htab->init = bfd_make_section_anyway_with_flags (ibfd, ".ovini", flags); if (htab->init == NULL - || !bfd_set_section_alignment (ibfd, htab->init, 4)) + || !bfd_set_section_alignment (htab->init, 4)) return 0; htab->init->size = 16; @@ -1751,7 +1764,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY; htab->ovtab = bfd_make_section_anyway_with_flags (ibfd, ".ovtab", flags); if (htab->ovtab == NULL - || !bfd_set_section_alignment (ibfd, htab->ovtab, 4)) + || !bfd_set_section_alignment (htab->ovtab, 4)) return 0; htab->ovtab->size = htab->num_overlays * 16 + 16 + htab->num_buf * 4; @@ -1759,7 +1772,7 @@ spu_elf_size_stubs (struct bfd_link_info *info) htab->toe = bfd_make_section_anyway_with_flags (ibfd, ".toe", SEC_ALLOC); if (htab->toe == NULL - || !bfd_set_section_alignment (ibfd, htab->toe, 4)) + || !bfd_set_section_alignment (htab->toe, 4)) return 0; htab->toe->size = 16; @@ -1895,16 +1908,17 @@ define_ovtab_symbol (struct spu_link_hash_table *htab, const char *name) } else if (h->root.u.def.section->owner != NULL) { - (*_bfd_error_handler) (_("%B is not allowed to define %s"), - h->root.u.def.section->owner, - h->root.root.string); + /* xgettext:c-format */ + _bfd_error_handler (_("%pB is not allowed to define %s"), + h->root.u.def.section->owner, + h->root.root.string); bfd_set_error (bfd_error_bad_value); return NULL; } else { - (*_bfd_error_handler) (_("you are not allowed to define %s in a script"), - h->root.root.string); + _bfd_error_handler (_("you are not allowed to define %s in a script"), + h->root.root.string); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -1937,8 +1951,8 @@ spu_elf_build_stubs (struct bfd_link_info *info) s = h->root.u.def.section->output_section; if (spu_elf_section_data (s)->u.o.ovl_index) { - (*_bfd_error_handler) (_("%s in overlay section"), - h->root.root.string); + _bfd_error_handler (_("%s in overlay section"), + h->root.root.string); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1966,7 +1980,7 @@ spu_elf_build_stubs (struct bfd_link_info *info) if (htab->stub_err) { - (*_bfd_error_handler) (_("overlay stub relocation overflow")); + _bfd_error_handler (_("overlay stub relocation overflow")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -1975,7 +1989,7 @@ spu_elf_build_stubs (struct bfd_link_info *info) { if (htab->stub_sec[i]->size != htab->stub_sec[i]->rawsize) { - (*_bfd_error_handler) (_("stubs don't match calculated size")); + _bfd_error_handler (_("stubs don't match calculated size")); bfd_set_error (bfd_error_bad_value); return FALSE; } @@ -2117,7 +2131,7 @@ spu_elf_build_stubs (struct bfd_link_info *info) bfd_put_32 (htab->ovtab->owner, s->vma, p + off); bfd_put_32 (htab->ovtab->owner, (s->size + 15) & -16, p + off + 4); - /* file_off written later in spu_elf_modify_program_headers. */ + /* file_off written later in spu_elf_modify_headers. */ bfd_put_32 (htab->ovtab->owner, ovl_buf, p + off + 12); } } @@ -2557,6 +2571,7 @@ check_function_ranges (asection *sec, struct bfd_link_info *info) const char *f1 = func_name (&sinfo->fun[i - 1]); const char *f2 = func_name (&sinfo->fun[i]); + /* xgettext:c-format */ info->callbacks->einfo (_("warning: %s overlaps %s\n"), f1, f2); sinfo->fun[i - 1].hi = sinfo->fun[i].lo; } @@ -2604,7 +2619,8 @@ find_function (asection *sec, bfd_vma offset, struct bfd_link_info *info) else return &sinfo->fun[mid]; } - info->callbacks->einfo (_("%A:0x%v not found in function table\n"), + /* xgettext:c-format */ + info->callbacks->einfo (_("%pA:0x%v not found in function table\n"), sec, offset); bfd_set_error (bfd_error_bad_value); return NULL; @@ -2744,8 +2760,9 @@ mark_functions_via_relocs (asection *sec, { if (!warned) info->callbacks->einfo - (_("%B(%A+0x%v): call to non-code section" - " %B(%A), analysis incomplete\n"), + /* xgettext:c-format */ + (_("%pB(%pA+0x%v): call to non-code section" + " %pB(%pA), analysis incomplete\n"), sec->owner, sec, irela->r_offset, sym_sec->owner, sym_sec); warned = TRUE; @@ -3312,7 +3329,8 @@ remove_cycles (struct function_info *fun, const char *f1 = func_name (fun); const char *f2 = func_name (call->fun); - info->callbacks->info (_("Stack analysis will ignore the call " + /* xgettext:c-format */ + info->callbacks->info (_("stack analysis will ignore the call " "from %s to %s\n"), f1, f2); } @@ -4003,8 +4021,8 @@ sum_stack (struct function_info *fun, if (htab->params->stack_analysis) { if (!fun->non_root) - info->callbacks->info (_(" %s: 0x%v\n"), f1, (bfd_vma) cum_stack); - info->callbacks->minfo (_("%s: 0x%v 0x%v\n"), + info->callbacks->info (" %s: 0x%v\n", f1, (bfd_vma) cum_stack); + info->callbacks->minfo ("%s: 0x%v 0x%v\n", f1, (bfd_vma) stack, (bfd_vma) cum_stack); if (has_call) @@ -4017,7 +4035,7 @@ sum_stack (struct function_info *fun, const char *ann1 = call->fun == max ? "*" : " "; const char *ann2 = call->is_tail ? "t" : " "; - info->callbacks->minfo (_(" %s%s %s\n"), ann1, ann2, f2); + info->callbacks->minfo (" %s%s %s\n", ann1, ann2, f2); } } } @@ -4322,6 +4340,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info) if (bfd_arr[i - 1]->my_archive == bfd_arr[i]->my_archive) { if (bfd_arr[i - 1]->my_archive && bfd_arr[i]->my_archive) + /* xgettext:c-format */ info->callbacks->einfo (_("%s duplicated in %s\n"), bfd_arr[i]->filename, bfd_arr[i]->my_archive->filename); @@ -4374,6 +4393,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info) } if (fixed_size + mos_param.max_overlay_size > htab->local_store) + /* xgettext:c-format */ info->callbacks->einfo (_("non-overlay size of 0x%v plus maximum overlay " "size of 0x%v exceeds local store\n"), (bfd_vma) fixed_size, @@ -4529,7 +4549,8 @@ spu_elf_auto_overlay (struct bfd_link_info *info) if (i == base) { - info->callbacks->einfo (_("%B:%A%s exceeds overlay size\n"), + /* xgettext:c-format */ + info->callbacks->einfo (_("%pB:%pA%s exceeds overlay size\n"), ovly_sections[2 * i]->owner, ovly_sections[2 * i], ovly_sections[2 * i + 1] ? " + rodata" : ""); @@ -4670,7 +4691,7 @@ spu_elf_auto_overlay (struct bfd_link_info *info) file_err: bfd_set_error (bfd_error_system_call); err_exit: - info->callbacks->einfo ("%F%P: auto overlay error: %E\n"); + info->callbacks->einfo (_("%F%P: auto overlay error: %E\n")); xexit (1); } @@ -4721,10 +4742,10 @@ spu_elf_final_link (bfd *output_bfd, struct bfd_link_info *info) || (htab->params->ovly_flavour == ovly_soft_icache && htab->params->lrlive_analysis)) && !spu_elf_stack_analysis (info)) - info->callbacks->einfo ("%X%P: stack/lrlive analysis error: %E\n"); + info->callbacks->einfo (_("%X%P: stack/lrlive analysis error: %E\n")); if (!spu_elf_build_stubs (info)) - info->callbacks->einfo ("%F%P: can not build overlay stubs: %E\n"); + info->callbacks->einfo (_("%F%P: can not build overlay stubs: %E\n")); return bfd_elf_final_link (output_bfd, info); } @@ -4793,7 +4814,7 @@ spu_elf_emit_fixup (bfd * output_bfd, struct bfd_link_info *info, if (qaddr != (base & ~(bfd_vma) 15)) { if ((sfixup->reloc_count + 1) * FIXUP_RECORD_SIZE > sfixup->size) - (*_bfd_error_handler) (_("fatal error while creating .fixup")); + _bfd_error_handler (_("fatal error while creating .fixup")); FIXUP_PUT (output_bfd, htab, sfixup->reloc_count, qaddr | bit); sfixup->reloc_count++; } @@ -4906,13 +4927,14 @@ spu_elf_relocate_section (bfd *output_bfd, && !(r_type == R_SPU_PPU32 || r_type == R_SPU_PPU64)) { bfd_boolean err; - err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR - || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT); - (*info->callbacks->undefined_symbol) (info, - h->root.root.string, - input_bfd, - input_section, - rel->r_offset, err); + + err = (info->unresolved_syms_in_objects == RM_DIAGNOSE + && !info->warn_unresolved_syms) + || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT; + + info->callbacks->undefined_symbol + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset, err); } sym_name = h->root.root.string; } @@ -5026,11 +5048,13 @@ spu_elf_relocate_section (bfd *output_bfd, && _bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset) != (bfd_vma) -1) { - (*_bfd_error_handler) - (_("%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"), + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB(%s+%#" PRIx64 "): " + "unresolvable %s relocation against symbol `%s'"), input_bfd, - bfd_get_section_name (input_bfd, input_section), - (long) rel->r_offset, + bfd_section_name (input_section), + (uint64_t) rel->r_offset, howto->name, sym_name); ret = FALSE; @@ -5165,17 +5189,19 @@ spu_elf_plugin (int val) /* Set ELF header e_type for plugins. */ -static void -spu_elf_post_process_headers (bfd *abfd, struct bfd_link_info *info) +static bfd_boolean +spu_elf_init_file_header (bfd *abfd, struct bfd_link_info *info) { + if (!_bfd_elf_init_file_header (abfd, info)) + return FALSE; + if (spu_plugin) { Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd); i_ehdrp->e_type = ET_DYN; } - - _bfd_elf_post_process_headers (abfd, info); + return TRUE; } /* We may add an extra PT_LOAD segment for .toe. We also need extra @@ -5211,7 +5237,7 @@ spu_elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info) { asection *toe, *s; struct elf_segment_map *m, *m_overlay; - struct elf_segment_map **p, **p_overlay; + struct elf_segment_map **p, **p_overlay, **first_load; unsigned int i; if (info == NULL) @@ -5270,24 +5296,41 @@ spu_elf_modify_segment_map (bfd *abfd, struct bfd_link_info *info) /* Move all overlay segments onto a separate list. */ p = &elf_seg_map (abfd); p_overlay = &m_overlay; + m_overlay = NULL; + first_load = NULL; while (*p != NULL) { - if ((*p)->p_type == PT_LOAD && (*p)->count == 1 - && spu_elf_section_data ((*p)->sections[0])->u.o.ovl_index != 0) + if ((*p)->p_type == PT_LOAD) { - m = *p; - *p = m->next; - *p_overlay = m; - p_overlay = &m->next; - continue; + if (!first_load) + first_load = p; + if ((*p)->count == 1 + && spu_elf_section_data ((*p)->sections[0])->u.o.ovl_index != 0) + { + m = *p; + m->no_sort_lma = 1; + *p = m->next; + *p_overlay = m; + p_overlay = &m->next; + continue; + } } - p = &((*p)->next); } /* Re-insert overlay segments at the head of the segment map. */ - *p_overlay = elf_seg_map (abfd); - elf_seg_map (abfd) = m_overlay; + if (m_overlay != NULL) + { + p = first_load; + if (*p != NULL && (*p)->p_type == PT_LOAD && (*p)->includes_filehdr) + /* It doesn't really make sense for someone to include the ELF + file header into an spu image, but if they do the code that + assigns p_offset needs to see the segment containing the + header first. */ + p = &(*p)->next; + *p_overlay = *p; + *p = m_overlay; + } return TRUE; } @@ -5307,100 +5350,103 @@ spu_elf_fake_sections (bfd *obfd ATTRIBUTE_UNUSED, /* Tweak phdrs before writing them out. */ static int -spu_elf_modify_program_headers (bfd *abfd, struct bfd_link_info *info) +spu_elf_modify_headers (bfd *abfd, struct bfd_link_info *info) { - const struct elf_backend_data *bed; - struct elf_obj_tdata *tdata; - Elf_Internal_Phdr *phdr, *last; - struct spu_link_hash_table *htab; - unsigned int count; - unsigned int i; - - if (info == NULL) - return TRUE; - - bed = get_elf_backend_data (abfd); - tdata = elf_tdata (abfd); - phdr = tdata->phdr; - count = elf_program_header_size (abfd) / bed->s->sizeof_phdr; - htab = spu_hash_table (info); - if (htab->num_overlays != 0) + if (info != NULL) { - struct elf_segment_map *m; - unsigned int o; - - 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) - { - /* Mark this as an overlay header. */ - phdr[i].p_flags |= PF_OVERLAY; + const struct elf_backend_data *bed; + struct elf_obj_tdata *tdata; + Elf_Internal_Phdr *phdr, *last; + struct spu_link_hash_table *htab; + unsigned int count; + unsigned int i; + + bed = get_elf_backend_data (abfd); + tdata = elf_tdata (abfd); + phdr = tdata->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; - if (htab->ovtab != NULL && htab->ovtab->size != 0 - && htab->params->ovly_flavour != ovly_soft_icache) + 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_byte *p = htab->ovtab->contents; - unsigned int off = o * 16 + 8; + /* Mark this as an overlay header. */ + phdr[i].p_flags |= PF_OVERLAY; + + if (htab->ovtab != NULL && htab->ovtab->size != 0 + && htab->params->ovly_flavour != ovly_soft_icache) + { + bfd_byte *p = htab->ovtab->contents; + unsigned int off = o * 16 + 8; - /* Write file_off into _ovly_table. */ - bfd_put_32 (htab->ovtab->owner, phdr[i].p_offset, p + off); + /* Write file_off into _ovly_table. */ + bfd_put_32 (htab->ovtab->owner, phdr[i].p_offset, p + off); + } } - } - /* Soft-icache has its file offset put in .ovl.init. */ - if (htab->init != NULL && htab->init->size != 0) - { - bfd_vma val = elf_section_data (htab->ovl_sec[0])->this_hdr.sh_offset; + /* Soft-icache has its file offset put in .ovl.init. */ + if (htab->init != NULL && htab->init->size != 0) + { + bfd_vma val + = elf_section_data (htab->ovl_sec[0])->this_hdr.sh_offset; - bfd_put_32 (htab->init->owner, val, htab->init->contents + 4); + bfd_put_32 (htab->init->owner, val, htab->init->contents + 4); + } } - } - /* Round up p_filesz and p_memsz of PT_LOAD segments to multiples - of 16. This should always be possible when using the standard - linker scripts, but don't create overlapping segments if - someone is playing games with linker scripts. */ - last = NULL; - for (i = count; i-- != 0; ) - if (phdr[i].p_type == PT_LOAD) - { - unsigned adjust; + /* Round up p_filesz and p_memsz of PT_LOAD segments to multiples + of 16. This should always be possible when using the standard + linker scripts, but don't create overlapping segments if + someone is playing games with linker scripts. */ + last = NULL; + for (i = count; i-- != 0; ) + if (phdr[i].p_type == PT_LOAD) + { + unsigned adjust; - adjust = -phdr[i].p_filesz & 15; - if (adjust != 0 - && last != NULL - && phdr[i].p_offset + phdr[i].p_filesz > last->p_offset - adjust) - break; + adjust = -phdr[i].p_filesz & 15; + if (adjust != 0 + && last != NULL + && (phdr[i].p_offset + phdr[i].p_filesz + > last->p_offset - adjust)) + break; - adjust = -phdr[i].p_memsz & 15; - if (adjust != 0 - && last != NULL - && phdr[i].p_filesz != 0 - && phdr[i].p_vaddr + phdr[i].p_memsz > last->p_vaddr - adjust - && phdr[i].p_vaddr + phdr[i].p_memsz <= last->p_vaddr) - break; + adjust = -phdr[i].p_memsz & 15; + if (adjust != 0 + && last != NULL + && phdr[i].p_filesz != 0 + && phdr[i].p_vaddr + phdr[i].p_memsz > last->p_vaddr - adjust + && phdr[i].p_vaddr + phdr[i].p_memsz <= last->p_vaddr) + break; - if (phdr[i].p_filesz != 0) - last = &phdr[i]; - } + if (phdr[i].p_filesz != 0) + last = &phdr[i]; + } - if (i == (unsigned int) -1) - for (i = count; i-- != 0; ) - if (phdr[i].p_type == PT_LOAD) - { - unsigned adjust; + if (i == (unsigned int) -1) + for (i = count; i-- != 0; ) + if (phdr[i].p_type == PT_LOAD) + { + unsigned adjust; - adjust = -phdr[i].p_filesz & 15; - phdr[i].p_filesz += adjust; + adjust = -phdr[i].p_filesz & 15; + phdr[i].p_filesz += adjust; - adjust = -phdr[i].p_memsz & 15; - phdr[i].p_memsz += adjust; - } + adjust = -phdr[i].p_memsz & 15; + phdr[i].p_memsz += adjust; + } + } - return TRUE; + return _bfd_elf_modify_headers (abfd, info); } bfd_boolean -spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) +spu_elf_size_sections (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { struct spu_link_hash_table *htab = spu_hash_table (info); if (htab->params->emit_fixups) @@ -5424,7 +5470,7 @@ spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) bfd_vma base_end; /* If there aren't any relocs, then there's nothing more - to do. */ + to do. */ if ((isec->flags & SEC_ALLOC) == 0 || (isec->flags & SEC_RELOC) == 0 || isec->reloc_count == 0) @@ -5438,10 +5484,10 @@ spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) return FALSE; /* 1 quadword can contain up to 4 R_SPU_ADDR32 - relocations. They are stored in a single word by - saving the upper 28 bits of the address and setting the - lower 4 bits to a bit mask of the words that have the - relocation. BASE_END keeps track of the next quadword. */ + relocations. They are stored in a single word by + saving the upper 28 bits of the address and setting the + lower 4 bits to a bit mask of the words that have the + relocation. BASE_END keeps track of the next quadword. */ irela = internal_relocs; irelaend = irela + isec->reloc_count; base_end = 0; @@ -5457,7 +5503,7 @@ spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) /* We always have a NULL fixup as a sentinel */ size = (fixup_count + 1) * FIXUP_RECORD_SIZE; - if (!bfd_set_section_size (output_bfd, sfixup, size)) + if (!bfd_set_section_size (sfixup, size)) return FALSE; sfixup->contents = (bfd_byte *) bfd_zalloc (info->input_bfds, size); if (sfixup->contents == NULL) @@ -5473,7 +5519,7 @@ spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) #define ELF_MACHINE_CODE EM_SPU /* This matches the alignment need for DMA. */ #define ELF_MAXPAGESIZE 0x80 -#define elf_backend_rela_normal 1 +#define elf_backend_rela_normal 1 #define elf_backend_can_gc_sections 1 #define bfd_elf32_bfd_reloc_type_lookup spu_elf_reloc_type_lookup @@ -5490,8 +5536,8 @@ spu_elf_size_sections (bfd * output_bfd, struct bfd_link_info *info) #define elf_backend_additional_program_headers spu_elf_additional_program_headers #define elf_backend_modify_segment_map spu_elf_modify_segment_map -#define elf_backend_modify_program_headers spu_elf_modify_program_headers -#define elf_backend_post_process_headers spu_elf_post_process_headers +#define elf_backend_modify_headers spu_elf_modify_headers +#define elf_backend_init_file_header spu_elf_init_file_header #define elf_backend_fake_sections spu_elf_fake_sections #define elf_backend_special_sections spu_elf_special_sections #define bfd_elf32_bfd_final_link spu_elf_final_link