/* BFD back-end for National Semiconductor's CRX ELF
- Copyright (C) 2004-2022 Free Software Foundation, Inc.
+ Copyright (C) 2004-2023 Free Software Foundation, Inc.
Written by Tomer Levi, NSC, Israel.
This file is part of BFD, the Binary File Descriptor library.
/* Apply dst_mask to select only relocatable part of the insn. */
Rvalue &= howto->dst_mask;
- switch (howto->size)
+ switch (bfd_get_reloc_size (howto))
{
- case 0:
+ case 1:
if (r_type == R_CRX_REL4)
{
Rvalue <<= 4;
bfd_put_8 (input_bfd, (unsigned char) Rvalue, hit_data);
break;
- case 1:
+ case 2:
if (r_type == R_CRX_REGREL12)
Rvalue |= (bfd_get_16 (input_bfd, hit_data) & 0xf000);
bfd_put_16 (input_bfd, Rvalue, hit_data);
break;
- case 2:
+ case 4:
if (r_type == R_CRX_REL24
|| r_type == R_CRX_REGREL22
|| r_type == R_CRX_REGREL28)
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;
}
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;