OLD | NEW |
1 /* BFD back-end for PowerPC Microsoft Portable Executable files. | 1 /* BFD back-end for PowerPC Microsoft Portable Executable files. |
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, |
4 Free Software Foundation, Inc. | 4 2012 Free Software Foundation, Inc. |
5 | 5 |
6 Original version pieced together by Kim Knuttila (krk@cygnus.com) | 6 Original version pieced together by Kim Knuttila (krk@cygnus.com) |
7 | 7 |
8 There is nothing new under the sun. This file draws a lot on other | 8 There is nothing new under the sun. This file draws a lot on other |
9 coff files, in particular, those for the rs/6000, alpha, mips, and | 9 coff files, in particular, those for the rs/6000, alpha, mips, and |
10 intel backends, and the PE work for the arm. | 10 intel backends, and the PE work for the arm. |
11 | 11 |
12 This file is part of BFD, the Binary File Descriptor library. | 12 This file is part of BFD, the Binary File Descriptor library. |
13 | 13 |
14 This program is free software; you can redistribute it and/or modify | 14 This program is free software; you can redistribute it and/or modify |
(...skipping 30 matching lines...) Expand all Loading... |
45 #ifdef BADMAG | 45 #ifdef BADMAG |
46 #undef BADMAG | 46 #undef BADMAG |
47 #endif | 47 #endif |
48 | 48 |
49 #define BADMAG(x) PPCBADMAG(x) | 49 #define BADMAG(x) PPCBADMAG(x) |
50 | 50 |
51 #include "libcoff.h" | 51 #include "libcoff.h" |
52 | 52 |
53 /* This file is compiled more than once, but we only compile the | 53 /* This file is compiled more than once, but we only compile the |
54 final_link routine once. */ | 54 final_link routine once. */ |
55 extern bfd_boolean ppc_bfd_coff_final_link | 55 extern bfd_boolean ppc_bfd_coff_final_link (bfd *, struct bfd_link_info *); |
56 PARAMS ((bfd *, struct bfd_link_info *)); | 56 extern void dump_toc (void *); |
57 extern void dump_toc PARAMS ((PTR)); | |
58 | 57 |
59 /* The toc is a set of bfd_vma fields. We use the fact that valid | 58 /* The toc is a set of bfd_vma fields. We use the fact that valid |
60 addresses are even (i.e. the bit representing "1" is off) to allow | 59 addresses are even (i.e. the bit representing "1" is off) to allow |
61 us to encode a little extra information in the field | 60 us to encode a little extra information in the field |
62 - Unallocated addresses are initialized to 1. | 61 - Unallocated addresses are initialized to 1. |
63 - Allocated addresses are even numbers. | 62 - Allocated addresses are even numbers. |
64 The first time we actually write a reference to the toc in the bfd, | 63 The first time we actually write a reference to the toc in the bfd, |
65 we want to record that fact in a fixup file (if it is asked for), so | 64 we want to record that fact in a fixup file (if it is asked for), so |
66 we keep track of whether or not an address has been written by marking | 65 we keep track of whether or not an address has been written by marking |
67 the low order bit with a "1" upon writing. */ | 66 the low order bit with a "1" upon writing. */ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 HASH_CHECK_DCL | 115 HASH_CHECK_DCL |
117 }; | 116 }; |
118 | 117 |
119 /* PE linker hash table. */ | 118 /* PE linker hash table. */ |
120 | 119 |
121 struct ppc_coff_link_hash_table | 120 struct ppc_coff_link_hash_table |
122 { | 121 { |
123 struct coff_link_hash_table root; /* First entry, as required. */ | 122 struct coff_link_hash_table root; /* First entry, as required. */ |
124 }; | 123 }; |
125 | 124 |
126 static struct bfd_hash_entry *ppc_coff_link_hash_newfunc | |
127 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, | |
128 const char *)); | |
129 static struct bfd_link_hash_table *ppc_coff_link_hash_table_create | |
130 PARAMS ((bfd *)); | |
131 static bfd_boolean coff_ppc_relocate_section | |
132 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
133 struct internal_reloc *, struct internal_syment *, asection **)); | |
134 static reloc_howto_type *coff_ppc_rtype_to_howto | |
135 PARAMS ((bfd *, asection *, struct internal_reloc *, | |
136 struct coff_link_hash_entry *, struct internal_syment *, | |
137 bfd_vma *)); | |
138 | |
139 /* Routine to create an entry in the link hash table. */ | 125 /* Routine to create an entry in the link hash table. */ |
140 | 126 |
141 static struct bfd_hash_entry * | 127 static struct bfd_hash_entry * |
142 ppc_coff_link_hash_newfunc (entry, table, string) | 128 ppc_coff_link_hash_newfunc (struct bfd_hash_entry * entry, |
143 struct bfd_hash_entry *entry; | 129 » » » struct bfd_hash_table * table, |
144 struct bfd_hash_table *table; | 130 » » » const char * string) |
145 const char *string; | |
146 { | 131 { |
147 struct ppc_coff_link_hash_entry *ret = | 132 struct ppc_coff_link_hash_entry *ret = |
148 (struct ppc_coff_link_hash_entry *) entry; | 133 (struct ppc_coff_link_hash_entry *) entry; |
149 | 134 |
150 /* Allocate the structure if it has not already been allocated by a | 135 /* Allocate the structure if it has not already been allocated by a |
151 subclass. */ | 136 subclass. */ |
152 if (ret == (struct ppc_coff_link_hash_entry *) NULL) | 137 if (ret == (struct ppc_coff_link_hash_entry *) NULL) |
153 ret = (struct ppc_coff_link_hash_entry *) | 138 ret = (struct ppc_coff_link_hash_entry *) |
154 bfd_hash_allocate (table, | 139 bfd_hash_allocate (table, |
155 sizeof (struct ppc_coff_link_hash_entry)); | 140 sizeof (struct ppc_coff_link_hash_entry)); |
(...skipping 17 matching lines...) Expand all Loading... |
173 } | 158 } |
174 | 159 |
175 return (struct bfd_hash_entry *) ret; | 160 return (struct bfd_hash_entry *) ret; |
176 } | 161 } |
177 | 162 |
178 /* Initialize a PE linker hash table. */ | 163 /* Initialize a PE linker hash table. */ |
179 | 164 |
180 static bfd_boolean | 165 static bfd_boolean |
181 ppc_coff_link_hash_table_init (struct ppc_coff_link_hash_table *table, | 166 ppc_coff_link_hash_table_init (struct ppc_coff_link_hash_table *table, |
182 bfd *abfd, | 167 bfd *abfd, |
183 » » » struct bfd_hash_entry *(*newfunc) (struct bfd_has
h_entry *, | 168 » » » struct bfd_hash_entry *(*newfunc) |
184 » » » » » » » » struct bfd_has
h_table *, | 169 » » » (struct bfd_hash_entry *, |
185 » » » » » » » » const char *), | 170 » » » » struct bfd_hash_table *, |
| 171 » » » » const char *), |
186 unsigned int entsize) | 172 unsigned int entsize) |
187 { | 173 { |
188 return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc, entsize); | 174 return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc, entsize); |
189 } | 175 } |
190 | 176 |
191 /* Create a PE linker hash table. */ | 177 /* Create a PE linker hash table. */ |
192 | 178 |
193 static struct bfd_link_hash_table * | 179 static struct bfd_link_hash_table * |
194 ppc_coff_link_hash_table_create (abfd) | 180 ppc_coff_link_hash_table_create (bfd *abfd) |
195 bfd *abfd; | |
196 { | 181 { |
197 struct ppc_coff_link_hash_table *ret; | 182 struct ppc_coff_link_hash_table *ret; |
198 bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table); | 183 bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table); |
199 | 184 |
200 ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt); | 185 ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt); |
201 if (ret == NULL) | 186 if (ret == NULL) |
202 return NULL; | 187 return NULL; |
203 if (!ppc_coff_link_hash_table_init (ret, abfd, | 188 if (!ppc_coff_link_hash_table_init (ret, abfd, |
204 ppc_coff_link_hash_newfunc, | 189 ppc_coff_link_hash_newfunc, |
205 sizeof (struct ppc_coff_link_hash_entry))) | 190 sizeof (struct ppc_coff_link_hash_entry))) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 #define IMAGE_REL_PPC_TOCDEFN 0x0800 | 289 #define IMAGE_REL_PPC_TOCDEFN 0x0800 |
305 | 290 |
306 /* Masks to isolate above values in IMAGE_RELOCATION.Type. */ | 291 /* Masks to isolate above values in IMAGE_RELOCATION.Type. */ |
307 #define IMAGE_REL_PPC_TYPEMASK 0x00FF | 292 #define IMAGE_REL_PPC_TYPEMASK 0x00FF |
308 #define IMAGE_REL_PPC_FLAGMASK 0x0F00 | 293 #define IMAGE_REL_PPC_FLAGMASK 0x0F00 |
309 | 294 |
310 #define EXTRACT_TYPE(x) ((x) & IMAGE_REL_PPC_TYPEMASK) | 295 #define EXTRACT_TYPE(x) ((x) & IMAGE_REL_PPC_TYPEMASK) |
311 #define EXTRACT_FLAGS(x) ((x) & IMAGE_REL_PPC_FLAGMASK) | 296 #define EXTRACT_FLAGS(x) ((x) & IMAGE_REL_PPC_FLAGMASK) |
312 #define EXTRACT_JUNK(x) \ | 297 #define EXTRACT_JUNK(x) \ |
313 ((x) & ~(IMAGE_REL_PPC_TYPEMASK | IMAGE_REL_PPC_FLAGMASK)) | 298 ((x) & ~(IMAGE_REL_PPC_TYPEMASK | IMAGE_REL_PPC_FLAGMASK)) |
error: old chunk mismatch |
None
OLD | NEW |