alpha: handle discarded got section
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
Commit Message
This fixes testsuite failures I noticed when changing dynobj to be
linker created, but I think the bug could be triggered by suitably
crafted linker scripts without any dynobj changes.
* elf64-alpha.c (elf64_alpha_final_link): Don't attempt to
write out a got section that has been discarded.
@@ -5248,28 +5248,28 @@ elf64_alpha_final_link (bfd *abfd, struct bfd_link_info *info)
/* Now write out the computed sections. */
/* The .got subsections... */
- {
- bfd *i, *dynobj = elf_hash_table(info)->dynobj;
- for (i = htab->got_list;
- i != NULL;
- i = alpha_elf_tdata(i)->got_link_next)
- {
- asection *sgot;
+ bfd *i, *dynobj = elf_hash_table(info)->dynobj;
+ for (i = htab->got_list;
+ i != NULL;
+ i = alpha_elf_tdata(i)->got_link_next)
+ {
+ asection *sgot;
- /* elf_bfd_final_link already did everything in dynobj. */
- if (i == dynobj)
- continue;
+ /* elf_bfd_final_link already did everything in dynobj. */
+ if (i == dynobj)
+ continue;
- sgot = alpha_elf_tdata(i)->got;
- if (! bfd_set_section_contents (abfd, sgot->output_section,
+ sgot = alpha_elf_tdata(i)->got;
+ if (sgot != NULL
+ && !bfd_is_abs_section (sgot->output_section)
+ && !bfd_set_section_contents (abfd, sgot->output_section,
sgot->contents,
(file_ptr) sgot->output_offset,
sgot->size))
- return false;
- }
- }
+ return false;
+ }
- if (mdebug_sec != (asection *) NULL)
+ if (mdebug_sec != NULL)
{
BFD_ASSERT (abfd->output_has_begun);
if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,