Home | History | Annotate | Download | only in bfd
      1 /* SH ELF support for BFD.
      2    Copyright (C) 2003-2014 Free Software Foundation, Inc.
      3 
      4    This file is part of BFD, the Binary File Descriptor library.
      5 
      6    This program is free software; you can redistribute it and/or modify
      7    it under the terms of the GNU General Public License as published by
      8    the Free Software Foundation; either version 3 of the License, or
      9    (at your option) any later version.
     10 
     11    This program is distributed in the hope that it will be useful,
     12    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14    GNU General Public License for more details.
     15 
     16    You should have received a copy of the GNU General Public License
     17    along with this program; if not, write to the Free Software Foundation,
     18    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
     19 
     20 #ifndef ELF32_SH64_H
     21 #define ELF32_SH64_H
     22 
     23 #define SH64_CRANGES_SECTION_NAME ".cranges"
     24 enum sh64_elf_cr_type {
     25   CRT_NONE = 0,
     26   CRT_DATA = 1,
     27   CRT_SH5_ISA16 = 2,
     28   CRT_SH5_ISA32 = 3
     29 };
     30 
     31 /* The official definition is this:
     32 
     33     typedef struct {
     34       Elf32_Addr cr_addr;
     35       Elf32_Word cr_size;
     36       Elf32_Half cr_type;
     37     } Elf32_CRange;
     38 
     39    but we have no use for that exact type.  Instead we use this struct for
     40    the internal representation.  */
     41 typedef struct {
     42   bfd_vma cr_addr;
     43   bfd_size_type cr_size;
     44   enum sh64_elf_cr_type cr_type;
     45 } sh64_elf_crange;
     46 
     47 #define SH64_CRANGE_SIZE (4 + 4 + 2)
     48 #define SH64_CRANGE_CR_ADDR_OFFSET 0
     49 #define SH64_CRANGE_CR_SIZE_OFFSET 4
     50 #define SH64_CRANGE_CR_TYPE_OFFSET (4 + 4)
     51 
     52 /* Get the contents type of an arbitrary address, or return CRT_NONE.  */
     53 extern enum sh64_elf_cr_type sh64_get_contents_type
     54   (asection *, bfd_vma, sh64_elf_crange *);
     55 
     56 /* Simpler interface.
     57    FIXME: This seems redundant now that we export the interface above.  */
     58 extern bfd_boolean sh64_address_is_shmedia
     59   (asection *, bfd_vma);
     60 
     61 extern int _bfd_sh64_crange_qsort_cmpb
     62   (const void *, const void *);
     63 extern int _bfd_sh64_crange_qsort_cmpl
     64   (const void *, const void *);
     65 extern int _bfd_sh64_crange_bsearch_cmpb
     66   (const void *, const void *);
     67 extern int _bfd_sh64_crange_bsearch_cmpl
     68   (const void *, const void *);
     69 
     70 struct 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 
     79 struct _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