00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #define COFF_WITH_XX
00062
00063 #include "bfd.h"
00064 #include "sysdep.h"
00065 #include "libbfd.h"
00066 #include "coff/internal.h"
00067
00068
00069
00070
00071
00072
00073
00074 #ifdef COFF_WITH_pep
00075 # include "coff/ia64.h"
00076 #else
00077 # include "coff/i386.h"
00078 #endif
00079
00080 #include "coff/pe.h"
00081 #include "libcoff.h"
00082 #include "libpei.h"
00083
00084 #ifdef COFF_WITH_pep
00085 # undef AOUTSZ
00086 # define AOUTSZ PEPAOUTSZ
00087 # define PEAOUTHDR PEPAOUTHDR
00088 #endif
00089
00090
00091
00092
00093
00094
00095
00096 static void add_data_entry
00097 PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
00098 static bfd_boolean pe_print_pdata PARAMS ((bfd *, PTR));
00099 static bfd_boolean pe_print_reloc PARAMS ((bfd *, PTR));
00100 static bfd_boolean pe_print_idata PARAMS ((bfd *, PTR));
00101 static bfd_boolean pe_print_edata PARAMS ((bfd *, PTR));
00102
00103
00104 void
00105 _bfd_XXi_swap_sym_in (abfd, ext1, in1)
00106 bfd *abfd;
00107 PTR ext1;
00108 PTR in1;
00109 {
00110 SYMENT *ext = (SYMENT *) ext1;
00111 struct internal_syment *in = (struct internal_syment *) in1;
00112
00113 if (ext->e.e_name[0] == 0)
00114 {
00115 in->_n._n_n._n_zeroes = 0;
00116 in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
00117 }
00118 else
00119 memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
00120
00121 in->n_value = H_GET_32 (abfd, ext->e_value);
00122 in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
00123
00124 if (sizeof (ext->e_type) == 2)
00125 in->n_type = H_GET_16 (abfd, ext->e_type);
00126 else
00127 in->n_type = H_GET_32 (abfd, ext->e_type);
00128
00129 in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
00130 in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
00131
00132 #ifndef STRICT_PE_FORMAT
00133
00134
00135
00136
00137
00138
00139
00140
00141 if (in->n_sclass == C_SECTION)
00142 {
00143 in->n_value = 0x0;
00144
00145
00146 if (in->n_scnum == 0)
00147 {
00148 asection *sec;
00149
00150 for (sec = abfd->sections; sec; sec = sec->next)
00151 {
00152 if (strcmp (sec->name, in->n_name) == 0)
00153 {
00154 in->n_scnum = sec->target_index;
00155 break;
00156 }
00157 }
00158 }
00159
00160 if (in->n_scnum == 0)
00161 {
00162 int unused_section_number = 0;
00163 asection *sec;
00164 char *name;
00165
00166 for (sec = abfd->sections; sec; sec = sec->next)
00167 if (unused_section_number <= sec->target_index)
00168 unused_section_number = sec->target_index + 1;
00169
00170 name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
00171 if (name == NULL)
00172 return;
00173 strcpy (name, in->n_name);
00174 sec = bfd_make_section_anyway (abfd, name);
00175
00176 sec->vma = 0;
00177 sec->lma = 0;
00178 sec->size = 0;
00179 sec->filepos = 0;
00180 sec->rel_filepos = 0;
00181 sec->reloc_count = 0;
00182 sec->line_filepos = 0;
00183 sec->lineno_count = 0;
00184 sec->userdata = NULL;
00185 sec->next = (asection *) NULL;
00186 sec->alignment_power = 2;
00187 sec->flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
00188
00189 sec->target_index = unused_section_number;
00190
00191 in->n_scnum = unused_section_number;
00192 }
00193 in->n_sclass = C_STAT;
00194 }
00195 #endif
00196
00197 #ifdef coff_swap_sym_in_hook
00198
00199
00200 coff_swap_sym_in_hook (abfd, ext1, in1);
00201 #endif
00202 }
00203
00204 unsigned int
00205 _bfd_XXi_swap_sym_out (abfd, inp, extp)
00206 bfd *abfd;
00207 PTR inp;
00208 PTR extp;
00209 {
00210 struct internal_syment *in = (struct internal_syment *) inp;
00211 SYMENT *ext = (SYMENT *) extp;
00212
00213 if (in->_n._n_name[0] == 0)
00214 {
00215 H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
00216 H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
00217 }
00218 else
00219 memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
00220
00221 H_PUT_32 (abfd, in->n_value, ext->e_value);
00222 H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
00223
00224 if (sizeof (ext->e_type) == 2)
00225 H_PUT_16 (abfd, in->n_type, ext->e_type);
00226 else
00227 H_PUT_32 (abfd, in->n_type, ext->e_type);
00228
00229 H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
00230 H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
00231
00232 return SYMESZ;
00233 }
00234
00235 void
00236 _bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
00237 bfd *abfd;
00238 PTR ext1;
00239 int type;
00240 int class;
00241 int indx ATTRIBUTE_UNUSED;
00242 int numaux ATTRIBUTE_UNUSED;
00243 PTR in1;
00244 {
00245 AUXENT *ext = (AUXENT *) ext1;
00246 union internal_auxent *in = (union internal_auxent *) in1;
00247
00248 switch (class)
00249 {
00250 case C_FILE:
00251 if (ext->x_file.x_fname[0] == 0)
00252 {
00253 in->x_file.x_n.x_zeroes = 0;
00254 in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
00255 }
00256 else
00257 memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
00258 return;
00259
00260 case C_STAT:
00261 case C_LEAFSTAT:
00262 case C_HIDDEN:
00263 if (type == T_NULL)
00264 {
00265 in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
00266 in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
00267 in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
00268 in->x_scn.x_checksum = H_GET_32 (abfd, ext->x_scn.x_checksum);
00269 in->x_scn.x_associated = H_GET_16 (abfd, ext->x_scn.x_associated);
00270 in->x_scn.x_comdat = H_GET_8 (abfd, ext->x_scn.x_comdat);
00271 return;
00272 }
00273 break;
00274 }
00275
00276 in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
00277 in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
00278
00279 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00280 {
00281 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
00282 in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
00283 }
00284 else
00285 {
00286 in->x_sym.x_fcnary.x_ary.x_dimen[0] =
00287 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
00288 in->x_sym.x_fcnary.x_ary.x_dimen[1] =
00289 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
00290 in->x_sym.x_fcnary.x_ary.x_dimen[2] =
00291 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
00292 in->x_sym.x_fcnary.x_ary.x_dimen[3] =
00293 H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
00294 }
00295
00296 if (ISFCN (type))
00297 {
00298 in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
00299 }
00300 else
00301 {
00302 in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
00303 in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
00304 }
00305 }
00306
00307 unsigned int
00308 _bfd_XXi_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
00309 bfd *abfd;
00310 PTR inp;
00311 int type;
00312 int class;
00313 int indx ATTRIBUTE_UNUSED;
00314 int numaux ATTRIBUTE_UNUSED;
00315 PTR extp;
00316 {
00317 union internal_auxent *in = (union internal_auxent *) inp;
00318 AUXENT *ext = (AUXENT *) extp;
00319
00320 memset ((PTR) ext, 0, AUXESZ);
00321 switch (class)
00322 {
00323 case C_FILE:
00324 if (in->x_file.x_fname[0] == 0)
00325 {
00326 H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
00327 H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
00328 }
00329 else
00330 memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
00331
00332 return AUXESZ;
00333
00334 case C_STAT:
00335 case C_LEAFSTAT:
00336 case C_HIDDEN:
00337 if (type == T_NULL)
00338 {
00339 PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
00340 PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
00341 PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
00342 H_PUT_32 (abfd, in->x_scn.x_checksum, ext->x_scn.x_checksum);
00343 H_PUT_16 (abfd, in->x_scn.x_associated, ext->x_scn.x_associated);
00344 H_PUT_8 (abfd, in->x_scn.x_comdat, ext->x_scn.x_comdat);
00345 return AUXESZ;
00346 }
00347 break;
00348 }
00349
00350 H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
00351 H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
00352
00353 if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
00354 {
00355 PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
00356 PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
00357 }
00358 else
00359 {
00360 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
00361 ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
00362 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
00363 ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
00364 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
00365 ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
00366 H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
00367 ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
00368 }
00369
00370 if (ISFCN (type))
00371 H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
00372 else
00373 {
00374 PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
00375 PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
00376 }
00377
00378 return AUXESZ;
00379 }
00380
00381 void
00382 _bfd_XXi_swap_lineno_in (abfd, ext1, in1)
00383 bfd *abfd;
00384 PTR ext1;
00385 PTR in1;
00386 {
00387 LINENO *ext = (LINENO *) ext1;
00388 struct internal_lineno *in = (struct internal_lineno *) in1;
00389
00390 in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
00391 in->l_lnno = GET_LINENO_LNNO (abfd, ext);
00392 }
00393
00394 unsigned int
00395 _bfd_XXi_swap_lineno_out (abfd, inp, outp)
00396 bfd *abfd;
00397 PTR inp;
00398 PTR outp;
00399 {
00400 struct internal_lineno *in = (struct internal_lineno *) inp;
00401 struct external_lineno *ext = (struct external_lineno *) outp;
00402 H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
00403
00404 PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
00405 return LINESZ;
00406 }
00407
00408 void
00409 _bfd_XXi_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
00410 bfd *abfd;
00411 PTR aouthdr_ext1;
00412 PTR aouthdr_int1;
00413 {
00414 struct internal_extra_pe_aouthdr *a;
00415 PEAOUTHDR *src = (PEAOUTHDR *) (aouthdr_ext1);
00416 AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
00417 struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
00418
00419 aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
00420 aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
00421 aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
00422 aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
00423 aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
00424 aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
00425 aouthdr_int->text_start =
00426 GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
00427 #ifndef COFF_WITH_pep
00428
00429 aouthdr_int->data_start =
00430 GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
00431 #endif
00432
00433 a = &aouthdr_int->pe;
00434 a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, src->ImageBase);
00435 a->SectionAlignment = H_GET_32 (abfd, src->SectionAlignment);
00436 a->FileAlignment = H_GET_32 (abfd, src->FileAlignment);
00437 a->MajorOperatingSystemVersion =
00438 H_GET_16 (abfd, src->MajorOperatingSystemVersion);
00439 a->MinorOperatingSystemVersion =
00440 H_GET_16 (abfd, src->MinorOperatingSystemVersion);
00441 a->MajorImageVersion = H_GET_16 (abfd, src->MajorImageVersion);
00442 a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
00443 a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
00444 a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
00445 a->Reserved1 = H_GET_32 (abfd, src->Reserved1);
00446 a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
00447 a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
00448 a->CheckSum = H_GET_32 (abfd, src->CheckSum);
00449 a->Subsystem = H_GET_16 (abfd, src->Subsystem);
00450 a->DllCharacteristics = H_GET_16 (abfd, src->DllCharacteristics);
00451 a->SizeOfStackReserve =
00452 GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, src->SizeOfStackReserve);
00453 a->SizeOfStackCommit =
00454 GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, src->SizeOfStackCommit);
00455 a->SizeOfHeapReserve =
00456 GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, src->SizeOfHeapReserve);
00457 a->SizeOfHeapCommit =
00458 GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, src->SizeOfHeapCommit);
00459 a->LoaderFlags = H_GET_32 (abfd, src->LoaderFlags);
00460 a->NumberOfRvaAndSizes = H_GET_32 (abfd, src->NumberOfRvaAndSizes);
00461
00462 {
00463 int idx;
00464
00465 for (idx = 0; idx < 16; idx++)
00466 {
00467
00468 int size =
00469 H_GET_32 (abfd, src->DataDirectory[idx][1]);
00470 a->DataDirectory[idx].Size = size;
00471
00472 if (size)
00473 a->DataDirectory[idx].VirtualAddress =
00474 H_GET_32 (abfd, src->DataDirectory[idx][0]);
00475 else
00476 a->DataDirectory[idx].VirtualAddress = 0;
00477 }
00478 }
00479
00480 if (aouthdr_int->entry)
00481 {
00482 aouthdr_int->entry += a->ImageBase;
00483 #ifndef COFF_WITH_pep
00484 aouthdr_int->entry &= 0xffffffff;
00485 #endif
00486 }
00487
00488 if (aouthdr_int->tsize)
00489 {
00490 aouthdr_int->text_start += a->ImageBase;
00491 #ifndef COFF_WITH_pep
00492 aouthdr_int->text_start &= 0xffffffff;
00493 #endif
00494 }
00495
00496 #ifndef COFF_WITH_pep
00497
00498 if (aouthdr_int->dsize)
00499 {
00500 aouthdr_int->data_start += a->ImageBase;
00501 aouthdr_int->data_start &= 0xffffffff;
00502 }
00503 #endif
00504
00505 #ifdef POWERPC_LE_PE
00506
00507
00508
00509 first_thunk_address = a->DataDirectory[12].VirtualAddress;
00510 thunk_size = a->DataDirectory[12].Size;
00511 import_table_size = a->DataDirectory[1].Size;
00512 #endif
00513 }
00514
00515
00516
00517 static void
00518 add_data_entry (abfd, aout, idx, name, base)
00519 bfd *abfd;
00520 struct internal_extra_pe_aouthdr *aout;
00521 int idx;
00522 char *name;
00523 bfd_vma base;
00524 {
00525 asection *sec = bfd_get_section_by_name (abfd, name);
00526
00527
00528 if ((sec != NULL)
00529 && (coff_section_data (abfd, sec) != NULL)
00530 && (pei_section_data (abfd, sec) != NULL))
00531 {
00532
00533 int size = pei_section_data (abfd, sec)->virt_size;
00534 aout->DataDirectory[idx].Size = size;
00535
00536 if (size)
00537 {
00538 aout->DataDirectory[idx].VirtualAddress =
00539 (sec->vma - base) & 0xffffffff;
00540 sec->flags |= SEC_DATA;
00541 }
00542 }
00543 }
00544
00545 unsigned int
00546 _bfd_XXi_swap_aouthdr_out (abfd, in, out)
00547 bfd *abfd;
00548 PTR in;
00549 PTR out;
00550 {
00551 struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
00552 pe_data_type *pe = pe_data (abfd);
00553 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
00554 PEAOUTHDR *aouthdr_out = (PEAOUTHDR *) out;
00555 bfd_vma sa, fa, ib;
00556 IMAGE_DATA_DIRECTORY idata2, idata5, tls;
00557
00558 if (pe->force_minimum_alignment)
00559 {
00560 if (!extra->FileAlignment)
00561 extra->FileAlignment = PE_DEF_FILE_ALIGNMENT;
00562 if (!extra->SectionAlignment)
00563 extra->SectionAlignment = PE_DEF_SECTION_ALIGNMENT;
00564 }
00565
00566 if (extra->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
00567 extra->Subsystem = pe->target_subsystem;
00568
00569 sa = extra->SectionAlignment;
00570 fa = extra->FileAlignment;
00571 ib = extra->ImageBase;
00572
00573 idata2 = pe->pe_opthdr.DataDirectory[1];
00574 idata5 = pe->pe_opthdr.DataDirectory[12];
00575 tls = pe->pe_opthdr.DataDirectory[9];
00576
00577 if (aouthdr_in->tsize)
00578 {
00579 aouthdr_in->text_start -= ib;
00580 #ifndef COFF_WITH_pep
00581 aouthdr_in->text_start &= 0xffffffff;
00582 #endif
00583 }
00584
00585 if (aouthdr_in->dsize)
00586 {
00587 aouthdr_in->data_start -= ib;
00588 #ifndef COFF_WITH_pep
00589 aouthdr_in->data_start &= 0xffffffff;
00590 #endif
00591 }
00592
00593 if (aouthdr_in->entry)
00594 {
00595 aouthdr_in->entry -= ib;
00596 #ifndef COFF_WITH_pep
00597 aouthdr_in->entry &= 0xffffffff;
00598 #endif
00599 }
00600
00601 #define FA(x) (((x) + fa -1 ) & (- fa))
00602 #define SA(x) (((x) + sa -1 ) & (- sa))
00603
00604
00605 aouthdr_in->bsize = FA (aouthdr_in->bsize);
00606
00607 extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
00608
00609
00610 memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory));
00611
00612 add_data_entry (abfd, extra, 0, ".edata", ib);
00613 add_data_entry (abfd, extra, 2, ".rsrc", ib);
00614 add_data_entry (abfd, extra, 3, ".pdata", ib);
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 extra->DataDirectory[1] = idata2;
00626 extra->DataDirectory[12] = idata5;
00627 extra->DataDirectory[9] = tls;
00628
00629 if (extra->DataDirectory[1].VirtualAddress == 0)
00630
00631
00632 add_data_entry (abfd, extra, 1, ".idata", ib);
00633
00634
00635
00636
00637
00638
00639 if (pe->has_reloc_section)
00640 add_data_entry (abfd, extra, 5, ".reloc", ib);
00641
00642 {
00643 asection *sec;
00644 bfd_vma hsize = 0;
00645 bfd_vma dsize = 0;
00646 bfd_vma isize = 0;
00647 bfd_vma tsize = 0;
00648
00649 for (sec = abfd->sections; sec; sec = sec->next)
00650 {
00651 int rounded = FA(sec->size);
00652
00653
00654
00655 if (hsize == 0)
00656 hsize = sec->filepos;
00657 if (sec->flags & SEC_DATA)
00658 dsize += rounded;
00659 if (sec->flags & SEC_CODE)
00660 tsize += rounded;
00661
00662
00663
00664
00665
00666 if (coff_section_data (abfd, sec) != NULL
00667 && pei_section_data (abfd, sec) != NULL)
00668 isize += SA (FA (pei_section_data (abfd, sec)->virt_size));
00669 }
00670
00671 aouthdr_in->dsize = dsize;
00672 aouthdr_in->tsize = tsize;
00673 extra->SizeOfHeaders = hsize;
00674 extra->SizeOfImage = SA(hsize) + isize;
00675 }
00676
00677 H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
00678
00679 #define LINKER_VERSION 256
00680
00681
00682
00683 H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
00684 aouthdr_out->standard.vstamp);
00685
00686 PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize);
00687 PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize);
00688 PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->standard.bsize);
00689 PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->standard.entry);
00690 PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
00691 aouthdr_out->standard.text_start);
00692
00693 #ifndef COFF_WITH_pep
00694
00695 PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
00696 aouthdr_out->standard.data_start);
00697 #endif
00698
00699 PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase, aouthdr_out->ImageBase);
00700 H_PUT_32 (abfd, extra->SectionAlignment, aouthdr_out->SectionAlignment);
00701 H_PUT_32 (abfd, extra->FileAlignment, aouthdr_out->FileAlignment);
00702 H_PUT_16 (abfd, extra->MajorOperatingSystemVersion,
00703 aouthdr_out->MajorOperatingSystemVersion);
00704 H_PUT_16 (abfd, extra->MinorOperatingSystemVersion,
00705 aouthdr_out->MinorOperatingSystemVersion);
00706 H_PUT_16 (abfd, extra->MajorImageVersion, aouthdr_out->MajorImageVersion);
00707 H_PUT_16 (abfd, extra->MinorImageVersion, aouthdr_out->MinorImageVersion);
00708 H_PUT_16 (abfd, extra->MajorSubsystemVersion,
00709 aouthdr_out->MajorSubsystemVersion);
00710 H_PUT_16 (abfd, extra->MinorSubsystemVersion,
00711 aouthdr_out->MinorSubsystemVersion);
00712 H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1);
00713 H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
00714 H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
00715 H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
00716 H_PUT_16 (abfd, extra->Subsystem, aouthdr_out->Subsystem);
00717 H_PUT_16 (abfd, extra->DllCharacteristics, aouthdr_out->DllCharacteristics);
00718 PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve,
00719 aouthdr_out->SizeOfStackReserve);
00720 PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit,
00721 aouthdr_out->SizeOfStackCommit);
00722 PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve,
00723 aouthdr_out->SizeOfHeapReserve);
00724 PUT_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, extra->SizeOfHeapCommit,
00725 aouthdr_out->SizeOfHeapCommit);
00726 H_PUT_32 (abfd, extra->LoaderFlags, aouthdr_out->LoaderFlags);
00727 H_PUT_32 (abfd, extra->NumberOfRvaAndSizes,
00728 aouthdr_out->NumberOfRvaAndSizes);
00729 {
00730 int idx;
00731
00732 for (idx = 0; idx < 16; idx++)
00733 {
00734 H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
00735 aouthdr_out->DataDirectory[idx][0]);
00736 H_PUT_32 (abfd, extra->DataDirectory[idx].Size,
00737 aouthdr_out->DataDirectory[idx][1]);
00738 }
00739 }
00740
00741 return AOUTSZ;
00742 }
00743
00744 unsigned int
00745 _bfd_XXi_only_swap_filehdr_out (abfd, in, out)
00746 bfd *abfd;
00747 PTR in;
00748 PTR out;
00749 {
00750 int idx;
00751 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
00752 struct external_PEI_filehdr *filehdr_out = (struct external_PEI_filehdr *) out;
00753
00754 if (pe_data (abfd)->has_reloc_section)
00755 filehdr_in->f_flags &= ~F_RELFLG;
00756
00757 if (pe_data (abfd)->dll)
00758 filehdr_in->f_flags |= F_DLL;
00759
00760 filehdr_in->pe.e_magic = DOSMAGIC;
00761 filehdr_in->pe.e_cblp = 0x90;
00762 filehdr_in->pe.e_cp = 0x3;
00763 filehdr_in->pe.e_crlc = 0x0;
00764 filehdr_in->pe.e_cparhdr = 0x4;
00765 filehdr_in->pe.e_minalloc = 0x0;
00766 filehdr_in->pe.e_maxalloc = 0xffff;
00767 filehdr_in->pe.e_ss = 0x0;
00768 filehdr_in->pe.e_sp = 0xb8;
00769 filehdr_in->pe.e_csum = 0x0;
00770 filehdr_in->pe.e_ip = 0x0;
00771 filehdr_in->pe.e_cs = 0x0;
00772 filehdr_in->pe.e_lfarlc = 0x40;
00773 filehdr_in->pe.e_ovno = 0x0;
00774
00775 for (idx = 0; idx < 4; idx++)
00776 filehdr_in->pe.e_res[idx] = 0x0;
00777
00778 filehdr_in->pe.e_oemid = 0x0;
00779 filehdr_in->pe.e_oeminfo = 0x0;
00780
00781 for (idx = 0; idx < 10; idx++)
00782 filehdr_in->pe.e_res2[idx] = 0x0;
00783
00784 filehdr_in->pe.e_lfanew = 0x80;
00785
00786
00787
00788 filehdr_in->pe.dos_message[0] = 0x0eba1f0e;
00789 filehdr_in->pe.dos_message[1] = 0xcd09b400;
00790 filehdr_in->pe.dos_message[2] = 0x4c01b821;
00791 filehdr_in->pe.dos_message[3] = 0x685421cd;
00792 filehdr_in->pe.dos_message[4] = 0x70207369;
00793 filehdr_in->pe.dos_message[5] = 0x72676f72;
00794 filehdr_in->pe.dos_message[6] = 0x63206d61;
00795 filehdr_in->pe.dos_message[7] = 0x6f6e6e61;
00796 filehdr_in->pe.dos_message[8] = 0x65622074;
00797 filehdr_in->pe.dos_message[9] = 0x6e757220;
00798 filehdr_in->pe.dos_message[10] = 0x206e6920;
00799 filehdr_in->pe.dos_message[11] = 0x20534f44;
00800 filehdr_in->pe.dos_message[12] = 0x65646f6d;
00801 filehdr_in->pe.dos_message[13] = 0x0a0d0d2e;
00802 filehdr_in->pe.dos_message[14] = 0x24;
00803 filehdr_in->pe.dos_message[15] = 0x0;
00804 filehdr_in->pe.nt_signature = NT_SIGNATURE;
00805
00806 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
00807 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
00808
00809 H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
00810 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
00811 filehdr_out->f_symptr);
00812 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
00813 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
00814 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
00815
00816
00817
00818
00819 H_PUT_16 (abfd, filehdr_in->pe.e_magic, filehdr_out->e_magic);
00820 H_PUT_16 (abfd, filehdr_in->pe.e_cblp, filehdr_out->e_cblp);
00821 H_PUT_16 (abfd, filehdr_in->pe.e_cp, filehdr_out->e_cp);
00822 H_PUT_16 (abfd, filehdr_in->pe.e_crlc, filehdr_out->e_crlc);
00823 H_PUT_16 (abfd, filehdr_in->pe.e_cparhdr, filehdr_out->e_cparhdr);
00824 H_PUT_16 (abfd, filehdr_in->pe.e_minalloc, filehdr_out->e_minalloc);
00825 H_PUT_16 (abfd, filehdr_in->pe.e_maxalloc, filehdr_out->e_maxalloc);
00826 H_PUT_16 (abfd, filehdr_in->pe.e_ss, filehdr_out->e_ss);
00827 H_PUT_16 (abfd, filehdr_in->pe.e_sp, filehdr_out->e_sp);
00828 H_PUT_16 (abfd, filehdr_in->pe.e_csum, filehdr_out->e_csum);
00829 H_PUT_16 (abfd, filehdr_in->pe.e_ip, filehdr_out->e_ip);
00830 H_PUT_16 (abfd, filehdr_in->pe.e_cs, filehdr_out->e_cs);
00831 H_PUT_16 (abfd, filehdr_in->pe.e_lfarlc, filehdr_out->e_lfarlc);
00832 H_PUT_16 (abfd, filehdr_in->pe.e_ovno, filehdr_out->e_ovno);
00833
00834 for (idx = 0; idx < 4; idx++)
00835 H_PUT_16 (abfd, filehdr_in->pe.e_res[idx], filehdr_out->e_res[idx]);
00836
00837 H_PUT_16 (abfd, filehdr_in->pe.e_oemid, filehdr_out->e_oemid);
00838 H_PUT_16 (abfd, filehdr_in->pe.e_oeminfo, filehdr_out->e_oeminfo);
00839
00840 for (idx = 0; idx < 10; idx++)
00841 H_PUT_16 (abfd, filehdr_in->pe.e_res2[idx], filehdr_out->e_res2[idx]);
00842
00843 H_PUT_32 (abfd, filehdr_in->pe.e_lfanew, filehdr_out->e_lfanew);
00844
00845 for (idx = 0; idx < 16; idx++)
00846 H_PUT_32 (abfd, filehdr_in->pe.dos_message[idx],
00847 filehdr_out->dos_message[idx]);
00848
00849
00850 H_PUT_32 (abfd, filehdr_in->pe.nt_signature, filehdr_out->nt_signature);
00851
00852 return FILHSZ;
00853 }
00854
00855 unsigned int
00856 _bfd_XX_only_swap_filehdr_out (abfd, in, out)
00857 bfd *abfd;
00858 PTR in;
00859 PTR out;
00860 {
00861 struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
00862 FILHDR *filehdr_out = (FILHDR *) out;
00863
00864 H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
00865 H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
00866 H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
00867 PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
00868 H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
00869 H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
00870 H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
00871
00872 return FILHSZ;
00873 }
00874
00875 unsigned int
00876 _bfd_XXi_swap_scnhdr_out (abfd, in, out)
00877 bfd *abfd;
00878 PTR in;
00879 PTR out;
00880 {
00881 struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
00882 SCNHDR *scnhdr_ext = (SCNHDR *) out;
00883 unsigned int ret = SCNHSZ;
00884 bfd_vma ps;
00885 bfd_vma ss;
00886
00887 memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
00888
00889 PUT_SCNHDR_VADDR (abfd,
00890 ((scnhdr_int->s_vaddr
00891 - pe_data (abfd)->pe_opthdr.ImageBase)
00892 & 0xffffffff),
00893 scnhdr_ext->s_vaddr);
00894
00895
00896
00897
00898 if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
00899 {
00900 if (bfd_pe_executable_p (abfd))
00901 {
00902 ps = scnhdr_int->s_size;
00903 ss = 0;
00904 }
00905 else
00906 {
00907 ps = 0;
00908 ss = scnhdr_int->s_size;
00909 }
00910 }
00911 else
00912 {
00913 if (bfd_pe_executable_p (abfd))
00914 ps = scnhdr_int->s_paddr;
00915 else
00916 ps = 0;
00917
00918 ss = scnhdr_int->s_size;
00919 }
00920
00921 PUT_SCNHDR_SIZE (abfd, ss,
00922 scnhdr_ext->s_size);
00923
00924
00925 PUT_SCNHDR_PADDR (abfd, ps, scnhdr_ext->s_paddr);
00926
00927 PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
00928 scnhdr_ext->s_scnptr);
00929 PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
00930 scnhdr_ext->s_relptr);
00931 PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
00932 scnhdr_ext->s_lnnoptr);
00933
00934 {
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949 typedef struct
00950 {
00951 const char * section_name;
00952 unsigned long must_have;
00953 }
00954 pe_required_section_flags;
00955
00956 pe_required_section_flags known_sections [] =
00957 {
00958 { ".arch", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_ALIGN_8BYTES },
00959 { ".bss", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
00960 { ".data", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
00961 { ".edata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
00962 { ".idata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
00963 { ".pdata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
00964 { ".rdata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
00965 { ".reloc", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_DISCARDABLE },
00966 { ".rsrc", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
00967 { ".text" , IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE },
00968 { ".tls", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
00969 { ".xdata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
00970 { NULL, 0}
00971 };
00972
00973 pe_required_section_flags * p;
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983 for (p = known_sections; p->section_name; p++)
00984 if (strcmp (scnhdr_int->s_name, p->section_name) == 0)
00985 {
00986 if (strcmp (scnhdr_int->s_name, ".text")
00987 || (bfd_get_file_flags (abfd) & WP_TEXT))
00988 scnhdr_int->s_flags &= ~IMAGE_SCN_MEM_WRITE;
00989 scnhdr_int->s_flags |= p->must_have;
00990 break;
00991 }
00992
00993 H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
00994 }
00995
00996 if (coff_data (abfd)->link_info
00997 && ! coff_data (abfd)->link_info->relocatable
00998 && ! coff_data (abfd)->link_info->shared
00999 && strcmp (scnhdr_int->s_name, ".text") == 0)
01000 {
01001
01002
01003
01004
01005
01006
01007
01008
01009 H_PUT_16 (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno);
01010 H_PUT_16 (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc);
01011 }
01012 else
01013 {
01014 if (scnhdr_int->s_nlnno <= 0xffff)
01015 H_PUT_16 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
01016 else
01017 {
01018 (*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
01019 bfd_get_filename (abfd),
01020 scnhdr_int->s_nlnno);
01021 bfd_set_error (bfd_error_file_truncated);
01022 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno);
01023 ret = 0;
01024 }
01025
01026
01027
01028
01029
01030 if (scnhdr_int->s_nreloc < 0xffff)
01031 H_PUT_16 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
01032 else
01033 {
01034
01035 H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
01036 scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
01037 H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
01038 }
01039 }
01040 return ret;
01041 }
01042
01043 static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
01044 {
01045 N_("Export Directory [.edata (or where ever we found it)]"),
01046 N_("Import Directory [parts of .idata]"),
01047 N_("Resource Directory [.rsrc]"),
01048 N_("Exception Directory [.pdata]"),
01049 N_("Security Directory"),
01050 N_("Base Relocation Directory [.reloc]"),
01051 N_("Debug Directory"),
01052 N_("Description Directory"),
01053 N_("Special Directory"),
01054 N_("Thread Storage Directory [.tls]"),
01055 N_("Load Configuration Directory"),
01056 N_("Bound Import Directory"),
01057 N_("Import Address Table Directory"),
01058 N_("Delay Import Directory"),
01059 N_("Reserved"),
01060 N_("Reserved")
01061 };
01062
01063 #ifdef POWERPC_LE_PE
01064
01065
01066
01067
01068
01069 #endif
01070
01071 static bfd_boolean
01072 pe_print_idata (abfd, vfile)
01073 bfd *abfd;
01074 PTR vfile;
01075 {
01076 FILE *file = (FILE *) vfile;
01077 bfd_byte *data;
01078 asection *section;
01079 bfd_signed_vma adj;
01080
01081 #ifdef POWERPC_LE_PE
01082 asection *rel_section = bfd_get_section_by_name (abfd, ".reldata");
01083 #endif
01084
01085 bfd_size_type datasize = 0;
01086 bfd_size_type dataoff;
01087 bfd_size_type i;
01088 int onaline = 20;
01089
01090 pe_data_type *pe = pe_data (abfd);
01091 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
01092
01093 bfd_vma addr;
01094
01095 addr = extra->DataDirectory[1].VirtualAddress;
01096
01097 if (addr == 0 && extra->DataDirectory[1].Size == 0)
01098 {
01099
01100 section = bfd_get_section_by_name (abfd, ".idata");
01101 if (section == NULL)
01102 return TRUE;
01103
01104 addr = section->vma;
01105 datasize = section->size;
01106 if (datasize == 0)
01107 return TRUE;
01108 }
01109 else
01110 {
01111 addr += extra->ImageBase;
01112 for (section = abfd->sections; section != NULL; section = section->next)
01113 {
01114 datasize = section->size;
01115 if (addr >= section->vma && addr < section->vma + datasize)
01116 break;
01117 }
01118
01119 if (section == NULL)
01120 {
01121 fprintf (file,
01122 _("\nThere is an import table, but the section containing it could not be found\n"));
01123 return TRUE;
01124 }
01125 }
01126
01127 fprintf (file, _("\nThere is an import table in %s at 0x%lx\n"),
01128 section->name, (unsigned long) addr);
01129
01130 dataoff = addr - section->vma;
01131 datasize -= dataoff;
01132
01133 #ifdef POWERPC_LE_PE
01134 if (rel_section != 0 && rel_section->size != 0)
01135 {
01136
01137
01138
01139
01140
01141
01142
01143 bfd_vma loadable_toc_address;
01144 bfd_vma toc_address;
01145 bfd_vma start_address;
01146 bfd_byte *data;
01147 int offset;
01148
01149 if (!bfd_malloc_and_get_section (abfd, rel_section, &data))
01150 {
01151 if (data != NULL)
01152 free (data);
01153 return FALSE;
01154 }
01155
01156 offset = abfd->start_address - rel_section->vma;
01157
01158 start_address = bfd_get_32 (abfd, data + offset);
01159 loadable_toc_address = bfd_get_32 (abfd, data + offset + 4);
01160 toc_address = loadable_toc_address - 32768;
01161
01162 fprintf (file,
01163 _("\nFunction descriptor located at the start address: %04lx\n"),
01164 (unsigned long int) (abfd->start_address));
01165 fprintf (file,
01166 _("\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"),
01167 start_address, loadable_toc_address, toc_address);
01168 if (data != NULL)
01169 free (data);
01170 }
01171 else
01172 {
01173 fprintf (file,
01174 _("\nNo reldata section! Function descriptor not decoded.\n"));
01175 }
01176 #endif
01177
01178 fprintf (file,
01179 _("\nThe Import Tables (interpreted %s section contents)\n"),
01180 section->name);
01181 fprintf (file,
01182 _("\
01183 vma: Hint Time Forward DLL First\n\
01184 Table Stamp Chain Name Thunk\n"));
01185
01186
01187 if (!bfd_malloc_and_get_section (abfd, section, &data))
01188 {
01189 if (data != NULL)
01190 free (data);
01191 return FALSE;
01192 }
01193
01194 adj = section->vma - extra->ImageBase;
01195
01196
01197 for (i = 0; i < datasize; i += onaline)
01198 {
01199 bfd_vma hint_addr;
01200 bfd_vma time_stamp;
01201 bfd_vma forward_chain;
01202 bfd_vma dll_name;
01203 bfd_vma first_thunk;
01204 int idx = 0;
01205 bfd_size_type j;
01206 char *dll;
01207
01208
01209 fprintf (file, " %08lx\t", (unsigned long) (i + adj + dataoff));
01210 hint_addr = bfd_get_32 (abfd, data + i + dataoff);
01211 time_stamp = bfd_get_32 (abfd, data + i + 4 + dataoff);
01212 forward_chain = bfd_get_32 (abfd, data + i + 8 + dataoff);
01213 dll_name = bfd_get_32 (abfd, data + i + 12 + dataoff);
01214 first_thunk = bfd_get_32 (abfd, data + i + 16 + dataoff);
01215
01216 fprintf (file, "%08lx %08lx %08lx %08lx %08lx\n",
01217 (unsigned long) hint_addr,
01218 (unsigned long) time_stamp,
01219 (unsigned long) forward_chain,
01220 (unsigned long) dll_name,
01221 (unsigned long) first_thunk);
01222
01223 if (hint_addr == 0 && first_thunk == 0)
01224 break;
01225
01226 dll = (char *) data + dll_name - adj;
01227 fprintf (file, _("\n\tDLL Name: %s\n"), dll);
01228
01229 if (hint_addr != 0)
01230 {
01231 bfd_byte *ft_data;
01232 asection *ft_section;
01233 bfd_vma ft_addr;
01234 bfd_size_type ft_datasize;
01235 int ft_idx;
01236 int ft_allocated = 0;
01237
01238 fprintf (file, _("\tvma: Hint/Ord Member-Name Bound-To\n"));
01239
01240 idx = hint_addr - adj;
01241
01242 ft_addr = first_thunk + extra->ImageBase;
01243 ft_data = data;
01244 ft_idx = first_thunk - adj;
01245 ft_allocated = 0;
01246
01247 if (first_thunk != hint_addr)
01248 {
01249
01250 for (ft_section = abfd->sections;
01251 ft_section != NULL;
01252 ft_section = ft_section->next)
01253 {
01254 ft_datasize = ft_section->size;
01255 if (ft_addr >= ft_section->vma
01256 && ft_addr < ft_section->vma + ft_datasize)
01257 break;
01258 }
01259
01260 if (ft_section == NULL)
01261 {
01262 fprintf (file,
01263 _("\nThere is a first thunk, but the section containing it could not be found\n"));
01264 continue;
01265 }
01266
01267
01268
01269 if (ft_section == section)
01270 {
01271 ft_data = data;
01272 ft_idx = first_thunk - adj;
01273 }
01274 else
01275 {
01276 ft_idx = first_thunk - (ft_section->vma - extra->ImageBase);
01277 ft_data = (bfd_byte *) bfd_malloc (datasize);
01278 if (ft_data == NULL)
01279 continue;
01280
01281
01282 if (! bfd_get_section_contents (abfd, ft_section,
01283 (PTR) ft_data,
01284 (bfd_vma) ft_idx,
01285 datasize))
01286 {
01287 free (ft_data);
01288 continue;
01289 }
01290
01291 ft_idx = 0;
01292 ft_allocated = 1;
01293 }
01294 }
01295
01296
01297 for (j = 0; j < datasize; j += 4)
01298 {
01299 unsigned long member = bfd_get_32 (abfd, data + idx + j);
01300
01301
01302 if (member == 0)
01303 break;
01304
01305 if (member & 0x80000000)
01306 fprintf (file, "\t%04lx\t %4lu <none>",
01307 member, member & 0x7fffffff);
01308 else
01309 {
01310 int ordinal;
01311 char *member_name;
01312
01313 ordinal = bfd_get_16 (abfd, data + member - adj);
01314 member_name = (char *) data + member - adj + 2;
01315 fprintf (file, "\t%04lx\t %4d %s",
01316 member, ordinal, member_name);
01317 }
01318
01319
01320
01321 if (time_stamp != 0
01322 && first_thunk != 0
01323 && first_thunk != hint_addr)
01324 fprintf (file, "\t%04lx",
01325 (long) bfd_get_32 (abfd, ft_data + ft_idx + j));
01326
01327 fprintf (file, "\n");
01328 }
01329
01330 if (ft_allocated)
01331 free (ft_data);
01332 }
01333
01334 fprintf (file, "\n");
01335 }
01336
01337 free (data);
01338
01339 return TRUE;
01340 }
01341
01342 static bfd_boolean
01343 pe_print_edata (abfd, vfile)
01344 bfd *abfd;
01345 PTR vfile;
01346 {
01347 FILE *file = (FILE *) vfile;
01348 bfd_byte *data;
01349 asection *section;
01350 bfd_size_type datasize = 0;
01351 bfd_size_type dataoff;
01352 bfd_size_type i;
01353 bfd_signed_vma adj;
01354 struct EDT_type
01355 {
01356 long export_flags;
01357 long time_stamp;
01358 short major_ver;
01359 short minor_ver;
01360 bfd_vma name;
01361 long base;
01362 unsigned long num_functions;
01363 unsigned long num_names;
01364 bfd_vma eat_addr;
01365 bfd_vma npt_addr;
01366 bfd_vma ot_addr;
01367 } edt;
01368
01369 pe_data_type *pe = pe_data (abfd);
01370 struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
01371
01372 bfd_vma addr;
01373
01374 addr = extra->DataDirectory[0].VirtualAddress;
01375
01376 if (addr == 0 && extra->DataDirectory[0].Size == 0)
01377 {
01378
01379 section = bfd_get_section_by_name (abfd, ".edata");
01380 if (section == NULL)
01381 return TRUE;
01382
01383 addr = section->vma;
01384 datasize = section->size;
01385 if (datasize == 0)
01386 return TRUE;
01387 }
01388 else
01389 {
01390 addr += extra->ImageBase;
01391
01392 for (section = abfd->sections; section != NULL; section = section->next)
01393 {
01394 datasize = section->size;
01395
01396 if (addr >= section->vma && addr < section->vma + datasize)
01397 break;
01398 }
01399
01400 if (section == NULL)
01401 {
01402 fprintf (file,
01403 _("\nThere is an export table, but the section containing it could not be found\n"));
01404 return TRUE;
01405 }
01406 }
01407
01408 fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
01409 section->name, (unsigned long) addr);
01410
01411 dataoff = addr - section->vma;
01412 datasize -= dataoff;
01413
01414 data = (bfd_byte *) bfd_malloc (datasize);
01415 if (data == NULL)
01416 return FALSE;
01417
01418 if (! bfd_get_section_contents (abfd, section, (PTR) data,
01419 (file_ptr) dataoff, datasize))
01420 return FALSE;
01421
01422
01423 edt.export_flags = bfd_get_32 (abfd, data + 0);
01424 edt.time_stamp = bfd_get_32 (abfd, data + 4);
01425 edt.major_ver = bfd_get_16 (abfd, data + 8);
01426 edt.minor_ver = bfd_get_16 (abfd, data + 10);
01427 edt.name = bfd_get_32 (abfd, data + 12);
01428 edt.base = bfd_get_32 (abfd, data + 16);
01429 edt.num_functions = bfd_get_32 (abfd, data + 20);
01430 edt.num_names = bfd_get_32 (abfd, data + 24);
01431 edt.eat_addr = bfd_get_32 (abfd, data + 28);
01432 edt.npt_addr = bfd_get_32 (abfd, data + 32);
01433 edt.ot_addr = bfd_get_32 (abfd, data + 36);
01434
01435 adj = section->vma - extra->ImageBase + dataoff;
01436
01437
01438 fprintf (file,
01439 _("\nThe Export Tables (interpreted %s section contents)\n\n"),
01440 section->name);
01441
01442 fprintf (file,
01443 _("Export Flags \t\t\t%lx\n"), (unsigned long) edt.export_flags);
01444
01445 fprintf (file,
01446 _("Time/Date stamp \t\t%lx\n"), (unsigned long) edt.time_stamp);
01447
01448 fprintf (file,
01449 _("Major/Minor \t\t\t%d/%d\n"), edt.major_ver, edt.minor_ver);
01450
01451 fprintf (file,
01452 _("Name \t\t\t\t"));
01453 fprintf_vma (file, edt.name);
01454 fprintf (file,
01455 " %s\n", data + edt.name - adj);
01456
01457 fprintf (file,
01458 _("Ordinal Base \t\t\t%ld\n"), edt.base);
01459
01460 fprintf (file,
01461 _("Number in:\n"));
01462
01463 fprintf (file,
01464 _("\tExport Address Table \t\t%08lx\n"),
01465 edt.num_functions);
01466
01467 fprintf (file,
01468 _("\t[Name Pointer/Ordinal] Table\t%08lx\n"), edt.num_names);
01469
01470 fprintf (file,
01471 _("Table Addresses\n"));
01472
01473 fprintf (file,
01474 _("\tExport Address Table \t\t"));
01475 fprintf_vma (file, edt.eat_addr);
01476 fprintf (file, "\n");
01477
01478 fprintf (file,
01479 _("\tName Pointer Table \t\t"));
01480 fprintf_vma (file, edt.npt_addr);
01481 fprintf (file, "\n");
01482
01483 fprintf (file,
01484 _("\tOrdinal Table \t\t\t"));
01485 fprintf_vma (file, edt.ot_addr);
01486 fprintf (file, "\n");
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498 fprintf (file,
01499 _("\nExport Address Table -- Ordinal Base %ld\n"),
01500 edt.base);
01501
01502 for (i = 0; i < edt.num_functions; ++i)
01503 {
01504 bfd_vma eat_member = bfd_get_32 (abfd,
01505 data + edt.eat_addr + (i * 4) - adj);
01506 if (eat_member == 0)
01507 continue;
01508
01509 if (eat_member - adj <= datasize)
01510 {
01511
01512
01513 fprintf (file,
01514 "\t[%4ld] +base[%4ld] %04lx %s -- %s\n",
01515 (long) i,
01516 (long) (i + edt.base),
01517 (unsigned long) eat_member,
01518 _("Forwarder RVA"),
01519 data + eat_member - adj);
01520 }
01521 else
01522 {
01523
01524 fprintf (file,
01525 "\t[%4ld] +base[%4ld] %04lx %s\n",
01526 (long) i,
01527 (long) (i + edt.base),
01528 (unsigned long) eat_member,
01529 _("Export RVA"));
01530 }
01531 }
01532
01533
01534
01535 fprintf (file,
01536 _("\n[Ordinal/Name Pointer] Table\n"));
01537
01538 for (i = 0; i < edt.num_names; ++i)
01539 {
01540 bfd_vma name_ptr = bfd_get_32 (abfd,
01541 data +
01542 edt.npt_addr
01543 + (i*4) - adj);
01544
01545 char *name = (char *) data + name_ptr - adj;
01546
01547 bfd_vma ord = bfd_get_16 (abfd,
01548 data +
01549 edt.ot_addr
01550 + (i*2) - adj);
01551 fprintf (file,
01552 "\t[%4ld] %s\n", (long) ord, name);
01553 }
01554
01555 free (data);
01556
01557 return TRUE;
01558 }
01559
01560
01561
01562
01563
01564
01565 static bfd_boolean
01566 pe_print_pdata (abfd, vfile)
01567 bfd *abfd;
01568 PTR vfile;
01569 {
01570 #ifdef COFF_WITH_pep
01571 # define PDATA_ROW_SIZE (3*8)
01572 #else
01573 # define PDATA_ROW_SIZE (5*4)
01574 #endif
01575 FILE *file = (FILE *) vfile;
01576 bfd_byte *data = 0;
01577 asection *section = bfd_get_section_by_name (abfd, ".pdata");
01578 bfd_size_type datasize = 0;
01579 bfd_size_type i;
01580 bfd_size_type start, stop;
01581 int onaline = PDATA_ROW_SIZE;
01582
01583 if (section == NULL
01584 || coff_section_data (abfd, section) == NULL
01585 || pei_section_data (abfd, section) == NULL)
01586 return TRUE;
01587
01588 stop = pei_section_data (abfd, section)->virt_size;
01589 if ((stop % onaline) != 0)
01590 fprintf (file,
01591 _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
01592 (long) stop, onaline);
01593
01594 fprintf (file,
01595 _("\nThe Function Table (interpreted .pdata section contents)\n"));
01596 #ifdef COFF_WITH_pep
01597 fprintf (file,
01598 _(" vma:\t\t\tBegin Address End Address Unwind Info\n"));
01599 #else
01600 fprintf (file, _("\
01601 vma:\t\tBegin End EH EH PrologEnd Exception\n\
01602 \t\tAddress Address Handler Data Address Mask\n"));
01603 #endif
01604
01605 datasize = section->size;
01606 if (datasize == 0)
01607 return TRUE;
01608
01609 if (!bfd_malloc_and_get_section (abfd, section, &data))
01610 {
01611 if (data != NULL)
01612 free (data);
01613 return FALSE;
01614 }
01615
01616 start = 0;
01617
01618 for (i = start; i < stop; i += onaline)
01619 {
01620 bfd_vma begin_addr;
01621 bfd_vma end_addr;
01622 bfd_vma eh_handler;
01623 bfd_vma eh_data;
01624 bfd_vma prolog_end_addr;
01625 int em_data;
01626
01627 if (i + PDATA_ROW_SIZE > stop)
01628 break;
01629
01630 begin_addr = GET_PDATA_ENTRY (abfd, data + i );
01631 end_addr = GET_PDATA_ENTRY (abfd, data + i + 4);
01632 eh_handler = GET_PDATA_ENTRY (abfd, data + i + 8);
01633 eh_data = GET_PDATA_ENTRY (abfd, data + i + 12);
01634 prolog_end_addr = GET_PDATA_ENTRY (abfd, data + i + 16);
01635
01636 if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
01637 && eh_data == 0 && prolog_end_addr == 0)
01638
01639 break;
01640
01641 em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3);
01642 eh_handler &= ~(bfd_vma) 0x3;
01643 prolog_end_addr &= ~(bfd_vma) 0x3;
01644
01645 fputc (' ', file);
01646 fprintf_vma (file, i + section->vma); fputc ('\t', file);
01647 fprintf_vma (file, begin_addr); fputc (' ', file);
01648 fprintf_vma (file, end_addr); fputc (' ', file);
01649 fprintf_vma (file, eh_handler);
01650 #ifndef COFF_WITH_pep
01651 fputc (' ', file);
01652 fprintf_vma (file, eh_data); fputc (' ', file);
01653 fprintf_vma (file, prolog_end_addr);
01654 fprintf (file, " %x", em_data);
01655 #endif
01656
01657 #ifdef POWERPC_LE_PE
01658 if (eh_handler == 0 && eh_data != 0)
01659 {
01660
01661
01662
01663
01664
01665
01666
01667 switch (eh_data)
01668 {
01669 case 0x01:
01670 fprintf (file, _(" Register save millicode"));
01671 break;
01672 case 0x02:
01673 fprintf (file, _(" Register restore millicode"));
01674 break;
01675 case 0x03:
01676 fprintf (file, _(" Glue code sequence"));
01677 break;
01678 default:
01679 break;
01680 }
01681 }
01682 #endif
01683 fprintf (file, "\n");
01684 }
01685
01686 free (data);
01687
01688 return TRUE;
01689 }
01690
01691 #define IMAGE_REL_BASED_HIGHADJ 4
01692 static const char * const tbl[] =
01693 {
01694 "ABSOLUTE",
01695 "HIGH",
01696 "LOW",
01697 "HIGHLOW",
01698 "HIGHADJ",
01699 "MIPS_JMPADDR",
01700 "SECTION",
01701 "REL32",
01702 "RESERVED1",
01703 "MIPS_JMPADDR16",
01704 "DIR64",
01705 "HIGH3ADJ"
01706 "UNKNOWN",
01707 };
01708
01709 static bfd_boolean
01710 pe_print_reloc (abfd, vfile)
01711 bfd *abfd;
01712 PTR vfile;
01713 {
01714 FILE *file = (FILE *) vfile;
01715 bfd_byte *data = 0;
01716 asection *section = bfd_get_section_by_name (abfd, ".reloc");
01717 bfd_size_type datasize;
01718 bfd_size_type i;
01719 bfd_size_type start, stop;
01720
01721 if (section == NULL)
01722 return TRUE;
01723
01724 if (section->size == 0)
01725 return TRUE;
01726
01727 fprintf (file,
01728 _("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
01729
01730 datasize = section->size;
01731 if (!bfd_malloc_and_get_section (abfd, section, &data))
01732 {
01733 if (data != NULL)
01734 free (data);
01735 return FALSE;
01736 }
01737
01738 start = 0;
01739
01740 stop = section->size;
01741
01742 for (i = start; i < stop;)
01743 {
01744 int j;
01745 bfd_vma virtual_address;
01746 long number, size;
01747
01748
01749
01750 virtual_address = bfd_get_32 (abfd, data+i);
01751 size = bfd_get_32 (abfd, data+i+4);
01752 number = (size - 8) / 2;
01753
01754 if (size == 0)
01755 break;
01756
01757 fprintf (file,
01758 _("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"),
01759 (unsigned long) virtual_address, size, size, number);
01760
01761 for (j = 0; j < number; ++j)
01762 {
01763 unsigned short e = bfd_get_16 (abfd, data + i + 8 + j * 2);
01764 unsigned int t = (e & 0xF000) >> 12;
01765 int off = e & 0x0FFF;
01766
01767 if (t >= sizeof (tbl) / sizeof (tbl[0]))
01768 t = (sizeof (tbl) / sizeof (tbl[0])) - 1;
01769
01770 fprintf (file,
01771 _("\treloc %4d offset %4x [%4lx] %s"),
01772 j, off, (long) (off + virtual_address), tbl[t]);
01773
01774
01775
01776 if (t == IMAGE_REL_BASED_HIGHADJ)
01777 {
01778 fprintf (file, " (%4x)",
01779 ((unsigned int)
01780 bfd_get_16 (abfd, data + i + 8 + j * 2 + 2)));
01781 j++;
01782 }
01783
01784 fprintf (file, "\n");
01785 }
01786
01787 i += size;
01788 }
01789
01790 free (data);
01791
01792 return TRUE;
01793 }
01794
01795
01796
01797 bfd_boolean
01798 _bfd_XX_print_private_bfd_data_common (abfd, vfile)
01799 bfd *abfd;
01800 PTR vfile;
01801 {
01802 FILE *file = (FILE *) vfile;
01803 int j;
01804 pe_data_type *pe = pe_data (abfd);
01805 struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
01806 const char *subsystem_name = NULL;
01807
01808
01809
01810
01811 fprintf (file, _("\nCharacteristics 0x%x\n"), pe->real_flags);
01812 #undef PF
01813 #define PF(x, y) if (pe->real_flags & x) { fprintf (file, "\t%s\n", y); }
01814 PF (IMAGE_FILE_RELOCS_STRIPPED, "relocations stripped");
01815 PF (IMAGE_FILE_EXECUTABLE_IMAGE, "executable");
01816 PF (IMAGE_FILE_LINE_NUMS_STRIPPED, "line numbers stripped");
01817 PF (IMAGE_FILE_LOCAL_SYMS_STRIPPED, "symbols stripped");
01818 PF (IMAGE_FILE_LARGE_ADDRESS_AWARE, "large address aware");
01819 PF (IMAGE_FILE_BYTES_REVERSED_LO, "little endian");
01820 PF (IMAGE_FILE_32BIT_MACHINE, "32 bit words");
01821 PF (IMAGE_FILE_DEBUG_STRIPPED, "debugging information removed");
01822 PF (IMAGE_FILE_SYSTEM, "system file");
01823 PF (IMAGE_FILE_DLL, "DLL");
01824 PF (IMAGE_FILE_BYTES_REVERSED_HI, "big endian");
01825 #undef PF
01826
01827
01828 {
01829 time_t t = pe->coff.timestamp;
01830 fprintf (file, "\nTime/Date\t\t%s", ctime (&t));
01831 }
01832 fprintf (file, "\nImageBase\t\t");
01833 fprintf_vma (file, i->ImageBase);
01834 fprintf (file, "\nSectionAlignment\t");
01835 fprintf_vma (file, i->SectionAlignment);
01836 fprintf (file, "\nFileAlignment\t\t");
01837 fprintf_vma (file, i->FileAlignment);
01838 fprintf (file, "\nMajorOSystemVersion\t%d\n", i->MajorOperatingSystemVersion);
01839 fprintf (file, "MinorOSystemVersion\t%d\n", i->MinorOperatingSystemVersion);
01840 fprintf (file, "MajorImageVersion\t%d\n", i->MajorImageVersion);
01841 fprintf (file, "MinorImageVersion\t%d\n", i->MinorImageVersion);
01842 fprintf (file, "MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
01843 fprintf (file, "MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
01844 fprintf (file, "Win32Version\t\t%08lx\n", i->Reserved1);
01845 fprintf (file, "SizeOfImage\t\t%08lx\n", i->SizeOfImage);
01846 fprintf (file, "SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
01847 fprintf (file, "CheckSum\t\t%08lx\n", i->CheckSum);
01848
01849 switch (i->Subsystem)
01850 {
01851 case IMAGE_SUBSYSTEM_UNKNOWN:
01852 subsystem_name = "unspecified";
01853 break;
01854 case IMAGE_SUBSYSTEM_NATIVE:
01855 subsystem_name = "NT native";
01856 break;
01857 case IMAGE_SUBSYSTEM_WINDOWS_GUI:
01858 subsystem_name = "Windows GUI";
01859 break;
01860 case IMAGE_SUBSYSTEM_WINDOWS_CUI:
01861 subsystem_name = "Windows CUI";
01862 break;
01863 case IMAGE_SUBSYSTEM_POSIX_CUI:
01864 subsystem_name = "POSIX CUI";
01865 break;
01866 case IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
01867 subsystem_name = "Wince CUI";
01868 break;
01869 case IMAGE_SUBSYSTEM_EFI_APPLICATION:
01870 subsystem_name = "EFI application";
01871 break;
01872 case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
01873 subsystem_name = "EFI boot service driver";
01874 break;
01875 case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
01876 subsystem_name = "EFI runtime driver";
01877 break;
01878 }
01879
01880 fprintf (file, "Subsystem\t\t%08x", i->Subsystem);
01881 if (subsystem_name)
01882 fprintf (file, "\t(%s)", subsystem_name);
01883 fprintf (file, "\nDllCharacteristics\t%08x\n", i->DllCharacteristics);
01884 fprintf (file, "SizeOfStackReserve\t");
01885 fprintf_vma (file, i->SizeOfStackReserve);
01886 fprintf (file, "\nSizeOfStackCommit\t");
01887 fprintf_vma (file, i->SizeOfStackCommit);
01888 fprintf (file, "\nSizeOfHeapReserve\t");
01889 fprintf_vma (file, i->SizeOfHeapReserve);
01890 fprintf (file, "\nSizeOfHeapCommit\t");
01891 fprintf_vma (file, i->SizeOfHeapCommit);
01892 fprintf (file, "\nLoaderFlags\t\t%08lx\n", i->LoaderFlags);
01893 fprintf (file, "NumberOfRvaAndSizes\t%08lx\n", i->NumberOfRvaAndSizes);
01894
01895 fprintf (file, "\nThe Data Directory\n");
01896 for (j = 0; j < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; j++)
01897 {
01898 fprintf (file, "Entry %1x ", j);
01899 fprintf_vma (file, i->DataDirectory[j].VirtualAddress);
01900 fprintf (file, " %08lx ", i->DataDirectory[j].Size);
01901 fprintf (file, "%s\n", dir_names[j]);
01902 }
01903
01904 pe_print_idata (abfd, vfile);
01905 pe_print_edata (abfd, vfile);
01906 pe_print_pdata (abfd, vfile);
01907 pe_print_reloc (abfd, vfile);
01908
01909 return TRUE;
01910 }
01911
01912
01913
01914
01915 bfd_boolean
01916 _bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd)
01917 bfd *ibfd, *obfd;
01918 {
01919
01920 if (ibfd->xvec->flavour != bfd_target_coff_flavour
01921 || obfd->xvec->flavour != bfd_target_coff_flavour)
01922 return TRUE;
01923
01924 pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
01925 pe_data (obfd)->dll = pe_data (ibfd)->dll;
01926
01927
01928
01929 if (! pe_data (obfd)->has_reloc_section)
01930 {
01931 pe_data (obfd)->pe_opthdr.DataDirectory[5].VirtualAddress = 0;
01932 pe_data (obfd)->pe_opthdr.DataDirectory[5].Size = 0;
01933 }
01934 return TRUE;
01935 }
01936
01937
01938
01939 bfd_boolean
01940 _bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
01941 bfd *ibfd;
01942 asection *isec;
01943 bfd *obfd;
01944 asection *osec;
01945 {
01946 if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
01947 || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
01948 return TRUE;
01949
01950 if (coff_section_data (ibfd, isec) != NULL
01951 && pei_section_data (ibfd, isec) != NULL)
01952 {
01953 if (coff_section_data (obfd, osec) == NULL)
01954 {
01955 bfd_size_type amt = sizeof (struct coff_section_tdata);
01956 osec->used_by_bfd = (PTR) bfd_zalloc (obfd, amt);
01957 if (osec->used_by_bfd == NULL)
01958 return FALSE;
01959 }
01960
01961 if (pei_section_data (obfd, osec) == NULL)
01962 {
01963 bfd_size_type amt = sizeof (struct pei_section_tdata);
01964 coff_section_data (obfd, osec)->tdata = (PTR) bfd_zalloc (obfd, amt);
01965 if (coff_section_data (obfd, osec)->tdata == NULL)
01966 return FALSE;
01967 }
01968
01969 pei_section_data (obfd, osec)->virt_size =
01970 pei_section_data (ibfd, isec)->virt_size;
01971 pei_section_data (obfd, osec)->pe_flags =
01972 pei_section_data (ibfd, isec)->pe_flags;
01973 }
01974
01975 return TRUE;
01976 }
01977
01978 void
01979 _bfd_XX_get_symbol_info (abfd, symbol, ret)
01980 bfd *abfd;
01981 asymbol *symbol;
01982 symbol_info *ret;
01983 {
01984 coff_get_symbol_info (abfd, symbol, ret);
01985 }
01986
01987
01988
01989
01990 bfd_boolean
01991 _bfd_XXi_final_link_postscript (abfd, pfinfo)
01992 bfd *abfd;
01993 struct coff_final_link_info *pfinfo;
01994 {
01995 struct coff_link_hash_entry *h1;
01996 struct bfd_link_info *info = pfinfo->info;
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006 h1 = coff_link_hash_lookup (coff_hash_table (info),
02007 ".idata$2", FALSE, FALSE, TRUE);
02008 if (h1 != NULL)
02009 {
02010 pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress =
02011 (h1->root.u.def.value
02012 + h1->root.u.def.section->output_section->vma
02013 + h1->root.u.def.section->output_offset);
02014 h1 = coff_link_hash_lookup (coff_hash_table (info),
02015 ".idata$4", FALSE, FALSE, TRUE);
02016 pe_data (abfd)->pe_opthdr.DataDirectory[1].Size =
02017 ((h1->root.u.def.value
02018 + h1->root.u.def.section->output_section->vma
02019 + h1->root.u.def.section->output_offset)
02020 - pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress);
02021
02022
02023
02024 h1 = coff_link_hash_lookup (coff_hash_table (info),
02025 ".idata$5", FALSE, FALSE, TRUE);
02026 pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress =
02027 (h1->root.u.def.value
02028 + h1->root.u.def.section->output_section->vma
02029 + h1->root.u.def.section->output_offset);
02030 h1 = coff_link_hash_lookup (coff_hash_table (info),
02031 ".idata$6", FALSE, FALSE, TRUE);
02032 pe_data (abfd)->pe_opthdr.DataDirectory[12].Size =
02033 ((h1->root.u.def.value
02034 + h1->root.u.def.section->output_section->vma
02035 + h1->root.u.def.section->output_offset)
02036 - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress);
02037 }
02038
02039 h1 = coff_link_hash_lookup (coff_hash_table (info),
02040 "__tls_used", FALSE, FALSE, TRUE);
02041 if (h1 != NULL)
02042 {
02043 pe_data (abfd)->pe_opthdr.DataDirectory[9].VirtualAddress =
02044 (h1->root.u.def.value
02045 + h1->root.u.def.section->output_section->vma
02046 + h1->root.u.def.section->output_offset
02047 - pe_data (abfd)->pe_opthdr.ImageBase);
02048 pe_data (abfd)->pe_opthdr.DataDirectory[9].Size = 0x18;
02049 }
02050
02051
02052
02053
02054 return TRUE;
02055 }