added coff-sparc.c to CFILES, rebuilt dependencies
[deliverable/binutils-gdb.git] / bfd / coff-m88k.c
CommitLineData
6585e9e3
ILT
1/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
2 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
156e3852 3 Written by Cygnus Support.
a7fe4c59 4
156e3852 5This file is part of BFD, the Binary File Descriptor library.
a7fe4c59 6
156e3852 7This program is free software; you can redistribute it and/or modify
a7fe4c59 8it under the terms of the GNU General Public License as published by
156e3852
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
a7fe4c59 11
156e3852 12This program is distributed in the hope that it will be useful,
a7fe4c59
SC
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
156e3852
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
a7fe4c59 20
156e3852 21#define M88 1 /* Customize various include files */
a7fe4c59 22#include "bfd.h"
156e3852 23#include "sysdep.h"
a7fe4c59 24#include "libbfd.h"
9872a49c 25#include "obstack.h"
294eaca4
SC
26#include "coff/m88k.h"
27#include "coff/internal.h"
9872a49c 28#include "libcoff.h"
294eaca4 29#undef HOWTO_PREPARE
4cddd1c9
SC
30/* Provided the symbol, returns the value reffed */
31#define HOWTO_PREPARE(relocation, symbol) \
32 { \
33 if (symbol != (asymbol *)NULL) { \
6585e9e3 34 if (bfd_is_com_section (symbol->section)) { \
4cddd1c9
SC
35 relocation = 0; \
36 } \
37 else { \
38 relocation = symbol->value; \
39 } \
40 } \
41 if (symbol->section != (asection *)NULL) { \
42 relocation += symbol->section->output_section->vma + \
43 symbol->section->output_offset; \
44 } \
45}
4cddd1c9
SC
46
47
156e3852 48static bfd_reloc_status_type
294eaca4
SC
49DEFUN(howto_hvrt16,(abfd, reloc_entry, symbol_in, data,
50 ignore_input_section, ignore_bfd),
51 bfd *abfd AND
52 arelent *reloc_entry AND
53 asymbol *symbol_in AND
54 PTR data AND
55 asection *ignore_input_section AND
56 bfd *ignore_bfd)
4cddd1c9 57{
294eaca4 58 long relocation = 0;
4cddd1c9 59 bfd_vma addr = reloc_entry->address;
19b03b7a 60 long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
4cddd1c9
SC
61
62 HOWTO_PREPARE(relocation, symbol_in);
63
64 x = (x + relocation + reloc_entry->addend) >> 16;
65
19b03b7a 66 bfd_put_16(abfd, x, (bfd_byte *)data + addr);
4cddd1c9
SC
67 return bfd_reloc_ok;
68}
69
a7fe4c59
SC
70
71
72static reloc_howto_type howto_table[] =
73{
4cddd1c9 74 HOWTO(R_PCR16L,02,1,16,true, 0,false,true,0,"PCR16L",false,0x0000ffff,0x0000ffff,true),
6585e9e3 75 HOWTO(R_PCR26L,02,2,26,true, 0,false,true,0,"PCR26L",false,0x03ffffff,0x03ffffff,true),
4cddd1c9
SC
76 HOWTO(R_VRT16, 00,1,16,false,0,false,true,0,"VRT16", false,0x0000ffff,0x0000ffff,true),
77 HOWTO(R_HVRT16,16,1,16,false,0,false,true,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true),
78 HOWTO(R_LVRT16,00,1,16,false,0,false,true,0,"LVRT16",false,0x0000ffff,0x0000ffff,true),
79 HOWTO(R_VRT32, 00,2,32,false,0,false,true,0,"VRT32", false,0xffffffff,0xffffffff,true),
a7fe4c59
SC
80};
81
82
3b4f1a5d
SC
83/* Code to swap in the reloc offset */
84#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
85#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
86
87
88/* Code to turn an external r_type into a pointer to an entry in the
89 above howto table */
90#define RTYPE2HOWTO(cache_ptr, dst) \
294eaca4
SC
91 if ((dst)->r_type >= R_PCR16L && (dst)->r_type <= R_VRT32) {\
92 cache_ptr->howto = howto_table + (dst)->r_type - R_PCR16L;\
93 cache_ptr->addend += (dst)->r_offset << 16; \
3b4f1a5d
SC
94 } \
95 else { \
96 BFD_ASSERT(0); \
97 }
98
99
a7fe4c59
SC
100
101#define BADMAG(x) MC88BADMAG(x)
2700c3c7 102#include "coffcode.h"
a7fe4c59 103
5685fb50 104#undef coff_write_armap
9872a49c 105
080f6324 106bfd_target m88kbcs_vec =
a7fe4c59 107{
3b4f1a5d 108 "coff-m88kbcs", /* name */
156e3852 109 bfd_target_coff_flavour,
9872a49c 110 true, /* data byte order is big */
a7fe4c59
SC
111 true, /* header byte order is big */
112
113 (HAS_RELOC | EXEC_P | /* object flags */
114 HAS_LINENO | HAS_DEBUG |
115 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
116
117 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
6585e9e3 118 '_', /* leading underscore */
a7fe4c59
SC
119 '/', /* ar_pad_char */
120 15, /* ar_max_namelen */
156e3852 121 3, /* default alignment power */
6585e9e3
ILT
122 _do_getb64, _do_getb_signed_64, _do_putb64,
123 _do_getb32, _do_getb_signed_32, _do_putb32,
124 _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
125 _do_getb64, _do_getb_signed_64, _do_putb64,
126 _do_getb32, _do_getb_signed_32, _do_putb32,
127 _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
a7fe4c59 128
156e3852
JG
129 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
130 bfd_generic_archive_p, _bfd_dummy_target},
131 {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
132 bfd_false},
133 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
134 _bfd_write_archive_contents, bfd_false},
9872a49c 135
2700c3c7 136 JUMP_TABLE(coff),
6585e9e3 137 COFF_SWAP_TABLE,
2b1d8a50 138};
This page took 0.108523 seconds and 4 git commands to generate.