Back to index

cell-binutils  2.17cvs20070401
coff-apollo.c
Go to the documentation of this file.
00001 /* BFD back-end for Apollo 68000 COFF binaries.
00002    Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001, 2002, 2003
00003    Free Software Foundation, Inc.
00004    By Troy Rollo (troy@cbme.unsw.edu.au)
00005    Based on m68k standard COFF version Written by Cygnus Support.
00006 
00007 This file is part of BFD, the Binary File Descriptor library.
00008 
00009 This program is free software; you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation; either version 2 of the License, or
00012 (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00022 
00023 #include "bfd.h"
00024 #include "sysdep.h"
00025 #include "libbfd.h"
00026 #include "coff/apollo.h"
00027 #include "coff/internal.h"
00028 #include "libcoff.h"
00029 
00030 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
00031 
00032 #ifdef ONLY_DECLARE_RELOCS
00033 extern reloc_howto_type apollocoff_howto_table[];
00034 #else
00035 reloc_howto_type apollocoff_howto_table[] =
00036   {
00037     HOWTO (R_RELBYTE,              0,  0,        8,  FALSE, 0, complain_overflow_bitfield, 0, "8",       TRUE, 0x000000ff,0x000000ff, FALSE),
00038     HOWTO (R_RELWORD,              0,  1,        16, FALSE, 0, complain_overflow_bitfield, 0, "16",      TRUE, 0x0000ffff,0x0000ffff, FALSE),
00039     HOWTO (R_RELLONG,              0,  2,        32, FALSE, 0, complain_overflow_bitfield, 0, "32",      TRUE, 0xffffffff,0xffffffff, FALSE),
00040     HOWTO (R_PCRBYTE,              0,  0,        8,  TRUE,  0, complain_overflow_signed,   0, "DISP8",   TRUE, 0x000000ff,0x000000ff, FALSE),
00041     HOWTO (R_PCRWORD,              0,  1,        16, TRUE,  0, complain_overflow_signed,   0, "DISP16",  TRUE, 0x0000ffff,0x0000ffff, FALSE),
00042     HOWTO (R_PCRLONG,              0,  2,        32, TRUE,  0, complain_overflow_signed,   0, "DISP32",  TRUE, 0xffffffff,0xffffffff, FALSE),
00043     HOWTO (R_RELLONG_NEG,      0,  -2,    32, FALSE, 0, complain_overflow_bitfield, 0, "-32",     TRUE, 0xffffffff,0xffffffff, FALSE),
00044   };
00045 #endif /* not ONLY_DECLARE_RELOCS */
00046 
00047 #ifndef BADMAG
00048 #define BADMAG(x) M68KBADMAG(x)
00049 #endif
00050 #define APOLLO_M68 1        /* Customize coffcode.h */
00051 
00052 /* Turn a howto into a reloc number.  */
00053 
00054 extern void apollo_rtype2howto PARAMS ((arelent *, int));
00055 extern int  apollo_howto2rtype PARAMS ((reloc_howto_type *));
00056 #ifndef ONLY_DECLARE_RELOCS
00057 
00058 void
00059 apollo_rtype2howto (internal, relocentry)
00060      arelent *internal;
00061      int relocentry;
00062 {
00063   switch (relocentry)
00064     {
00065     case R_RELBYTE:  internal->howto = apollocoff_howto_table + 0; break;
00066     case R_RELWORD:  internal->howto = apollocoff_howto_table + 1; break;
00067     case R_RELLONG:  internal->howto = apollocoff_howto_table + 2; break;
00068     case R_PCRBYTE:  internal->howto = apollocoff_howto_table + 3; break;
00069     case R_PCRWORD:  internal->howto = apollocoff_howto_table + 4; break;
00070     case R_PCRLONG:  internal->howto = apollocoff_howto_table + 5; break;
00071     case R_RELLONG_NEG:     internal->howto = apollocoff_howto_table + 6; break;
00072     }
00073 }
00074 
00075 int
00076 apollo_howto2rtype (internal)
00077      reloc_howto_type *internal;
00078 {
00079   if (internal->pc_relative)
00080     {
00081       switch (internal->bitsize)
00082        {
00083        case 32: return R_PCRLONG;
00084        case 16: return R_PCRWORD;
00085        case 8: return R_PCRBYTE;
00086        }
00087     }
00088   else
00089     {
00090       switch (internal->bitsize)
00091        {
00092        case 32: return R_RELLONG;
00093        case 16: return R_RELWORD;
00094        case 8: return R_RELBYTE;
00095        }
00096     }
00097   return R_RELLONG;
00098 }
00099 #endif /* not ONLY_DECLARE_RELOCS */
00100 
00101 #define RTYPE2HOWTO(internal, relocentry) \
00102   apollo_rtype2howto (internal, (relocentry)->r_type)
00103 
00104 #define SELECT_RELOC(external, internal) \
00105   external.r_type = apollo_howto2rtype (internal);
00106 
00107 #include "coffcode.h"
00108 
00109 #ifndef TARGET_SYM
00110 #define TARGET_SYM apollocoff_vec
00111 #endif
00112 
00113 #ifndef TARGET_NAME
00114 #define TARGET_NAME "apollo-m68k"
00115 #endif
00116 
00117 #ifdef NAMES_HAVE_UNDERSCORE
00118 CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, '_', NULL, COFF_SWAP_TABLE)
00119 #else
00120 CREATE_BIG_COFF_TARGET_VEC (TARGET_SYM, TARGET_NAME, 0, 0, 0, NULL, COFF_SWAP_TABLE)
00121 #endif