1218885Sdim/* SH ELF support for BFD.
2218885Sdim   Copyright 2003 Free Software Foundation, Inc.
3218885Sdim
4218885Sdim   This file is part of BFD, the Binary File Descriptor library.
5218885Sdim
6218885Sdim   This program is free software; you can redistribute it and/or modify
7218885Sdim   it under the terms of the GNU General Public License as published by
8218885Sdim   the Free Software Foundation; either version 2 of the License, or
9218885Sdim   (at your option) any later version.
10218885Sdim
11218885Sdim   This program is distributed in the hope that it will be useful,
12218885Sdim   but WITHOUT ANY WARRANTY; without even the implied warranty of
13218885Sdim   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14218885Sdim   GNU General Public License for more details.
15218885Sdim
16218885Sdim   You should have received a copy of the GNU General Public License
17218885Sdim   along with this program; if not, write to the Free Software Foundation,
18218885Sdim   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19218885Sdim
20218885Sdim#ifndef ELF32_SH64_H
21218885Sdim#define ELF32_SH64_H
22218885Sdim
23218885Sdim#define SH64_CRANGES_SECTION_NAME ".cranges"
24218885Sdimenum sh64_elf_cr_type {
25234353Sdim  CRT_NONE = 0,
26234353Sdim  CRT_DATA = 1,
27234353Sdim  CRT_SH5_ISA16 = 2,
28234353Sdim  CRT_SH5_ISA32 = 3
29234353Sdim};
30234353Sdim
31234353Sdim/* The official definition is this:
32234353Sdim
33234353Sdim    typedef struct {
34218885Sdim      Elf32_Addr cr_addr;
35218885Sdim      Elf32_Word cr_size;
36218885Sdim      Elf32_Half cr_type;
37249423Sdim    } Elf32_CRange;
38234353Sdim
39218885Sdim   but we have no use for that exact type.  Instead we use this struct for
40218885Sdim   the internal representation.  */
41218885Sdimtypedef struct {
42218885Sdim  bfd_vma cr_addr;
43218885Sdim  bfd_size_type cr_size;
44218885Sdim  enum sh64_elf_cr_type cr_type;
45218885Sdim} sh64_elf_crange;
46218885Sdim
47234353Sdim#define SH64_CRANGE_SIZE (4 + 4 + 2)
48234353Sdim#define SH64_CRANGE_CR_ADDR_OFFSET 0
49234353Sdim#define SH64_CRANGE_CR_SIZE_OFFSET 4
50234353Sdim#define SH64_CRANGE_CR_TYPE_OFFSET (4 + 4)
51218885Sdim
52218885Sdim/* Get the contents type of an arbitrary address, or return CRT_NONE.  */
53218885Sdimextern enum sh64_elf_cr_type sh64_get_contents_type
54218885Sdim  (asection *, bfd_vma, sh64_elf_crange *);
55218885Sdim
56/* Simpler interface.
57   FIXME: This seems redundant now that we export the interface above.  */
58extern bfd_boolean sh64_address_is_shmedia
59  (asection *, bfd_vma);
60
61extern int _bfd_sh64_crange_qsort_cmpb
62  (const void *, const void *);
63extern int _bfd_sh64_crange_qsort_cmpl
64  (const void *, const void *);
65extern int _bfd_sh64_crange_bsearch_cmpb
66  (const void *, const void *);
67extern int _bfd_sh64_crange_bsearch_cmpl
68  (const void *, const void *);
69
70struct sh64_section_data
71{
72  flagword contents_flags;
73
74  /* Only used in the cranges section, but we don't have an official
75     backend-specific bfd field.  */
76  bfd_size_type cranges_growth;
77};
78
79struct _sh64_elf_section_data
80{
81  struct bfd_elf_section_data elf;
82  struct sh64_section_data *sh64_info;
83};
84
85#define sh64_elf_section_data(sec) \
86  ((struct _sh64_elf_section_data *) elf_section_data (sec))
87
88#endif /* ELF32_SH64_H */
89