/* AVR-specific support for 32-bit ELF
- Copyright (C) 1999-2022 Free Software Foundation, Inc.
+ Copyright (C) 1999-2023 Free Software Foundation, Inc.
Contributed by Denis Chertykov <denisc@overta.ru>
This file is part of BFD, the Binary File Descriptor library.
this section does not have relocs, or if this is not a
code section. */
if (bfd_link_relocatable (link_info)
- || (sec->flags & SEC_RELOC) == 0
|| sec->reloc_count == 0
+ || (sec->flags & SEC_RELOC) == 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0
|| (sec->flags & SEC_CODE) == 0)
return true;
symbols);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ bfd_byte *orig_data = data;
+ if (data == NULL)
+ {
+ data = bfd_malloc (input_section->size);
+ if (data == NULL)
+ return NULL;
+ }
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
(size_t) input_section->size);
free (isymbuf);
if (elf_section_data (input_section)->relocs != internal_relocs)
free (internal_relocs);
+ if (orig_data == NULL)
+ free (data);
return NULL;
}
/* Find the '.avr.prop' section and load the contents into memory. */
sec = bfd_get_section_by_name (abfd, AVR_PROPERTY_RECORD_SECTION_NAME);
- if (sec == NULL)
+ if (sec == NULL || (sec->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
return avr_elf32_load_records_from_section (abfd, sec);
}