]>
Commit | Line | Data |
---|---|---|
35c08157 KLC |
1 | /* NDS32-specific support for 32-bit ELF. |
2 | Copyright (C) 2012-2013 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 | #define R_NDS32_INSN16_CONVERT_FLAG (1 << 0) | |
50 | /* Convert a gp-relative access (e.g., lwi.gp) | |
51 | to fp-as-gp access (lwi37.fp). | |
52 | This value is used by linker internally only. | |
53 | It's fine to change the vlaue. */ | |
54 | #define R_NDS32_INSN16_FP7U2_FLAG (1 << 1) | |
55 | ||
56 | /* Relocation flags for R_NDS32_RELAX_REGION_OMIT_FP_START/END. */ | |
57 | ||
58 | /* OMIT_FP_FLAG marks the region for applying fp-as-gp | |
59 | optimization. */ | |
60 | #define R_NDS32_RELAX_REGION_OMIT_FP_FLAG (1 << 0) | |
61 | /* NOT_OMIT_FP_FLAG is set if this region is not worth | |
62 | for fp-as-gp. */ | |
63 | #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG (1 << 1) | |
64 | /* Suppress EX9 optimization in the region. */ | |
65 | #define R_NDS32_RELAX_REGION_NO_EX9_FLAG (1 << 2) | |
66 | /* A Innermost loop region. Some optimizations is suppressed | |
67 | in this region due to performance drop. */ | |
68 | #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG (1 << 4) | |
69 | ||
70 | /* Relax tag for nds32_elf_relax_section, we have to specify which | |
71 | optimization do in this round. */ | |
72 | enum | |
73 | { | |
74 | NDS32_RELAX_NONE_ROUND = 0, | |
75 | NDS32_RELAX_JUMP_IFC_ROUND = 1, | |
76 | NDS32_RELAX_EX9_BUILD_ROUND, | |
77 | NDS32_RELAX_EX9_REPLACE_ROUND | |
78 | ||
79 | }; | |
80 | ||
81 | /* Optimization status mask. */ | |
82 | #define NDS32_RELAX_JUMP_IFC_DONE (1 << 0) | |
83 | #define NDS32_RELAX_EX9_DONE (1 << 1) | |
84 | ||
85 | /* Optimization turn on mask. */ | |
86 | #define NDS32_RELAX_JUMP_IFC_ON (1 << 0) | |
87 | #define NDS32_RELAX_EX9_ON (1 << 1) | |
88 | ||
89 | /* The break 0xea defined for ex9 table to keep for trace32 to use 0xeaea. */ | |
90 | #define INSN_BREAK_EA 0x64001d4a | |
91 | \f | |
92 | extern void nds32_insertion_sort | |
93 | (void *, size_t, size_t, int (*) (const void *, const void *)); | |
94 | ||
95 | extern int nds32_elf_ex9_init (void); | |
96 | extern void nds32_elf_ex9_reloc_jmp (struct bfd_link_info *); | |
97 | extern void nds32_elf_ex9_finish (struct bfd_link_info *); | |
98 | extern bfd_boolean nds32_elf_ex9_itb_base (struct bfd_link_info *); | |
99 | extern void nds32_elf_ex9_import_table (struct bfd_link_info *); | |
100 | extern bfd_boolean nds32_elf_ifc_reloc (void); | |
101 | extern bfd_boolean nds32_elf_ifc_finish (struct bfd_link_info *); | |
102 | extern int nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *); | |
103 | extern int nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *); | |
104 | extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *, int, int, | |
105 | FILE *, int, int, int, int, FILE *, FILE *, | |
106 | int, int, bfd_boolean, bfd_boolean); | |
107 | ||
108 | #define nds32_elf_hash_table(info) \ | |
109 | (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \ | |
110 | == NDS32_ELF_DATA ? ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL) | |
111 | ||
112 | /* Hash table structure for target nds32. There are some members to | |
113 | save target options passed from nds32elf.em to bfd. */ | |
114 | ||
115 | struct elf_nds32_link_hash_table | |
116 | { | |
117 | struct elf_link_hash_table root; | |
118 | ||
119 | /* Short-cuts to get to dynamic linker sections. */ | |
120 | asection *sgot; | |
121 | asection *sgotplt; | |
122 | asection *srelgot; | |
123 | asection *splt; | |
124 | asection *srelplt; | |
125 | asection *sdynbss; | |
126 | asection *srelbss; | |
127 | ||
128 | /* Small local sym to section mapping cache. */ | |
129 | struct sym_cache sym_cache; | |
130 | ||
131 | /* Target dependent options. */ | |
132 | int relax_fp_as_gp; /* --mrelax-omit-fp */ | |
133 | int eliminate_gc_relocs; /* --meliminate-gc-relocs */ | |
134 | FILE *sym_ld_script; /* --mgen-symbol-ld-script=<file> */ | |
135 | /* Disable if linking a dynamically linked executable. */ | |
136 | int load_store_relax; | |
137 | int target_optimize; /* Switch optimization. */ | |
138 | int relax_status; /* Finished optimization. */ | |
139 | int relax_round; /* Going optimization. */ | |
140 | FILE *ex9_export_file; /* --mexport-ex9=<file> */ | |
141 | FILE *ex9_import_file; /* --mimport-ex9=<file> */ | |
142 | int update_ex9_table; /* --mupdate-ex9. */ | |
143 | int ex9_limit; | |
144 | bfd_boolean ex9_loop_aware; /* Ignore ex9 if inside a loop. */ | |
145 | bfd_boolean ifc_loop_aware; /* Ignore ifc if inside a loop. */ | |
146 | }; | |
147 | #endif |