public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR16005, avr linker crash on a particular instruction sequence with --relax
@ 2022-07-29  7:56 Alan Modra
  2022-07-29 13:57 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2022-07-29  7:56 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-29 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29  7:56 PR16005, avr linker crash on a particular instruction sequence with --relax Alan Modra
2022-07-29 13:57 ` Alan Modra

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).