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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [bfd/] [elf32-sparc.c] - Blame information for rev 53

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 khays
/* SPARC-specific support for 32-bit ELF
2
   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3
   2003, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
 
22
#include "sysdep.h"
23
#include "bfd.h"
24
#include "bfdlink.h"
25
#include "libbfd.h"
26
#include "elf-bfd.h"
27
#include "elf/sparc.h"
28
#include "opcode/sparc.h"
29
#include "elfxx-sparc.h"
30
#include "elf-vxworks.h"
31
 
32
/* Support for core dump NOTE sections.  */
33
 
34
static bfd_boolean
35
elf32_sparc_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
36
{
37
  switch (note->descsz)
38
    {
39
    default:
40
      return FALSE;
41
 
42
    case 260:                   /* Solaris prpsinfo_t.  */
43
      elf_tdata (abfd)->core_program
44
        = _bfd_elfcore_strndup (abfd, note->descdata + 84, 16);
45
      elf_tdata (abfd)->core_command
46
        = _bfd_elfcore_strndup (abfd, note->descdata + 100, 80);
47
      break;
48
 
49
    case 336:                   /* Solaris psinfo_t.  */
50
      elf_tdata (abfd)->core_program
51
        = _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);
52
      elf_tdata (abfd)->core_command
53
        = _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);
54
      break;
55
    }
56
 
57
  return TRUE;
58
}
59
 
60
/* Functions for dealing with the e_flags field.
61
 
62
   We don't define set_private_flags or copy_private_bfd_data because
63
   the only currently defined values are based on the bfd mach number,
64
   so we use the latter instead and defer setting e_flags until the
65
   file is written out.  */
66
 
67
/* Merge backend specific data from an object file to the output
68
   object file when linking.  */
69
 
70
static bfd_boolean
71
elf32_sparc_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
72
{
73
  bfd_boolean error;
74
  unsigned long ibfd_mach;
75
  /* FIXME: This should not be static.  */
76
  static unsigned long previous_ibfd_e_flags = (unsigned long) -1;
77
 
78
  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
79
      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
80
    return TRUE;
81
 
82
  error = FALSE;
83
 
84
  ibfd_mach = bfd_get_mach (ibfd);
85
  if (bfd_mach_sparc_64bit_p (ibfd_mach))
86
    {
87
      error = TRUE;
88
      (*_bfd_error_handler)
89
        (_("%B: compiled for a 64 bit system and target is 32 bit"), ibfd);
90
    }
91
  else if ((ibfd->flags & DYNAMIC) == 0)
92
    {
93
      if (bfd_get_mach (obfd) < ibfd_mach)
94
        bfd_set_arch_mach (obfd, bfd_arch_sparc, ibfd_mach);
95
    }
96
 
97
  if (((elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA)
98
       != previous_ibfd_e_flags)
99
      && previous_ibfd_e_flags != (unsigned long) -1)
100
    {
101
      (*_bfd_error_handler)
102
        (_("%B: linking little endian files with big endian files"), ibfd);
103
      error = TRUE;
104
    }
105
  previous_ibfd_e_flags = elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA;
106
 
107
  if (error)
108
    {
109
      bfd_set_error (bfd_error_bad_value);
110
      return FALSE;
111
    }
112
 
113
  return TRUE;
114
}
115
 
116
/* The final processing done just before writing out the object file.
117
   We need to set the e_machine field appropriately.  */
118
 
119
static void
120
elf32_sparc_final_write_processing (bfd *abfd,
121
                                    bfd_boolean linker ATTRIBUTE_UNUSED)
122
{
123
  switch (bfd_get_mach (abfd))
124
    {
125
    case bfd_mach_sparc :
126
    case bfd_mach_sparc_sparclet :
127
    case bfd_mach_sparc_sparclite :
128
      break; /* nothing to do */
129
    case bfd_mach_sparc_v8plus :
130
      elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
131
      elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
132
      elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
133
      break;
134
    case bfd_mach_sparc_v8plusa :
135
      elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
136
      elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
137
      elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
138
      break;
139
    case bfd_mach_sparc_v8plusb :
140
      elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
141
      elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
142
      elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1
143
                                       | EF_SPARC_SUN_US3;
144
      break;
145
    case bfd_mach_sparc_sparclite_le :
146
      elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA;
147
      break;
148
    default :
149
      abort ();
150
      break;
151
    }
152
}
153
 
