| OLD | NEW |
| 1 /* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub). | 1 /* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub). |
| 2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2007, 2009, | 2 Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2007, 2009, |
| 3 2011 Free Software Foundation, Inc. | 3 2011, 2012 Free Software Foundation, Inc. |
| 4 Written by Robert Hoehne. | 4 Written by Robert Hoehne. |
| 5 | 5 |
| 6 This file is part of BFD, the Binary File Descriptor library. | 6 This file is part of BFD, the Binary File Descriptor library. |
| 7 | 7 |
| 8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
| 9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
| 10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
| 11 (at your option) any later version. | 11 (at your option) any later version. |
| 12 | 12 |
| 13 This program is distributed in the hope that it will be useful, | 13 This program is distributed in the hope that it will be useful, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #define COFF_SECTION_ALIGNMENT_ENTRIES \ | 47 #define COFF_SECTION_ALIGNMENT_ENTRIES \ |
| 48 { COFF_SECTION_NAME_EXACT_MATCH (".data"), \ | 48 { COFF_SECTION_NAME_EXACT_MATCH (".data"), \ |
| 49 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ | 49 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ |
| 50 { COFF_SECTION_NAME_EXACT_MATCH (".text"), \ | 50 { COFF_SECTION_NAME_EXACT_MATCH (".text"), \ |
| 51 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ | 51 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \ |
| 52 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \ | 52 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \ |
| 53 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ | 53 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \ |
| 54 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \ | 54 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \ |
| 55 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } | 55 COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } |
| 56 | 56 |
| 57 #include "sysdep.h" |
| 57 #include "bfd.h" | 58 #include "bfd.h" |
| 58 | 59 |
| 59 /* At first the prototypes. */ | |
| 60 | |
| 61 static void | |
| 62 adjust_filehdr_in_post PARAMS ((bfd *, PTR, PTR)); | |
| 63 static void | |
| 64 adjust_filehdr_out_pre PARAMS ((bfd *, PTR, PTR)); | |
| 65 static void | |
| 66 adjust_filehdr_out_post PARAMS ((bfd *, PTR, PTR)); | |
| 67 static void | |
| 68 adjust_scnhdr_in_post PARAMS ((bfd *, PTR, PTR)); | |
| 69 static void | |
| 70 adjust_scnhdr_out_pre PARAMS ((bfd *, PTR, PTR)); | |
| 71 static void | |
| 72 adjust_scnhdr_out_post PARAMS ((bfd *, PTR, PTR)); | |
| 73 static void | |
| 74 adjust_aux_in_post PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
| 75 static void | |
| 76 adjust_aux_out_pre PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
| 77 static void | |
| 78 adjust_aux_out_post PARAMS ((bfd *, PTR, int, int, int, int, PTR)); | |
| 79 static void | |
| 80 create_go32_stub PARAMS ((bfd *)); | |
| 81 | |
| 82 /* All that ..._PRE and ...POST functions are called from the corresponding | 60 /* All that ..._PRE and ...POST functions are called from the corresponding |
| 83 coff_swap... functions. The ...PRE functions are called at the beginning | 61 coff_swap... functions. The ...PRE functions are called at the beginning |
| 84 of the function and the ...POST functions at the end of the swap routines. *
/ | 62 of the function and the ...POST functions at the end of the swap routines. *
/ |
| 85 | 63 |
| 64 static void |
| 65 adjust_filehdr_in_post (bfd *, void *, void *); |
| 66 static void |
| 67 adjust_filehdr_out_pre (bfd *, void *, void *); |
| 68 static void |
| 69 adjust_filehdr_out_post (bfd *, void *, void *); |
| 70 static void |
| 71 adjust_scnhdr_in_post (bfd *, void *, void *); |
| 72 static void |
| 73 adjust_scnhdr_out_pre (bfd *, void *, void *); |
| 74 static void |
| 75 adjust_scnhdr_out_post (bfd *, void *, void *); |
| 76 static void |
| 77 adjust_aux_in_post (bfd *, void *, int, int, int, int, void *); |
| 78 static void |
| 79 adjust_aux_out_pre (bfd *, void *, int, int, int, int, void *); |
| 80 static void |
| 81 adjust_aux_out_post (bfd *, void *, int, int, int, int, void *); |
| 82 static void |
| 83 create_go32_stub (bfd *); |
| 84 |
| 86 #define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post | 85 #define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post |
| 87 #define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre | 86 #define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre |
| 88 #define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post | 87 #define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post |
| 89 | 88 |
| 90 #define COFF_ADJUST_SCNHDR_IN_POST adjust_scnhdr_in_post | 89 #define COFF_ADJUST_SCNHDR_IN_POST adjust_scnhdr_in_post |
| 91 #define COFF_ADJUST_SCNHDR_OUT_PRE adjust_scnhdr_out_pre | 90 #define COFF_ADJUST_SCNHDR_OUT_PRE adjust_scnhdr_out_pre |
| 92 #define COFF_ADJUST_SCNHDR_OUT_POST adjust_scnhdr_out_post | 91 #define COFF_ADJUST_SCNHDR_OUT_POST adjust_scnhdr_out_post |
| 93 | 92 |
| 94 #define COFF_ADJUST_AUX_IN_POST adjust_aux_in_post | 93 #define COFF_ADJUST_AUX_IN_POST adjust_aux_in_post |
| 95 #define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre | 94 #define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre |
| 96 #define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post | 95 #define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post |
| 97 | 96 |
| 98 static const bfd_target *go32_check_format (bfd *abfd); | 97 static const bfd_target *go32_check_format (bfd *); |
| 99 | 98 |
| 100 #define COFF_CHECK_FORMAT go32_check_format | 99 #define COFF_CHECK_FORMAT go32_check_format |
| 101 | 100 |
| 102 static bfd_boolean | 101 static bfd_boolean |
| 103 go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); | 102 go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *, bfd *); |
| 104 | 103 |
| 105 #define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_da
ta | 104 #define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_da
ta |
| 106 | 105 |
| 107 #include "coff-i386.c" | 106 #include "coff-i386.c" |
| 108 | 107 |
| 109 /* This macro is used, because I cannot assume the endianness of the | 108 /* This macro is used, because I cannot assume the endianness of the |
| 110 host system. */ | 109 host system. */ |
| 111 #define _H(index) (H_GET_16 (abfd, (header + index * 2))) | 110 #define _H(index) (H_GET_16 (abfd, (header + index * 2))) |
| 112 | 111 |
| 113 /* These bytes are a 2048-byte DOS executable, which loads the COFF | 112 /* These bytes are a 2048-byte DOS executable, which loads the COFF |
| (...skipping 11 matching lines...) Expand all Loading... |
| 125 ...out function, it is subtracted first and after calling the | 124 ...out function, it is subtracted first and after calling the |
| 126 standard swap function it is reset to the old value. */ | 125 standard swap function it is reset to the old value. */ |
| 127 | 126 |
| 128 /* This macro is used for adjusting the filepointers, which | 127 /* This macro is used for adjusting the filepointers, which |
| 129 is done only, if the pointer is nonzero. */ | 128 is done only, if the pointer is nonzero. */ |
| 130 | 129 |
| 131 #define ADJUST_VAL(val,diff) \ | 130 #define ADJUST_VAL(val,diff) \ |
| 132 if (val != 0) val += diff | 131 if (val != 0) val += diff |
| 133 | 132 |
| 134 static void | 133 static void |
| 135 adjust_filehdr_in_post (abfd, src, dst) | 134 adjust_filehdr_in_post (bfd * abfd ATTRIBUTE_UNUSED, |
| 136 bfd *abfd ATTRIBUTE_UNUSED; | 135 » » » void * src, |
| 137 PTR src; | 136 » » » void * dst) |
| 138 PTR dst; | |
| 139 { | 137 { |
| 140 FILHDR *filehdr_src = (FILHDR *) src; | 138 FILHDR *filehdr_src = (FILHDR *) src; |
| 141 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; | 139 struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
| 142 | 140 |
| 143 ADJUST_VAL (filehdr_dst->f_symptr, GO32_STUBSIZE); | 141 ADJUST_VAL (filehdr_dst->f_symptr, GO32_STUBSIZE); |
| 144 | 142 |
| 145 /* Save now the stub to be used later. Put the stub data to FILEHDR_DST | 143 /* Save now the stub to be used later. Put the stub data to FILEHDR_DST |
| 146 first as coff_data (abfd) still does not exist. It may not even be ever | 144 first as coff_data (abfd) still does not exist. It may not even be ever |
| 147 created as we are just checking the file format of ABFD. */ | 145 created as we are just checking the file format of ABFD. */ |
| 148 memcpy (filehdr_dst->go32stub, filehdr_src->stub, GO32_STUBSIZE); | 146 memcpy (filehdr_dst->go32stub, filehdr_src->stub, GO32_STUBSIZE); |
| 149 filehdr_dst->f_flags |= F_GO32STUB; | 147 filehdr_dst->f_flags |= F_GO32STUB; |
| 150 } | 148 } |
| 151 | 149 |
| 152 static void | 150 static void |
| 153 adjust_filehdr_out_pre (abfd, in, out) | 151 adjust_filehdr_out_pre (bfd * abfd, void * in, void * out) |
| 154 bfd *abfd; | |
| 155 PTR in; | |
| 156 PTR out; | |
| 157 { | 152 { |
| 158 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; | 153 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; |
| 159 FILHDR *filehdr_out = (FILHDR *) out; | 154 FILHDR *filehdr_out = (FILHDR *) out; |
| 160 | 155 |
| 161 /* Generate the stub. */ | 156 /* Generate the stub. */ |
| 162 create_go32_stub (abfd); | 157 create_go32_stub (abfd); |
| 163 | 158 |
| 164 /* Copy the stub to the file header. */ | 159 /* Copy the stub to the file header. */ |
| 165 if (coff_data (abfd)->go32stub != NULL) | 160 if (coff_data (abfd)->go32stub != NULL) |
| 166 memcpy (filehdr_out->stub, coff_data (abfd)->go32stub, GO32_STUBSIZE); | 161 memcpy (filehdr_out->stub, coff_data (abfd)->go32stub, GO32_STUBSIZE); |
| 167 else | 162 else |
| 168 /* Use the default. */ | 163 /* Use the default. */ |
| 169 memcpy (filehdr_out->stub, stub_bytes, GO32_STUBSIZE); | 164 memcpy (filehdr_out->stub, stub_bytes, GO32_STUBSIZE); |
| 170 | 165 |
| 171 ADJUST_VAL (filehdr_in->f_symptr, -GO32_STUBSIZE); | 166 ADJUST_VAL (filehdr_in->f_symptr, -GO32_STUBSIZE); |
| 172 } | 167 } |
| 173 | 168 |
| 174 static void | 169 static void |
| 175 adjust_filehdr_out_post (abfd, in, out) | 170 adjust_filehdr_out_post (bfd * abfd ATTRIBUTE_UNUSED, |
| 176 bfd *abfd ATTRIBUTE_UNUSED; | 171 » » » void * in, |
| 177 PTR in; | 172 » » » void * out ATTRIBUTE_UNUSED) |
| 178 PTR out ATTRIBUTE_UNUSED; | |
| 179 { | 173 { |
| 180 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; | 174 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; |
| 181 /* Undo the above change. */ | 175 /* Undo the above change. */ |
| 182 ADJUST_VAL (filehdr_in->f_symptr, GO32_STUBSIZE); | 176 ADJUST_VAL (filehdr_in->f_symptr, GO32_STUBSIZE); |
| 183 } | 177 } |
| 184 | 178 |
| 185 static void | 179 static void |
| 186 adjust_scnhdr_in_post (abfd, ext, in) | 180 adjust_scnhdr_in_post (bfd * abfd ATTRIBUTE_UNUSED, |
| 187 bfd *abfd ATTRIBUTE_UNUSED; | 181 » » » void * ext ATTRIBUTE_UNUSED, |
| 188 PTR ext ATTRIBUTE_UNUSED; | 182 » » » void * in) |
| 189 PTR in; | |
| 190 { | 183 { |
| 191 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 184 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
| 192 | 185 |
| 193 ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE); | 186 ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE); |
| 194 ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE); | 187 ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE); |
| 195 ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE); | 188 ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE); |
| 196 } | 189 } |
| 197 | 190 |
| 198 static void | 191 static void |
| 199 adjust_scnhdr_out_pre (abfd, in, out) | 192 adjust_scnhdr_out_pre (bfd * abfd ATTRIBUTE_UNUSED, |
| 200 bfd *abfd ATTRIBUTE_UNUSED; | 193 » » » void * in, |
| 201 PTR in; | 194 » » » void * out ATTRIBUTE_UNUSED) |
| 202 PTR out ATTRIBUTE_UNUSED; | |
| 203 { | 195 { |
| 204 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 196 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
| 205 | 197 |
| 206 ADJUST_VAL (scnhdr_int->s_scnptr, -GO32_STUBSIZE); | 198 ADJUST_VAL (scnhdr_int->s_scnptr, -GO32_STUBSIZE); |
| 207 ADJUST_VAL (scnhdr_int->s_relptr, -GO32_STUBSIZE); | 199 ADJUST_VAL (scnhdr_int->s_relptr, -GO32_STUBSIZE); |
| 208 ADJUST_VAL (scnhdr_int->s_lnnoptr, -GO32_STUBSIZE); | 200 ADJUST_VAL (scnhdr_int->s_lnnoptr, -GO32_STUBSIZE); |
| 209 } | 201 } |
| 210 | 202 |
| 211 static void | 203 static void |
| 212 adjust_scnhdr_out_post (abfd, in, out) | 204 adjust_scnhdr_out_post (bfd * abfd ATTRIBUTE_UNUSED, |
| 213 bfd *abfd ATTRIBUTE_UNUSED; | 205 » » » void * in, |
| 214 PTR in; | 206 » » » void * out ATTRIBUTE_UNUSED) |
| 215 PTR out ATTRIBUTE_UNUSED; | |
| 216 { | 207 { |
| 217 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; | 208 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in; |
| 218 | 209 |
| 219 ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE); | 210 ADJUST_VAL (scnhdr_int->s_scnptr, GO32_STUBSIZE); |
| 220 ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE); | 211 ADJUST_VAL (scnhdr_int->s_relptr, GO32_STUBSIZE); |
| 221 ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE); | 212 ADJUST_VAL (scnhdr_int->s_lnnoptr, GO32_STUBSIZE); |
| 222 } | 213 } |
| 223 | 214 |
| 224 static void | 215 static void |
| 225 adjust_aux_in_post (abfd, ext1, type, in_class, indx, numaux, in1) | 216 adjust_aux_in_post (bfd * abfd ATTRIBUTE_UNUSED, |
| 226 bfd *abfd ATTRIBUTE_UNUSED; | 217 » » void * ext1 ATTRIBUTE_UNUSED, |
| 227 PTR ext1 ATTRIBUTE_UNUSED; | 218 » » int type, |
| 228 int type; | 219 » » int in_class, |
| 229 int in_class; | 220 » » int indx ATTRIBUTE_UNUSED, |
| 230 int indx ATTRIBUTE_UNUSED; | 221 » » int numaux ATTRIBUTE_UNUSED, |
| 231 int numaux ATTRIBUTE_UNUSED; | 222 » » void * in1) |
| 232 PTR in1; | |
| 233 { | 223 { |
| 234 union internal_auxent *in = (union internal_auxent *) in1; | 224 union internal_auxent *in = (union internal_auxent *) in1; |
| 235 | 225 |
| 236 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) | 226 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) |
| 237 || ISTAG (in_class)) | 227 || ISTAG (in_class)) |
| 238 { | 228 { |
| 239 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE); | 229 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE); |
| 240 } | 230 } |
| 241 } | 231 } |
| 242 | 232 |
| 243 static void | 233 static void |
| 244 adjust_aux_out_pre (abfd, inp, type, in_class, indx, numaux, extp) | 234 adjust_aux_out_pre (bfd *abfd ATTRIBUTE_UNUSED, |
| 245 bfd *abfd ATTRIBUTE_UNUSED; | 235 » » void * inp, |
| 246 PTR inp; | 236 » » int type, |
| 247 int type; | 237 » » int in_class, |
| 248 int in_class; | 238 » » int indx ATTRIBUTE_UNUSED, |
| 249 int indx ATTRIBUTE_UNUSED; | 239 » » int numaux ATTRIBUTE_UNUSED, |
| 250 int numaux ATTRIBUTE_UNUSED; | 240 » » void * extp ATTRIBUTE_UNUSED) |
| 251 PTR extp ATTRIBUTE_UNUSED; | |
| 252 { | 241 { |
| 253 union internal_auxent *in = (union internal_auxent *) inp; | 242 union internal_auxent *in = (union internal_auxent *) inp; |
| 254 | 243 |
| 255 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) | 244 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) |
| 256 || ISTAG (in_class)) | 245 || ISTAG (in_class)) |
| 257 { | 246 { |
| 258 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -GO32_STUBSIZE); | 247 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, -GO32_STUBSIZE); |
| 259 } | 248 } |
| 260 } | 249 } |
| 261 | 250 |
| 262 static void | 251 static void |
| 263 adjust_aux_out_post (abfd, inp, type, in_class, indx, numaux, extp) | 252 adjust_aux_out_post (bfd *abfd ATTRIBUTE_UNUSED, |
| 264 bfd *abfd ATTRIBUTE_UNUSED; | 253 » » void * inp, |
| 265 PTR inp; | 254 » » int type, |
| 266 int type; | 255 » » int in_class, |
| 267 int in_class; | 256 » » int indx ATTRIBUTE_UNUSED, |
| 268 int indx ATTRIBUTE_UNUSED; | 257 » » int numaux ATTRIBUTE_UNUSED, |
| 269 int numaux ATTRIBUTE_UNUSED; | 258 » » void * extp ATTRIBUTE_UNUSED) |
| 270 PTR extp ATTRIBUTE_UNUSED; | |
| 271 { | 259 { |
| 272 union internal_auxent *in = (union internal_auxent *) inp; | 260 union internal_auxent *in = (union internal_auxent *) inp; |
| 273 | 261 |
| 274 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) | 262 if (in_class == C_BLOCK || in_class == C_FCN || ISFCN (type) |
| 275 || ISTAG (in_class)) | 263 || ISTAG (in_class)) |
| 276 { | 264 { |
| 277 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE); | 265 ADJUST_VAL (in->x_sym.x_fcnary.x_fcn.x_lnnoptr, GO32_STUBSIZE); |
| 278 } | 266 } |
| 279 } | 267 } |
| 280 | 268 |
| 281 /* That's the function, which creates the stub. There are | 269 /* That's the function, which creates the stub. There are |
| 282 different cases from where the stub is taken. | 270 different cases from where the stub is taken. |
| 283 At first the environment variable $(GO32STUB) is checked and then | 271 At first the environment variable $(GO32STUB) is checked and then |
| 284 $(STUB) if it was not set. | 272 $(STUB) if it was not set. |
| 285 If it exists and points to a valid stub the stub is taken from | 273 If it exists and points to a valid stub the stub is taken from |
| 286 that file. This file can be also a whole executable file, because | 274 that file. This file can be also a whole executable file, because |
| 287 the stub is computed from the exe information at the start of that | 275 the stub is computed from the exe information at the start of that |
| 288 file. | 276 file. |
| 289 | 277 |
| 290 If there was any error, the standard stub (compiled in this file) | 278 If there was any error, the standard stub (compiled in this file) |
| 291 is taken. */ | 279 is taken. */ |
| 292 | 280 |
| 293 static void | 281 static void |
| 294 create_go32_stub (abfd) | 282 create_go32_stub (bfd *abfd) |
| 295 bfd *abfd; | |
| 296 { | 283 { |
| 297 /* Do it only once. */ | 284 /* Do it only once. */ |
| 298 if (coff_data (abfd)->go32stub == NULL) | 285 if (coff_data (abfd)->go32stub == NULL) |
| 299 { | 286 { |
| 300 char *stub; | 287 char *stub; |
| 301 struct stat st; | 288 struct stat st; |
| 302 int f; | 289 int f; |
| 303 unsigned char header[10]; | 290 unsigned char header[10]; |
| 304 char magic[8]; | 291 char magic[8]; |
| 305 unsigned long coff_start; | 292 unsigned long coff_start; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (coff_data (abfd)->go32stub == NULL) | 373 if (coff_data (abfd)->go32stub == NULL) |
| 387 return; | 374 return; |
| 388 memcpy (coff_data (abfd)->go32stub, stub_bytes, GO32_STUBSIZE); | 375 memcpy (coff_data (abfd)->go32stub, stub_bytes, GO32_STUBSIZE); |
| 389 } | 376 } |
| 390 } | 377 } |
| 391 | 378 |
| 392 /* If ibfd was a stubbed coff image, copy the stub from that bfd | 379 /* If ibfd was a stubbed coff image, copy the stub from that bfd |
| 393 to the new obfd. */ | 380 to the new obfd. */ |
| 394 | 381 |
| 395 static bfd_boolean | 382 static bfd_boolean |
| 396 go32_stubbed_coff_bfd_copy_private_bfd_data (ibfd, obfd) | 383 go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd) |
| 397 bfd *ibfd; | |
| 398 bfd *obfd; | |
| 399 { | 384 { |
| 400 /* Check if both are the same targets. */ | 385 /* Check if both are the same targets. */ |
| 401 if (ibfd->xvec != obfd->xvec) | 386 if (ibfd->xvec != obfd->xvec) |
| 402 return TRUE; | 387 return TRUE; |
| 403 | 388 |
| 404 /* Check if we have a source stub. */ | 389 /* Check if we have a source stub. */ |
| 405 if (coff_data (ibfd)->go32stub == NULL) | 390 if (coff_data (ibfd)->go32stub == NULL) |
| 406 return TRUE; | 391 return TRUE; |
| 407 | 392 |
| 408 /* As adjust_filehdr_out_pre may get called only after this function, | 393 /* As adjust_filehdr_out_pre may get called only after this function, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 431 { | 416 { |
| 432 bfd_set_error (bfd_error_wrong_format); | 417 bfd_set_error (bfd_error_wrong_format); |
| 433 return NULL; | 418 return NULL; |
| 434 } | 419 } |
| 435 | 420 |
| 436 if (bfd_seek (abfd, 0, SEEK_SET) != 0) | 421 if (bfd_seek (abfd, 0, SEEK_SET) != 0) |
| 437 return NULL; | 422 return NULL; |
| 438 | 423 |
| 439 return coff_object_p (abfd); | 424 return coff_object_p (abfd); |
| 440 } | 425 } |
| OLD | NEW |