[binutils-gdb] alpha: handle discarded got section
Alan Modra
amodra@sourceware.org
Thu May 14 23:00:56 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=53a7f1375a961e97a195682234b2aff84d6c3744
commit 53a7f1375a961e97a195682234b2aff84d6c3744
Author: Alan Modra <amodra@gmail.com>
Date: Mon May 11 09:20:29 2026 +0930
alpha: handle discarded got section
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.
Diff:
---
bfd/elf64-alpha.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 0a63ca0bbdb..91cc7bcaec8 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -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,
More information about the Binutils-cvs
mailing list