Commit | Line | Data |
---|---|---|
a8acc5fb NC |
1 | /* Freescale XGATE-specific support for 32-bit ELF |
2 | Copyright 2012 Free Software Foundation, Inc. | |
3 | ||
4 | Contributed by Sean Keys (skeys@ipdatasys.com) | |
5 | (Heavily copied from the HC11 port by Stephane Carrez (stcarrez@nerim.fr)) | |
6 | ||
7 | This file is part of BFD, the Binary File Descriptor library. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 3 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
22 | MA 02110-1301, USA. */ | |
23 | ||
24 | #ifndef _ELF32_XGATE_H | |
25 | #define _ELF32_XGATE_H | |
26 | ||
27 | #include "elf-bfd.h" | |
28 | #include "bfdlink.h" | |
29 | #include "elf/xgate.h" | |
30 | ||
31 | /* Set and control ELF flags in ELF header. */ | |
32 | extern bfd_boolean _bfd_xgate_elf_merge_private_bfd_data (bfd*,bfd*); | |
33 | extern bfd_boolean _bfd_xgate_elf_set_private_flags (bfd*,flagword); | |
34 | extern bfd_boolean _bfd_xgate_elf_print_private_bfd_data (bfd*, void*); | |
35 | ||
36 | struct elf32_xgate_stub_hash_entry | |
37 | { | |
38 | /* Base hash table entry structure. */ | |
39 | struct bfd_hash_entry root; | |
40 | ||
41 | /* The stub section. */ | |
42 | asection *stub_sec; | |
43 | ||
44 | /* Offset within stub_sec of the beginning of this stub. */ | |
45 | bfd_vma stub_offset; | |
46 | ||
47 | /* Given the symbol's value and its section we can determine its final | |
48 | value when building the stubs (so the stub knows where to jump. */ | |
49 | bfd_vma target_value; | |
50 | asection *target_section; | |
51 | }; | |
52 | ||
53 | struct xgate_page_info | |
54 | { | |
55 | bfd_vma bank_virtual; | |
56 | bfd_vma bank_physical; | |
57 | bfd_vma bank_physical_end; | |
58 | bfd_vma bank_mask; | |
59 | bfd_vma bank_size; | |
60 | int bank_shift; | |
61 | int bank_param_initialized; | |
62 | bfd_vma trampoline_addr; | |
63 | }; | |
64 | ||
65 | struct xgate_elf_link_hash_table | |
66 | { | |
67 | struct elf_link_hash_table root; | |
68 | struct xgate_page_info pinfo; | |
69 | ||
70 | /* The stub hash table. */ | |
71 | struct bfd_hash_table* stub_hash_table; | |
72 | ||
73 | /* Linker stub bfd. */ | |
74 | bfd *stub_bfd; | |
75 | ||
76 | asection* stub_section; | |
77 | asection* tramp_section; | |
78 | ||
79 | /* Linker call-backs. */ | |
80 | asection * (*add_stub_section) (const char *, asection *); | |
81 | ||
82 | /* Assorted information used by elf32_hppa_size_stubs. */ | |
83 | unsigned int bfd_count; | |
84 | int top_index; | |
85 | asection ** input_list; | |
86 | ||
87 | /* Small local sym cache. */ | |
88 | struct sym_cache sym_cache; | |
89 | ||
90 | bfd_boolean (*size_one_stub) (struct bfd_hash_entry*, void*); | |
91 | bfd_boolean (*build_one_stub) (struct bfd_hash_entry*, void*); | |
92 | }; | |
93 | ||
94 | /* Get the XGate ELF linker hash table from a link_info structure. */ | |
95 | ||
96 | #define xgate_elf_hash_table(p) \ | |
97 | ((struct xgate_elf_link_hash_table *) ((p)->hash)) | |
98 | ||
99 | /* Create a XGATE ELF linker hash table. */ | |
100 | ||
101 | extern struct xgate_elf_link_hash_table* xgate_elf_hash_table_create | |
102 | (bfd *); | |
103 | extern void xgate_elf_bfd_link_hash_table_free (struct bfd_link_hash_table *); | |
104 | ||
105 | extern void xgate_elf_get_bank_parameters (struct bfd_link_info *); | |
106 | ||
107 | /* Return 1 if the address is in banked memory. | |
108 | This can be applied to a virtual address and to a physical address. */ | |
109 | extern int xgate_addr_is_banked (struct xgate_page_info *, bfd_vma); | |
110 | ||
111 | /* Return the physical address seen by the processor, taking | |
112 | into account banked memory. */ | |
113 | extern bfd_vma xgate_phys_addr (struct xgate_page_info *, bfd_vma); | |
114 | ||
115 | /* Return the page number corresponding to an address in banked memory. */ | |
116 | extern bfd_vma xgate_phys_page (struct xgate_page_info *, bfd_vma); | |
117 | ||
118 | bfd_reloc_status_type xgate_elf_ignore_reloc | |
119 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); | |
120 | bfd_reloc_status_type xgate_elf_special_reloc | |
121 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); | |
122 | ||
123 | bfd_boolean elf32_xgate_check_relocs | |
124 | (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); | |
125 | bfd_boolean elf32_xgate_relocate_section | |
126 | (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
127 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **); | |
128 | ||
129 | bfd_boolean elf32_xgate_add_symbol_hook | |
130 | (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, | |
131 | flagword *, asection **, bfd_vma *); | |
132 | ||
133 | /* Tweak the OSABI field of the elf header. */ | |
134 | extern void elf32_xgate_post_process_headers (bfd *, struct bfd_link_info *); | |
135 | ||
136 | int elf32_xgate_setup_section_lists (bfd *, struct bfd_link_info *); | |
137 | ||
138 | bfd_boolean elf32_xgate_size_stubs | |
139 | (bfd *, bfd *, struct bfd_link_info *, | |
140 | asection * (*) (const char *, asection *)); | |
141 | ||
142 | bfd_boolean elf32_xgate_build_stubs (bfd * abfd, struct bfd_link_info *); | |
143 | ||
144 | #endif /* _ELF32_XGATE_H */ |