Import gdb-7.10.1
[dragonfly.git] / contrib / gdb-7 / bfd / elf32-nds32.h
1 /* NDS32-specific support for 32-bit ELF.
2    Copyright (C) 2012-2015 Free Software Foundation, Inc.
3    Contributed by Andes Technology Corporation.
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, MA
20    02110-1301, USA.*/
21
22 #ifndef ELF32_NDS32_H
23 #define ELF32_NDS32_H
24
25 /* Relocation flags encoded in r_addend.  */
26
27 /* Relocation flags for R_NDS32_ERLAX_ENTRY.  */
28
29 /* Set if relax on this section is done or disabled.  */
30 #define R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG                  (1 << 31)
31 /* Optimize for performance.  */
32 #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FLAG                       (1 << 30)
33 /* Optimize for size.  Branch destination 4-byte adjustment
34    may be disabled.  */
35 #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FOR_SPACE_FLAG             (1 << 29)
36 /* To distinguish the assembly code generated by compiler
37    or written manually.  */
38 #define R_NDS32_RELAX_ENTRY_VERBATIM_FLAG                       (1 << 28)
39 /* EX9 and link-time IFC must be explicitly enabled, so we
40    won't mess up handcraft assembly code.  */
41 /* Enable EX9 optimization for this section.  */
42 #define R_NDS32_RELAX_ENTRY_EX9_FLAG                            (1 << 2)
43 /* Enable IFC optimization for this section.  */
44 #define R_NDS32_RELAX_ENTRY_IFC_FLAG                            (1 << 3)
45
46
47 /* Relocation flags for R_NDS32_INSN16.  */
48
49 /* Tag the nop16 can be removed.  */
50 #define R_NDS32_INSN16_CONVERT_FLAG                             (1 << 0)
51 /* Convert a gp-relative access (e.g., lwi.gp)
52    to fp-as-gp access (lwi37.fp).
53    This value is used by linker internally only.
54    It's fine to change the vlaue.  */
55 #define R_NDS32_INSN16_FP7U2_FLAG                               (1 << 1)
56
57 /* Relocation flags for R_NDS32_RELAX_REGION_OMIT_FP_START/END.  */
58
59 /* OMIT_FP_FLAG marks the region for applying fp-as-gp
60    optimization.  */
61 #define R_NDS32_RELAX_REGION_OMIT_FP_FLAG                       (1 << 0)
62 /* NOT_OMIT_FP_FLAG is set if this region is not worth
63    for fp-as-gp.  */
64 #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG                   (1 << 1)
65 /* Suppress EX9 optimization in the region.  */
66 #define R_NDS32_RELAX_REGION_NO_EX9_FLAG                        (1 << 2)
67 /* A Innermost loop region.  Some optimizations is suppressed
68    in this region due to performance drop.  */
69 #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG                (1 << 4)
70
71 /* Tag range for LOADSTORE relocation.  */
72 enum
73 {
74   NDS32_LOADSTORE_NONE = 0x0,
75   NDS32_LOADSTORE_BYTE = 0x1,
76   NDS32_LOADSTORE_HALF = 0x2,
77   NDS32_LOADSTORE_WORD = 0x4,
78   NDS32_LOADSTORE_FLOAT_S = 0x8,
79   NDS32_LOADSTORE_FLOAT_D = 0x10,
80   NDS32_LOADSTORE_IMM = 0x20
81 };
82
83 /* Relax tag for nds32_elf_relax_section, we have to specify which
84    optimization do in this round.  */
85 enum
86 {
87   NDS32_RELAX_NONE_ROUND = 0,
88   NDS32_RELAX_NORMAL_ROUND,
89   NDS32_RELAX_JUMP_IFC_ROUND,
90   NDS32_RELAX_EX9_BUILD_ROUND,
91   NDS32_RELAX_EX9_REPLACE_ROUND,
92   NDS32_RELAX_EMPTY_ROUND
93 };
94
95 /* Optimization status mask.  */
96 #define NDS32_RELAX_JUMP_IFC_DONE       (1 << 0)
97 #define NDS32_RELAX_EX9_DONE            (1 << 1)
98
99 /* Optimization turn on mask.  */
100 #define NDS32_RELAX_JUMP_IFC_ON         (1 << 0)
101 #define NDS32_RELAX_EX9_ON              (1 << 1)
102 \f
103 extern void nds32_insertion_sort
104   (void *, size_t, size_t, int (*) (const void *, const void *));
105
106 extern int         nds32_elf_ex9_init (void);
107 extern int         nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *);
108 extern int         nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *);
109 extern void        bfd_elf32_nds32_set_target_option (struct bfd_link_info *,
110                                                       int, int, FILE *, int,
111                                                       int, int, int, FILE *,
112                                                       FILE *, int, int,
113                                                       bfd_boolean, bfd_boolean);
114
115 #define nds32_elf_hash_table(info) \
116   (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
117    == NDS32_ELF_DATA ? \
118    ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL)
119
120 /* Hash table structure for target nds32.  There are some members to
121    save target options passed from nds32elf.em to bfd.  */
122
123 struct elf_nds32_link_hash_table
124 {
125   struct elf_link_hash_table root;
126
127   /* Short-cuts to get to dynamic linker sections.  */
128   asection *sgot;
129   asection *sgotplt;
130   asection *srelgot;
131   asection *splt;
132   asection *srelplt;
133   asection *sdynbss;
134   asection *srelbss;
135
136   /* Small local sym to section mapping cache.  */
137   struct sym_cache sym_cache;
138
139   /* Target dependent options.  */
140   int relax_fp_as_gp;           /* --mrelax-omit-fp  */
141   int eliminate_gc_relocs;      /* --meliminate-gc-relocs  */
142   FILE *sym_ld_script;          /* --mgen-symbol-ld-script=<file>  */
143   /* Disable if linking a dynamically linked executable.  */
144   int load_store_relax;
145   int target_optimize;          /* Switch optimization.  */
146   int relax_status;             /* Finished optimization.  */
147   int relax_round;              /* Going optimization.  */
148   FILE *ex9_export_file;        /* --mexport-ex9=<file>  */
149   FILE *ex9_import_file;        /* --mimport-ex9=<file>  */
150   int update_ex9_table;         /* --mupdate-ex9.  */
151   int ex9_limit;
152   bfd_boolean ex9_loop_aware;   /* Ignore ex9 if inside a loop.  */
153   bfd_boolean ifc_loop_aware;   /* Ignore ifc if inside a loop.  */
154 };
155 #endif