OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [bfd/] [coff-tic30.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* BFD back-end for TMS320C30 coff binaries.
2
   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
3
   Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
4
 
5
   This file is part of BFD, the Binary File Descriptor library.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
   02111-1307, USA.  */
21
 
22
#include "bfd.h"
23
#include "sysdep.h"
24
#include "libbfd.h"
25
#include "bfdlink.h"
26
#include "coff/tic30.h"
27
#include "coff/internal.h"
28
#include "libcoff.h"
29
 
30
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
31
 
32
reloc_howto_type tic30_coff_howto_table[] =
33
{
34
  HOWTO (R_TIC30_ABS16, 2, 1, 16, false, 0, 0, NULL,
35
         "16", false, 0x0000FFFF, 0x0000FFFF, false),
36
  HOWTO (R_TIC30_ABS24, 2, 2, 24, false, 8, complain_overflow_bitfield, NULL,
37
         "24", false, 0xFFFFFF00, 0xFFFFFF00, false),
38
  HOWTO (R_TIC30_LDP, 18, 0, 24, false, 0, complain_overflow_bitfield, NULL,
39
         "LDP", false, 0x00FF0000, 0x000000FF, false),
40
  HOWTO (R_TIC30_ABS32, 2, 2, 32, false, 0, complain_overflow_bitfield, NULL,
41
         "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
42
  HOWTO (R_TIC30_PC16, 2, 1, 16, true, 0, complain_overflow_signed, NULL,
43
         "PCREL", false, 0x0000FFFF, 0x0000FFFF, false),
44
  EMPTY_HOWTO (-1)
45
};
46
 
47
#ifndef coff_bfd_reloc_type_lookup
48
#define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup
49
 
50
/* For the case statement use the code values used in tc_gen_reloc to
51
   map to the howto table entries that match those in both the aout
52
   and coff implementations. */
53
reloc_howto_type *
54
tic30_coff_reloc_type_lookup (abfd, code)
55
     bfd *abfd ATTRIBUTE_UNUSED;
56
     bfd_reloc_code_real_type code;
57
{
58
  switch (code)
59
    {
60
    case BFD_RELOC_8:
61
    case BFD_RELOC_TIC30_LDP:
62
      return &tic30_coff_howto_table[2];
63
    case BFD_RELOC_16:
64
      return &tic30_coff_howto_table[0];
65
    case BFD_RELOC_24:
66
      return &tic30_coff_howto_table[1];
67
    case BFD_RELOC_16_PCREL:
68
      return &tic30_coff_howto_table[4];
69
    case BFD_RELOC_32:
70
      return &tic30_coff_howto_table[3];
71
    default:
72
      return (reloc_howto_type *) NULL;
73
    }
74
}
75
 
76
#endif
77
 
78
/* Turn a howto into a reloc number */
79
 
80
static int
81
coff_tic30_select_reloc (howto)
82
     reloc_howto_type *howto;
83
{
84
  return howto->type;
85
}
86
 
87
#define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto)
88
 
89
 
90
#define BADMAG(x) TIC30BADMAG(x)
91
#define TIC30 1                 /* Customize coffcode.h */
92
#define __A_MAGIC_SET__
93
 
94
/* Code to swap in the reloc */
95
#define SWAP_IN_RELOC_OFFSET  bfd_h_get_32
96
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
97
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \
98
dst->r_stuff[1] = 'C';
99
 
100
/* Code to turn a r_type into a howto ptr, uses the above howto table. */
101
 
102
static void
103
rtype2howto (internal, dst)
104
     arelent *internal;
105
     struct internal_reloc *dst;
106
{
107
  switch (dst->r_type)
108
    {
109
    case R_TIC30_ABS16:
110
      internal->howto = &tic30_coff_howto_table[0];
111
      break;
112
    case R_TIC30_ABS24:
113
      internal->howto = &tic30_coff_howto_table[1];
114
      break;
115
    case R_TIC30_ABS32:
116
      internal->howto = &tic30_coff_howto_table[3];
117
      break;
118
    case R_TIC30_LDP:
119
      internal->howto = &tic30_coff_howto_table[2];
120
      break;
121
    case R_TIC30_PC16:
122
      internal->howto = &tic30_coff_howto_table[4];
123
      break;
124
    default:
125
      abort ();
126
      break;
127
    }
128
}
129
 
130
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
131
 
132
/* Perform any necessary magic to the addend in a reloc entry */
133
 
134
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
135
 cache_ptr->addend =  ext_reloc.r_offset;
136
 
137
 
138
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
139
 reloc_processing(relent, reloc, symbols, abfd, section)
140
 
141
static void
142
reloc_processing (relent, reloc, symbols, abfd, section)
143
     arelent *relent;
144
     struct internal_reloc *reloc;
145
     asymbol **symbols;
146
     bfd *abfd;
147
     asection *section;
148
{
149
  relent->address = reloc->r_vaddr;
150
  rtype2howto (relent, reloc);
151
 
152
  if (reloc->r_symndx > 0)
153
    {
154
      relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
155
    }
156
  else
157
    {
158
      relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
159
    }
160
  relent->addend = reloc->r_offset;
161
  relent->address -= section->vma;
162
}
163
 
164
#include "coffcode.h"
165
 
166
const bfd_target tic30_coff_vec =
167
{
168
  "coff-tic30",                 /* name */
169
  bfd_target_coff_flavour,
170
  BFD_ENDIAN_BIG,               /* data byte order is big */
171
  BFD_ENDIAN_LITTLE,            /* header byte order is little */
172
 
173
  (HAS_RELOC | EXEC_P |         /* object flags */
174
   HAS_LINENO | HAS_DEBUG |
175
   HAS_SYMS | HAS_LOCALS | WP_TEXT),
176
 
177
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
178
  '_',                          /* leading symbol underscore */
179
  '/',                          /* ar_pad_char */
180
  15,                           /* ar_max_namelen */
181
  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
182
  bfd_getb32, bfd_getb_signed_32, bfd_putb32,
183
  bfd_getb16, bfd_getb_signed_16, bfd_putb16,   /* data */
184
  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
185
  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
186
  bfd_getl16, bfd_getl_signed_16, bfd_putl16,   /* hdrs */
187
 
188
  {_bfd_dummy_target, coff_object_p,    /* bfd_check_format */
189
   bfd_generic_archive_p, _bfd_dummy_target},
190
  {bfd_false, coff_mkobject, _bfd_generic_mkarchive,    /* bfd_set_format */
191
   bfd_false},
192
  {bfd_false, coff_write_object_contents,       /* bfd_write_contents */
193
   _bfd_write_archive_contents, bfd_false},
194
 
195
  BFD_JUMP_TABLE_GENERIC (coff),
196
  BFD_JUMP_TABLE_COPY (coff),
197
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
198
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
199
  BFD_JUMP_TABLE_SYMBOLS (coff),
200
  BFD_JUMP_TABLE_RELOCS (coff),
201
  BFD_JUMP_TABLE_WRITE (coff),
202
  BFD_JUMP_TABLE_LINK (coff),
203
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
204
 
205
  NULL,
206
 
207
  COFF_SWAP_TABLE
208
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.