154
static enum elf_reloc_type_class
155
elf32_sparc_reloc_type_class (const Elf_Internal_Rela *rela)
156
{
157
  switch ((int) ELF32_R_TYPE (rela->r_info))
158
    {
159
    case R_SPARC_RELATIVE:
160
      return reloc_class_relative;
161
    case R_SPARC_JMP_SLOT:
162
      return reloc_class_plt;
163
    case R_SPARC_COPY:
164
      return reloc_class_copy;
165
    default:
166
      return reloc_class_normal;
167
    }
168
}
169
 
170
/* Hook called by the linker routine which adds symbols from an object
171
   file.  */
172
 
173
static bfd_boolean
174
elf32_sparc_add_symbol_hook (bfd * abfd,
175
                             struct bfd_link_info * info ATTRIBUTE_UNUSED,
176
                             Elf_Internal_Sym * sym,
177
                             const char ** namep ATTRIBUTE_UNUSED,
178
                             flagword * flagsp ATTRIBUTE_UNUSED,
179
                             asection ** secp ATTRIBUTE_UNUSED,
180
                             bfd_vma * valp ATTRIBUTE_UNUSED)
181
{
182
  if ((abfd->flags & DYNAMIC) == 0
183
      && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
184
          || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
185
    elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
186
  return TRUE;
187
}
188
 
189
#define TARGET_BIG_SYM  bfd_elf32_sparc_vec
190
#define TARGET_BIG_NAME "elf32-sparc"
191
#define ELF_ARCH        bfd_arch_sparc
192
#define ELF_TARGET_ID   SPARC_ELF_DATA
193
#define ELF_MACHINE_CODE EM_SPARC
194
#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
195
#define ELF_MAXPAGESIZE 0x10000
196
#define ELF_COMMONPAGESIZE 0x2000
197
 
198
#define bfd_elf32_bfd_merge_private_bfd_data \
199
                                        elf32_sparc_merge_private_bfd_data
200
#define elf_backend_final_write_processing \
201
                                        elf32_sparc_final_write_processing
202
#define elf_backend_grok_psinfo         elf32_sparc_grok_psinfo
203
#define elf_backend_reloc_type_class    elf32_sparc_reloc_type_class
204
 
205
#define elf_info_to_howto               _bfd_sparc_elf_info_to_howto
206
#define bfd_elf32_bfd_reloc_type_lookup _bfd_sparc_elf_reloc_type_lookup
207
#define bfd_elf32_bfd_reloc_name_lookup \
208
  _bfd_sparc_elf_reloc_name_lookup
209
#define bfd_elf32_bfd_link_hash_table_create \
210
                                        _bfd_sparc_elf_link_hash_table_create
211
#define bfd_elf32_bfd_link_hash_table_free \
212
                                        _bfd_sparc_elf_link_hash_table_free
213
#define bfd_elf32_bfd_relax_section     _bfd_sparc_elf_relax_section
214
#define bfd_elf32_new_section_hook      _bfd_sparc_elf_new_section_hook
215
#define elf_backend_copy_indirect_symbol \
216
                                        _bfd_sparc_elf_copy_indirect_symbol
217
#define elf_backend_create_dynamic_sections \
218
                                        _bfd_sparc_elf_create_dynamic_sections
219
#define elf_backend_check_relocs        _bfd_sparc_elf_check_relocs
220
#define elf_backend_adjust_dynamic_symbol \
221
                                        _bfd_sparc_elf_adjust_dynamic_symbol
222
#define elf_backend_omit_section_dynsym _bfd_sparc_elf_omit_section_dynsym
223
#define elf_backend_size_dynamic_sections \
224
                                        _bfd_sparc_elf_size_dynamic_sections
225
#define elf_backend_relocate_section    _bfd_sparc_elf_relocate_section
226
#define elf_backend_finish_dynamic_symbol \
227
                                        _bfd_sparc_elf_finish_dynamic_symbol
228
#define elf_backend_finish_dynamic_sections \
229
                                        _bfd_sparc_elf_finish_dynamic_sections
230
#define bfd_elf32_mkobject              _bfd_sparc_elf_mkobject
231
#define elf_backend_object_p            _bfd_sparc_elf_object_p
232
#define elf_backend_gc_mark_hook        _bfd_sparc_elf_gc_mark_hook
233
#define elf_backend_gc_sweep_hook       _bfd_sparc_elf_gc_sweep_hook
234
#define elf_backend_plt_sym_val         _bfd_sparc_elf_plt_sym_val
235
#define elf_backend_init_index_section  _bfd_elf_init_1_index_section
236
 
237
#define elf_backend_can_gc_sections 1
238
#define elf_backend_can_refcount 1
239
#define elf_backend_want_got_plt 0
240
#define elf_backend_plt_readonly 0
241
#define elf_backend_want_plt_sym 1
242
#define elf_backend_got_header_size 4
243
#define elf_backend_rela_normal 1
244
 
245
#define elf_backend_post_process_headers        _bfd_elf_set_osabi
246
#define elf_backend_add_symbol_hook             elf32_sparc_add_symbol_hook
247
 
248
#include "elf32-target.h"
249
 
250
/* Solaris 2.  */
251
 
252
#undef  TARGET_BIG_SYM
253
#define TARGET_BIG_SYM                          bfd_elf32_sparc_sol2_vec
254
#undef  TARGET_BIG_NAME
255
#define TARGET_BIG_NAME                         "elf32-sparc-sol2"
256
 
257
#undef elf32_bed
258
#define elf32_bed                               elf32_sparc_sol2_bed
259
 
260
/* The 32-bit static TLS arena size is rounded to the nearest 8-byte
261
   boundary.  */
262
#undef elf_backend_static_tls_alignment
263
#define elf_backend_static_tls_alignment        8
264
 
265
#include "elf32-target.h"
266
 
267
/* A wrapper around _bfd_sparc_elf_link_hash_table_create that identifies
268
   the target system as VxWorks.  */
269
 
270
static struct bfd_link_hash_table *
271
elf32_sparc_vxworks_link_hash_table_create (bfd *abfd)
272
{
273
  struct bfd_link_hash_table *ret;
274
 
275
  ret = _bfd_sparc_elf_link_hash_table_create (abfd);
276
  if (ret)
277
    {
278
      struct _bfd_sparc_elf_link_hash_table *htab;
279
 
280
      htab = (struct _bfd_sparc_elf_link_hash_table *) ret;
281
      htab->is_vxworks = 1;
282
    }
283
  return ret;
284
}
285
 
286
/* A final_write_processing hook that does both the SPARC- and VxWorks-
287
   specific handling.  */
288
 
289
static void
290
elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
291
{
292
  elf32_sparc_final_write_processing (abfd, linker);
293
  elf_vxworks_final_write_processing (abfd, linker);
294
}
295
 
296
#undef TARGET_BIG_SYM
297
#define TARGET_BIG_SYM  bfd_elf32_sparc_vxworks_vec
298
#undef TARGET_BIG_NAME
299
#define TARGET_BIG_NAME "elf32-sparc-vxworks"
300
 
301
#undef ELF_MINPAGESIZE
302
#define ELF_MINPAGESIZE 0x1000
303
 
304
#undef bfd_elf32_bfd_link_hash_table_create
305
#define bfd_elf32_bfd_link_hash_table_create \
306
  elf32_sparc_vxworks_link_hash_table_create
307
 
308
#undef elf_backend_want_got_plt
309
#define elf_backend_want_got_plt                1
310
#undef elf_backend_plt_readonly
311
#define elf_backend_plt_readonly                1
312
#undef elf_backend_got_header_size
313
#define elf_backend_got_header_size             12
314
#undef elf_backend_add_symbol_hook
315
#define elf_backend_add_symbol_hook \
316
  elf_vxworks_add_symbol_hook
317
#undef elf_backend_link_output_symbol_hook
318
#define elf_backend_link_output_symbol_hook \
319
  elf_vxworks_link_output_symbol_hook
320
#undef elf_backend_emit_relocs
321
#define elf_backend_emit_relocs \
322
  elf_vxworks_emit_relocs
323
#undef elf_backend_final_write_processing
324
#define elf_backend_final_write_processing \
325
  elf32_sparc_vxworks_final_write_processing
326
#undef elf_backend_static_tls_alignment
327
 
328
#undef elf32_bed
329
#define elf32_bed                               sparc_elf_vxworks_bed
330
 
331
#include "elf32-target.h"

powered by: WebSVN 2.1.0

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