Commit | Line | Data |
---|---|---|
35c08157 | 1 | /* NDS32-specific support for 32-bit ELF. |
b3adc24a | 2 | Copyright (C) 2012-2020 Free Software Foundation, Inc. |
35c08157 KLC |
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 | ||
1fe0971e TS |
25 | #ifdef __cplusplus |
26 | extern "C" { | |
27 | #endif | |
28 | ||
35c08157 KLC |
29 | /* Relocation flags encoded in r_addend. */ |
30 | ||
31 | /* Relocation flags for R_NDS32_ERLAX_ENTRY. */ | |
32 | ||
33 | /* Set if relax on this section is done or disabled. */ | |
13c9c485 | 34 | #define R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG (1u << 31) |
35c08157 | 35 | /* Optimize for performance. */ |
13c9c485 | 36 | #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FLAG (1u << 30) |
35c08157 KLC |
37 | /* Optimize for size. Branch destination 4-byte adjustment |
38 | may be disabled. */ | |
13c9c485 | 39 | #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FOR_SPACE_FLAG (1u << 29) |
35c08157 KLC |
40 | /* To distinguish the assembly code generated by compiler |
41 | or written manually. */ | |
13c9c485 | 42 | #define R_NDS32_RELAX_ENTRY_VERBATIM_FLAG (1u << 28) |
e859f655 KLC |
43 | /* Two bits for ICT to comply with files without directive. */ |
44 | /* ICT small model. */ | |
13c9c485 | 45 | #define R_NDS32_RELAX_ENTRY_ICT_SMALL (0x2u << 4) |
e859f655 | 46 | /* ICT large model. */ |
13c9c485 | 47 | #define R_NDS32_RELAX_ENTRY_ICT_LARGE (0x3u << 4) |
e859f655 | 48 | /* Mask for get ict bits. */ |
13c9c485 | 49 | #define R_NDS32_RELAX_ENTRY_ICT_MASK (0x3u << 4) |
35c08157 KLC |
50 | |
51 | ||
52 | /* Relocation flags for R_NDS32_INSN16. */ | |
53 | ||
1c8f6a4d | 54 | /* Tag the nop16 can be removed. */ |
13c9c485 | 55 | #define R_NDS32_INSN16_CONVERT_FLAG (1u << 0) |
35c08157 KLC |
56 | /* Convert a gp-relative access (e.g., lwi.gp) |
57 | to fp-as-gp access (lwi37.fp). | |
58 | This value is used by linker internally only. | |
59 | It's fine to change the vlaue. */ | |
13c9c485 | 60 | #define R_NDS32_INSN16_FP7U2_FLAG (1u << 1) |
35c08157 KLC |
61 | |
62 | /* Relocation flags for R_NDS32_RELAX_REGION_OMIT_FP_START/END. */ | |
63 | ||
64 | /* OMIT_FP_FLAG marks the region for applying fp-as-gp | |
65 | optimization. */ | |
13c9c485 | 66 | #define R_NDS32_RELAX_REGION_OMIT_FP_FLAG (1u << 0) |
35c08157 KLC |
67 | /* NOT_OMIT_FP_FLAG is set if this region is not worth |
68 | for fp-as-gp. */ | |
13c9c485 | 69 | #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG (1u << 1) |
35c08157 KLC |
70 | /* A Innermost loop region. Some optimizations is suppressed |
71 | in this region due to performance drop. */ | |
13c9c485 | 72 | #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG (1u << 4) |
35c08157 | 73 | |
1c8f6a4d KLC |
74 | /* Tag range for LOADSTORE relocation. */ |
75 | enum | |
76 | { | |
77 | NDS32_LOADSTORE_NONE = 0x0, | |
78 | NDS32_LOADSTORE_BYTE = 0x1, | |
79 | NDS32_LOADSTORE_HALF = 0x2, | |
80 | NDS32_LOADSTORE_WORD = 0x4, | |
81 | NDS32_LOADSTORE_FLOAT_S = 0x8, | |
82 | NDS32_LOADSTORE_FLOAT_D = 0x10, | |
83 | NDS32_LOADSTORE_IMM = 0x20 | |
84 | }; | |
85 | ||
fbaf61ad | 86 | struct section_id_list_t |
35c08157 | 87 | { |
fbaf61ad NC |
88 | int id; |
89 | struct section_id_list_t *next; | |
35c08157 KLC |
90 | }; |
91 | ||
fbaf61ad NC |
92 | extern struct section_id_list_t *elf32_nds32_lookup_section_id |
93 | (int, struct section_id_list_t **); | |
94 | extern int elf32_nds32_check_relax_group (bfd *, asection *); | |
95 | extern int elf32_nds32_unify_relax_group (bfd *, asection *); | |
96 | extern int nds32_elf_unify_tls_model (bfd *, asection *, bfd_byte *, | |
97 | struct bfd_link_info *); | |
35c08157 | 98 | extern void nds32_insertion_sort |
fbaf61ad | 99 | (void *, size_t, size_t, int (*) (const void *, const void *)); |
35c08157 | 100 | |
07d6d2b8 AM |
101 | extern int nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *); |
102 | extern int nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *); | |
103 | extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *, | |
fbaf61ad NC |
104 | int, int, FILE *, |
105 | int, int, int); | |
35c08157 KLC |
106 | |
107 | #define nds32_elf_hash_table(info) \ | |
108 | (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \ | |
1c8f6a4d KLC |
109 | == NDS32_ELF_DATA ? \ |
110 | ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL) | |
35c08157 | 111 | |
fbaf61ad NC |
112 | #define elf32_nds32_compute_jump_table_size(htab) \ |
113 | ((htab)->next_tls_desc_index * 4) | |
114 | ||
115 | #define elf32_nds32_local_tlsdesc_gotent(bfd) \ | |
116 | (elf_nds32_tdata (bfd)->local_tlsdesc_gotent) | |
117 | ||
35c08157 KLC |
118 | /* Hash table structure for target nds32. There are some members to |
119 | save target options passed from nds32elf.em to bfd. */ | |
120 | ||
121 | struct elf_nds32_link_hash_table | |
122 | { | |
123 | struct elf_link_hash_table root; | |
124 | ||
125 | /* Short-cuts to get to dynamic linker sections. */ | |
35c08157 KLC |
126 | asection *sdynbss; |
127 | asection *srelbss; | |
128 | ||
129 | /* Small local sym to section mapping cache. */ | |
130 | struct sym_cache sym_cache; | |
131 | ||
132 | /* Target dependent options. */ | |
fbaf61ad NC |
133 | int relax_fp_as_gp; /* --mrelax-omit-fp. */ |
134 | int eliminate_gc_relocs; /* --meliminate-gc-relocs. */ | |
135 | FILE *sym_ld_script; /* --mgen-symbol-ld-script=<file>. */ | |
136 | bfd_boolean hyper_relax; /* Relax for symbol not in RW sections. */ | |
137 | int tls_desc_trampoline; /* --m[no-]tlsdesc-trampoline. */ | |
35c08157 KLC |
138 | /* Disable if linking a dynamically linked executable. */ |
139 | int load_store_relax; | |
fbaf61ad NC |
140 | |
141 | /* The offset into splt of the PLT entry for the TLS descriptor | |
142 | resolver. Special values are 0, if not necessary (or not found | |
143 | to be necessary yet), and -1 if needed but not determined | |
144 | yet. */ | |
145 | bfd_vma dt_tlsdesc_plt; | |
146 | ||
147 | /* The offset into sgot of the GOT entry used by the PLT entry | |
148 | above. */ | |
149 | bfd_vma dt_tlsdesc_got; | |
150 | ||
151 | /* Offset in .plt section of tls_nds32_trampoline. */ | |
152 | bfd_vma tls_trampoline; | |
153 | ||
154 | /* The index of the next unused R_NDS32_TLS_DESC slot in .rel.plt. */ | |
155 | bfd_vma next_tls_desc_index; | |
156 | ||
157 | /* How many R_NDS32_TLS_DESC relocations were generated so far. */ | |
158 | bfd_vma num_tls_desc; | |
159 | ||
160 | /* The amount of space used by the reserved portion of the sgotplt | |
161 | section, plus whatever space is used by the jump slots. */ | |
162 | bfd_vma sgotplt_jump_table_size; | |
163 | ||
164 | /* True if the target uses REL relocations. */ | |
165 | int use_rel; | |
35c08157 | 166 | }; |
1fe0971e TS |
167 | |
168 | #ifdef __cplusplus | |
169 | } | |
170 | #endif | |
171 | ||
fbaf61ad | 172 | #endif /* ELF32_NDS32_H */ |