X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoff-z8k.c;h=5f7f952e23f93055ee14862260eafcd57d63b7d0;hb=5b677558bc6c7b2477bb33c709e6017e68e7ae8c;hp=d2dc3815ad02d59e11ebe0188c96eebfbf3d58dc;hpb=c0524131ea2e5bf988f957dcbccd68f0d9ea1bb9;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coff-z8k.c b/bfd/coff-z8k.c index d2dc3815ad..5f7f952e23 100644 --- a/bfd/coff-z8k.c +++ b/bfd/coff-z8k.c @@ -1,6 +1,5 @@ /* BFD back-end for Zilog Z800n COFF binaries. - Copyright 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1992-2016 Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Steve Chamberlain, . @@ -8,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -18,10 +17,11 @@ 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "libbfd.h" #include "bfdlink.h" #include "coff/z8k.h" @@ -85,7 +85,7 @@ rtype2howto (arelent *internal, struct internal_reloc *dst) switch (dst->r_type) { default: - abort (); + internal->howto = NULL; break; case R_IMM8: internal->howto = &r_imm8; @@ -135,6 +135,30 @@ coff_z8k_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, } } +static reloc_howto_type * +coff_z8k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ + if (strcasecmp (r_imm8.name, r_name) == 0) + return &r_imm8; + if (strcasecmp (r_da.name, r_name) == 0) + return &r_da; + if (strcasecmp (r_imm32.name, r_name) == 0) + return &r_imm32; + if (strcasecmp (r_jr.name, r_name) == 0) + return &r_jr; + if (strcasecmp (r_rel16.name, r_name) == 0) + return &r_rel16; + if (strcasecmp (r_disp7.name, r_name) == 0) + return &r_disp7; + if (strcasecmp (r_callr.name, r_name) == 0) + return &r_callr; + if (strcasecmp (r_imm4l.name, r_name) == 0) + return &r_imm4l; + + return NULL; +} + /* Perform any necessary magic to the addend in a reloc entry. */ #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ @@ -230,8 +254,8 @@ extra_case (bfd *in_abfd, { bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info, input_section); - bfd_vma dot = (link_order->offset - + *dst_ptr + bfd_vma dot = (*dst_ptr + + input_section->output_offset + input_section->output_section->vma); int gap = dst - dot - 1; /* -1, since we're in the odd byte of the word and the pc's been incremented. */ @@ -240,14 +264,11 @@ extra_case (bfd *in_abfd, abort (); gap /= 2; if (gap > 128 || gap < -128) - { - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, NULL, - bfd_asymbol_name (*reloc->sym_ptr_ptr), - reloc->howto->name, reloc->addend, input_section->owner, - input_section, reloc->address))) - abort (); - } + (*link_info->callbacks->reloc_overflow) + (link_info, NULL, bfd_asymbol_name (*reloc->sym_ptr_ptr), + reloc->howto->name, reloc->addend, input_section->owner, + input_section, reloc->address); + bfd_put_8 (in_abfd, gap, data + *dst_ptr); (*dst_ptr)++; (*src_ptr)++; @@ -258,8 +279,8 @@ extra_case (bfd *in_abfd, { bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info, input_section); - bfd_vma dot = (link_order->offset - + *dst_ptr + bfd_vma dot = (*dst_ptr + + input_section->output_offset + input_section->output_section->vma); int gap = dst - dot - 1; /* -1, since we're in the odd byte of the word and the pc's been incremented. */ @@ -269,14 +290,11 @@ extra_case (bfd *in_abfd, gap /= 2; if (gap > 0 || gap < -127) - { - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, NULL, - bfd_asymbol_name (*reloc->sym_ptr_ptr), - reloc->howto->name, reloc->addend, input_section->owner, - input_section, reloc->address))) - abort (); - } + (*link_info->callbacks->reloc_overflow) + (link_info, NULL, bfd_asymbol_name (*reloc->sym_ptr_ptr), + reloc->howto->name, reloc->addend, input_section->owner, + input_section, reloc->address); + bfd_put_8 (in_abfd, (bfd_get_8 ( in_abfd, data + *dst_ptr) & 0x80) + (-gap & 0x7f), data + *dst_ptr); @@ -289,22 +307,19 @@ extra_case (bfd *in_abfd, { bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info, input_section); - bfd_vma dot = (link_order->offset - + *dst_ptr + bfd_vma dot = (*dst_ptr + + input_section->output_offset + input_section->output_section->vma); int gap = dst - dot - 2; if (gap & 1) abort (); if (gap > 4096 || gap < -4095) - { - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, NULL, - bfd_asymbol_name (*reloc->sym_ptr_ptr), - reloc->howto->name, reloc->addend, input_section->owner, - input_section, reloc->address))) - abort (); - } + (*link_info->callbacks->reloc_overflow) + (link_info, NULL, bfd_asymbol_name (*reloc->sym_ptr_ptr), + reloc->howto->name, reloc->addend, input_section->owner, + input_section, reloc->address); + gap /= 2; bfd_put_16 (in_abfd, (bfd_get_16 ( in_abfd, data + *dst_ptr) & 0xf000) | (-gap & 0x0fff), @@ -318,20 +333,17 @@ extra_case (bfd *in_abfd, { bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info, input_section); - bfd_vma dot = (link_order->offset - + *dst_ptr + bfd_vma dot = (*dst_ptr + + input_section->output_offset + input_section->output_section->vma); int gap = dst - dot - 2; if (gap > 32767 || gap < -32768) - { - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, NULL, - bfd_asymbol_name (*reloc->sym_ptr_ptr), - reloc->howto->name, reloc->addend, input_section->owner, - input_section, reloc->address))) - abort (); - } + (*link_info->callbacks->reloc_overflow) + (link_info, NULL, bfd_asymbol_name (*reloc->sym_ptr_ptr), + reloc->howto->name, reloc->addend, input_section->owner, + input_section, reloc->address); + bfd_put_16 (in_abfd, (bfd_vma) gap, data + *dst_ptr); (*dst_ptr) += 2; (*src_ptr) += 2; @@ -345,6 +357,11 @@ extra_case (bfd *in_abfd, #define coff_reloc16_extra_cases extra_case #define coff_bfd_reloc_type_lookup coff_z8k_reloc_type_lookup +#define coff_bfd_reloc_name_lookup coff_z8k_reloc_name_lookup + +#ifndef bfd_pe_print_pdata +#define bfd_pe_print_pdata NULL +#endif #include "coffcode.h" @@ -355,4 +372,4 @@ extra_case (bfd *in_abfd, #undef coff_bfd_relax_section #define coff_bfd_relax_section bfd_coff_reloc16_relax_section -CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE) +CREATE_BIG_COFF_TARGET_VEC (z8k_coff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE)