PR16005, avr linker crash on a particular instruction sequence with --relax
[binutils-gdb.git] / bfd / elf32-avr.c
index 48591b8c9045c27ed49ed06ca4390259eb71b28b..3a1d238e707318a772717f9d1c13d6cf64c8d4ca 100644 (file)
@@ -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;