/* BFD back-end for National Semiconductor's CR16C ELF
- Copyright 2004 Free Software Foundation, Inc.
+ Copyright 2004, 2005 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "bfd.h"
#include "sysdep.h"
return bfd_reloc_overflow;
value &= 0xFF;
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_16: /* Two bytes. */
if (value > (int) MAX_UWORD || value < MIN_WORD)
return bfd_reloc_overflow;
sword = value;
bfd_put_16 (abfd, (bfd_vma) sword,
(unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_32: /* Four bytes. */
value &= 0xFFFFFFFF;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
default:
return bfd_reloc_notsupported;
}
value <<= 4;
value |= left_val;
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_08: /* word1(0-3,8-11). */
if (value > 255 || value < -256 || value == 0x80)
return bfd_reloc_overflow;
sword |= left_val;
bfd_put_16 (abfd, (bfd_vma) sword,
(unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_16: /* word2. */
if (value > 65535 || value < -65536)
return bfd_reloc_overflow;
sword = value;
bfd_put_16 (abfd, (bfd_vma) sword,
(unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_24_a: /* word1(0-7),word2. */
if (value > 16777215 || value < -16777216)
return bfd_reloc_overflow;
((value & 0x00800000) >> 7) | ((value & 0x007F8000) >> 15);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_24: /* word2(0-3,8-11),word3. */
if (value > 16777215 || value < -16777216)
return bfd_reloc_overflow;
((value & 0x000F0000) >> 8) | ((value & 0x00F00000) >> 20);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
default:
return bfd_reloc_notsupported;
}
value &= 0xF;
value |= left_val;
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_04_a: /* word1(12-15) not scaled. */
if (value > 26 || value < 0)
return bfd_reloc_overflow;
value >>= 1;
value |= left_val;
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_14: /* word1(4-5),word2(0-3,8-15). */
if (value < 0 || value > 16383)
return bfd_reloc_overflow;
((value & 0x0000000F) << 16) | (value & 0x00000030);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_16: /* word2. */
if (value > 65535 || value < 0)
return bfd_reloc_overflow;
sword = value;
bfd_put_16 (abfd, (bfd_vma) sword,
(unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_20: /* word2(8-11),word3. */
/* if (value > 1048575 || value < 0) RELOC_ERROR(1); */
value &= 0xFFFFF;
bfd_put_8 (abfd, (bfd_vma) value,
(unsigned char *) data + octets - 3);
}
- return bfd_reloc_ok;
break;
+
default:
return bfd_reloc_notsupported;
}
((value & 0x000F0000) >> 16);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_24: /* word2(0-3,8-11),word3. */
/* if (value > 16777215 || value < 0) RELOC_ERROR(1); */
value &= 0xFFFFFF;
((value & 0x000F0000) >> 8) | ((value & 0x00F00000) >> 20);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
default:
return bfd_reloc_notsupported;
}
value <<= 4;
value |= left_val;
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_16: /* word2. */
if (value > 32767 || value < -32768)
return bfd_reloc_overflow;
sword = value;
bfd_put_16 (abfd, (bfd_vma) sword,
(unsigned char *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_20: /* word1(0-3),word2. */
if (value > 1048575 || value < 0)
return bfd_reloc_overflow;
((value & 0x000F0000) >> 16);
value |= left_val;
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
case R_S_16C_32: /* word2, word3. */
value &= 0xFFFFFFFF;
value = ((value & 0x0000FFFF) << 16) |
((value & 0xFFFF0000) >> 16);
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
- return bfd_reloc_ok;
break;
+
default:
return bfd_reloc_notsupported;
}
default:
return bfd_reloc_notsupported;
}
+
+ return bfd_reloc_ok;
}
/* Relocate a CR16C ELF section. */
}
else
{
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + sec->output_section->vma + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- if (!((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset, TRUE)))
- return FALSE;
- relocation = 0;
- }
+ bfd_boolean unresolved_reloc, warned;
+
+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+ r_symndx, symtab_hdr, sym_hashes,
+ h, sec, relocation,
+ unresolved_reloc, warned);
}
r = cr16c_elf_final_link_relocate (howto, input_bfd, output_bfd,
{
case bfd_reloc_overflow:
if (!((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
+ (info, (h ? &h->root : NULL), name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section,
+ rel->r_offset)))
return FALSE;
break;
static bfd_boolean
elf32_cr16c_add_symbol_hook (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
- const Elf_Internal_Sym *sym,
+ Elf_Internal_Sym *sym,
const char **namep ATTRIBUTE_UNUSED,
flagword *flagsp ATTRIBUTE_UNUSED,
asection **secp,