From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR16005, avr linker crash on a particular instruction sequence with --relax
Date: Fri, 29 Jul 2022 17:26:40 +0930 [thread overview]
Message-ID: <YuOSuDG2z3ZnZViO@squeak.grove.modra.org> (raw)
It's possible for relax_delete_bytes to be called with section
contents NULL, as demonstrated by the testcase in this PR.
PR 16005
* elf32-avr.c (elf32_avr_relax_delete_bytes): Get section contents
if not already available.
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 48591b8c904..3a1d238e707 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1927,6 +1927,9 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
contents = elf_section_data (sec)->this_hdr.contents;
+ if (contents == NULL
+ && !bfd_malloc_and_get_section (abfd, sec, &contents))
+ return false;
relax_info = get_avr_relax_info (sec);
toaddr = sec->size;
--
Alan Modra
Australia Development Lab, IBM
next reply other threads:[~2022-07-29 7:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 7:56 Alan Modra [this message]
2022-07-29 13:57 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YuOSuDG2z3ZnZViO@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).