aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-avr.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-07-29 16:52:52 +0930
committerAlan Modra <amodra@gmail.com>2022-07-29 17:25:35 +0930
commitb875e9c93df9f30efb34a75b9379490c03ec4d4b (patch)
tree3815a8b332ff0225b2627dbca78ebafc3b4e7faf /bfd/elf32-avr.c
parente4e1fcce52befa56718bea6ae519d1b762b5cd67 (diff)
downloadgdb-b875e9c93df9f30efb34a75b9379490c03ec4d4b.zip
gdb-b875e9c93df9f30efb34a75b9379490c03ec4d4b.tar.gz
gdb-b875e9c93df9f30efb34a75b9379490c03ec4d4b.tar.bz2
PR16005, avr linker crash on a particular instruction sequence with --relax
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.
Diffstat (limited to 'bfd/elf32-avr.c')
-rw-r--r--bfd/elf32-avr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 48591b8..3a1d238 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;