/* Support for the generic parts of most COFF variants, for BFD.
- Copyright 1995 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
sac@cygnus.com
*/
+/* Hey look, some documentation [and in a place you expect to find it]!
+
+ The main reference for the pei format is "Microsoft Portable Executable
+ and Common Object File Format Specification 4.1". Get it if you need to
+ do some serious hacking on this code.
+
+ Another reference:
+ "Peering Inside the PE: A Tour of the Win32 Portable Executable
+ File Format", MSJ 1994, Volume 9.
+
+ The *sole* difference between the pe format and the pei format is that the
+ latter has an MSDOS 2.0 .exe header on the front that prints the message
+ "This app must be run under Windows." (or some such).
+ (FIXME: Whether that statement is *really* true or not is unknown.
+ Are there more subtle differences between pe and pei formats?
+ For now assume there aren't. If you find one, then for God sakes
+ document it here!)
+
+ The Microsoft docs use the word "image" instead of "executable" because
+ the former can also refer to a DLL (shared library). Confusion can arise
+ because the `i' in `pei' also refers to "image". The `pe' format can
+ also create images (i.e. executables), it's just that to run on a win32
+ system you need to use the pei format.
+
+ FIXME: Please add more docs here so the next poor fool that has to hack
+ on this code has a chance of getting something accomplished without
+ wasting too much time.
+*/
-
+#undef coff_bfd_print_private_bfd_data
#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
#define coff_mkobject pe_mkobject
#define coff_mkobject_hook pe_mkobject_hook
#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
#endif
-
+static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static unsigned int coff_swap_aux_out
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
+static void add_data_entry
+ PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
+static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
+static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
+static boolean pe_print_idata PARAMS ((bfd *, PTR));
+static boolean pe_print_edata PARAMS ((bfd *, PTR));
+static boolean pe_print_pdata PARAMS ((bfd *, PTR));
+static boolean pe_print_reloc PARAMS ((bfd *, PTR));
+static boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));
+static boolean pe_mkobject PARAMS ((bfd *));
+static PTR pe_mkobject_hook PARAMS ((bfd *, PTR, PTR));
+static boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
/**********************************************************************/
#ifdef SWAP_OUT_RELOC_EXTRA
SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
#endif
- return sizeof(struct external_reloc);
+ return RELSZ;
}
}
else
{
- filehdr_dst->f_symptr = 0;
filehdr_dst->f_nsyms = 0;
filehdr_dst->f_flags &= ~HAS_SYMS;
}
- return sizeof(FILHDR);
+ return FILHSZ;
}
#else
bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
- return sizeof(FILHDR);
+ return FILHSZ;
}
#endif
bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
- return sizeof(SYMENT);
+ return SYMESZ;
}
static void
in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
+ in->x_scn.x_checksum = bfd_h_get_32 (abfd,
+ (bfd_byte *) ext->x_scn.x_checksum);
+ in->x_scn.x_associated =
+ bfd_h_get_16 (abfd, (bfd_byte *) ext->x_scn.x_associated);
+ in->x_scn.x_comdat = bfd_h_get_8 (abfd,
+ (bfd_byte *) ext->x_scn.x_comdat);
return;
}
break;
in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
#endif
- if (class == C_BLOCK || ISFCN (type) || ISTAG (class))
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR (abfd, ext);
in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX (abfd, ext);
memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
#endif
}
- return sizeof (AUXENT);
+ return AUXESZ;
case C_STAT:
PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
- return sizeof (AUXENT);
+ bfd_h_put_32 (abfd, in->x_scn.x_checksum,
+ (bfd_byte *) ext->x_scn.x_checksum);
+ bfd_h_put_16 (abfd, in->x_scn.x_associated,
+ (bfd_byte *) ext->x_scn.x_associated);
+ bfd_h_put_8 (abfd, in->x_scn.x_comdat,
+ (bfd_byte *) ext->x_scn.x_comdat);
+ return AUXESZ;
}
break;
}
bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
#endif
- if (class == C_BLOCK || ISFCN (type) || ISTAG (class))
+ if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
}
- return sizeof(AUXENT);
+ return AUXESZ;
}
ext->l_addr.l_symndx);
PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
- return sizeof(struct external_lineno);
+ return LINESZ;
}
}
if (aouthdr_int->entry)
- aouthdr_int->entry += a->ImageBase;
+ {
+ aouthdr_int->entry += a->ImageBase;
+ aouthdr_int->entry &= 0xffffffff;
+ }
if (aouthdr_int->tsize)
- aouthdr_int->text_start += a->ImageBase;
+ {
+ aouthdr_int->text_start += a->ImageBase;
+ aouthdr_int->text_start &= 0xffffffff;
+ }
if (aouthdr_int->dsize)
- aouthdr_int->data_start += a->ImageBase;
+ {
+ aouthdr_int->data_start += a->ImageBase;
+ aouthdr_int->data_start &= 0xffffffff;
+ }
+
+#ifdef POWERPC_LE_PE
+ /* These three fields are normally set up by ppc_relocate_section.
+ In the case of reading a file in, we can pick them up from
+ the DataDirectory.
+ */
+ first_thunk_address = a->DataDirectory[12].VirtualAddress ;
+ thunk_size = a->DataDirectory[12].Size;
+ import_table_size = a->DataDirectory[1].Size;
+#endif
}
/* add import directory information if it exists */
if (sec != NULL)
{
- aout->DataDirectory[idx].VirtualAddress = sec->lma - base;
- aout->DataDirectory[idx].Size = sec->_cooked_size;
+ aout->DataDirectory[idx].VirtualAddress = (sec->vma - base) & 0xffffffff;
+ aout->DataDirectory[idx].Size = pei_section_data (abfd, sec)->virt_size;
sec->flags |= SEC_DATA;
}
}
bfd_vma ib = extra->ImageBase ;
if (aouthdr_in->tsize)
- aouthdr_in->text_start -= ib;
+ {
+ aouthdr_in->text_start -= ib;
+ aouthdr_in->text_start &= 0xffffffff;
+ }
if (aouthdr_in->dsize)
- aouthdr_in->data_start -= ib;
+ {
+ aouthdr_in->data_start -= ib;
+ aouthdr_in->data_start &= 0xffffffff;
+ }
if (aouthdr_in->entry)
- aouthdr_in->entry -= ib;
+ {
+ aouthdr_in->entry -= ib;
+ aouthdr_in->entry &= 0xffffffff;
+ }
#define FA(x) (((x) + fa -1 ) & (- fa))
#define SA(x) (((x) + sa -1 ) & (- sa))
bfd_vma dsize= 0;
bfd_vma isize = SA(abfd->sections->filepos);
bfd_vma tsize= 0;
-#ifdef PPC
- isize = 0;
-#endif
+
for (sec = abfd->sections; sec; sec = sec->next)
{
int rounded = FA(sec->_raw_size);
+
if (sec->flags & SEC_DATA)
dsize += rounded;
if (sec->flags & SEC_CODE)
}
}
- return sizeof(AOUTHDR);
+ return AOUTSZ;
}
static void
if (scnhdr_int->s_vaddr != 0)
{
scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
+ scnhdr_int->s_vaddr &= 0xffffffff;
}
if (strcmp (scnhdr_int->s_name, _BSS) == 0)
{
{
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
SCNHDR *scnhdr_ext = (SCNHDR *)out;
- unsigned int ret = sizeof (SCNHDR);
+ unsigned int ret = SCNHSZ;
bfd_vma ps;
bfd_vma ss;
memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
PUT_SCNHDR_VADDR (abfd,
- (scnhdr_int->s_vaddr
- - pe_data(abfd)->pe_opthdr.ImageBase),
+ ((scnhdr_int->s_vaddr
+ - pe_data(abfd)->pe_opthdr.ImageBase)
+ & 0xffffffff),
(bfd_byte *) scnhdr_ext->s_vaddr);
/* NT wants the size data to be rounded up to the next NT_FILE_ALIGNMENT
/* FIXME: even worse, I don't see how to get the original alignment field*/
/* back... */
+ /* FIXME: Basing this on section names is bogus. Also, this should
+ be in sec_to_styp_flags. */
+
{
int flags = scnhdr_int->s_flags;
if (strcmp (scnhdr_int->s_name, ".data") == 0 ||
else if (strcmp (scnhdr_int->s_name, ".rdata") == 0
|| strcmp (scnhdr_int->s_name, ".edata") == 0)
flags = IMAGE_SCN_MEM_READ | SEC_DATA;
- /* ppc-nt additions */
else if (strcmp (scnhdr_int->s_name, ".pdata") == 0)
flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES |
IMAGE_SCN_MEM_READ ;
/* Remember this field is a max of 8 chars, so the null is _not_ there
for an 8 character name like ".reldata". (yep. Stupid bug) */
- else if (strncmp (scnhdr_int->s_name, ".reldata", strlen(".reldata")) == 0)
+ else if (strncmp (scnhdr_int->s_name, ".reldata", 8) == 0)
flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
else if (strcmp (scnhdr_int->s_name, ".ydata") == 0)
flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
- else if (strcmp (scnhdr_int->s_name, ".drectve") == 0)
+ else if (strncmp (scnhdr_int->s_name, ".drectve", 8) == 0)
flags = IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE ;
- /* end of ppc-nt additions */
+ else if (strncmp (scnhdr_int->s_name, ".stab", 5) == 0)
+ flags |= IMAGE_SCN_LNK_INFO | IMAGE_SCN_MEM_DISCARDABLE;
+ else
+ flags = IMAGE_SCN_MEM_READ;
bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
}
static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
{
- "Export Directory [.edata]",
+ "Export Directory [.edata (or where ever we found it)]",
"Import Directory [parts of .idata]",
"Resource Directory [.rsrc]",
"Exception Directory [.pdata]",
/**********************************************************************/
static boolean
pe_print_idata(abfd, vfile)
- bfd*abfd;
- void *vfile;
+ bfd *abfd;
+ PTR vfile;
{
- FILE *file = vfile;
+ FILE *file = (FILE *) vfile;
bfd_byte *data = 0;
asection *section = bfd_get_section_by_name (abfd, ".idata");
bfd_size_type i;
bfd_size_type start, stop;
int onaline = 20;
- bfd_vma addr_value;
- bfd_vma loadable_toc_address;
- bfd_vma toc_address;
- bfd_vma start_address;
pe_data_type *pe = pe_data (abfd);
struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
and the descriptor is supposed to be in the .reldata section.
*/
+ bfd_vma loadable_toc_address;
+ bfd_vma toc_address;
+ bfd_vma start_address;
bfd_byte *data = 0;
int offset;
data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
"\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n",
start_address, loadable_toc_address, toc_address);
}
- else
+ else
{
- loadable_toc_address = 0;
- toc_address = 0;
- start_address = 0;
+ fprintf(file,
+ "\nNo reldata section! Function descriptor not decoded.\n");
}
#endif
int idx;
int j;
char *dll;
- int adj = extra->ImageBase - section->vma;
+ int adj = (extra->ImageBase - section->vma) & 0xffffffff;
fprintf (file,
" %04lx\t",
}
/* the image base is present in the section->vma */
- dll = data + dll_name + adj;
+ dll = (char *) data + dll_name + adj;
fprintf(file, "\n\tDLL Name: %s\n", dll);
fprintf(file, "\tvma: Ordinal Member-Name\n");
break;
ordinal = bfd_get_16(abfd,
data + member + adj);
- member_name = data + member + adj + 2;
+ member_name = (char *) data + member + adj + 2;
fprintf(file, "\t%04lx\t %4d %s\n",
member, ordinal, member_name);
}
{
ordinal = bfd_get_16(abfd,
data + iat_member + adj);
- member_name = data + iat_member + adj + 2;
+ member_name = (char *) data + iat_member + adj + 2;
fprintf(file, "\t%04lx\t %4d %s\n",
iat_member, ordinal, member_name);
}
}
free (data);
+
+ return true;
}
static boolean
-pe_print_edata(abfd, vfile)
- bfd*abfd;
- void *vfile;
+pe_print_edata (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
{
- FILE *file = vfile;
+ FILE *file = (FILE *) vfile;
bfd_byte *data = 0;
asection *section = bfd_get_section_by_name (abfd, ".edata");
edt.npt_addr = bfd_get_32(abfd, data+32);
edt.ot_addr = bfd_get_32(abfd, data+36);
- adj = extra->ImageBase - section->vma;
+ adj = (extra->ImageBase - section->vma) & 0xffffffff;
/* Dump the EDT first first */
"\nThe Export Tables (interpreted .edata section contents)\n\n");
fprintf(file,
- "Export Flags \t\t\t%x\n",edt.export_flags);
+ "Export Flags \t\t\t%lx\n", (unsigned long) edt.export_flags);
fprintf(file,
- "Time/Date stamp \t\t%x\n",edt.time_stamp);
+ "Time/Date stamp \t\t%lx\n", (unsigned long) edt.time_stamp);
fprintf(file,
"Major/Minor \t\t\t%d/%d\n", edt.major_ver, edt.minor_ver);
- fprintf(file,
- "Name \t\t\t\t%x %s\n", edt.name, data + edt.name + adj);
+ fprintf (file,
+ "Name \t\t\t\t");
+ fprintf_vma (file, edt.name);
+ fprintf (file,
+ " %s\n", data + edt.name + adj);
fprintf(file,
- "Ordinal Base \t\t\t%d\n", edt.base);
+ "Ordinal Base \t\t\t%ld\n", edt.base);
fprintf(file,
"Number in:\n");
fprintf(file,
- "\tExport Address Table \t\t%x\n", edt.num_functions);
+ "\tExport Address Table \t\t%lx\n",
+ (unsigned long) edt.num_functions);
fprintf(file,
- "\t[Name Pointer/Ordinal] Table\t%d\n", edt.num_names);
+ "\t[Name Pointer/Ordinal] Table\t%ld\n", edt.num_names);
fprintf(file,
"Table Addresses\n");
- fprintf(file,
- "\tExport Address Table \t\t%x\n",
- edt.eat_addr);
+ fprintf (file,
+ "\tExport Address Table \t\t");
+ fprintf_vma (file, edt.eat_addr);
+ fprintf (file, "\n");
- fprintf(file,
- "\tName Pointer Table \t\t%x\n",
- edt.npt_addr);
+ fprintf (file,
+ "\tName Pointer Table \t\t");
+ fprintf_vma (file, edt.npt_addr);
+ fprintf (file, "\n");
- fprintf(file,
- "\tOrdinal Table \t\t\t%x\n",
- edt.ot_addr);
+ fprintf (file,
+ "\tOrdinal Table \t\t\t");
+ fprintf_vma (file, edt.ot_addr);
+ fprintf (file, "\n");
/* The next table to find si the Export Address Table. It's basically
*/
fprintf(file,
- "\nExport Address Table -- Ordinal Base %d\n",
+ "\nExport Address Table -- Ordinal Base %ld\n",
edt.base);
for (i = 0; i < edt.num_functions; ++i)
{
bfd_vma eat_member = bfd_get_32(abfd,
data + edt.eat_addr + (i*4) + adj);
- bfd_vma eat_actual = extra->ImageBase + eat_member;
+ bfd_vma eat_actual = (extra->ImageBase + eat_member) & 0xffffffff;
bfd_vma edata_start = bfd_get_section_vma(abfd,section);
bfd_vma edata_end = edata_start + bfd_section_size (abfd, section);
/* this rva is to a name (forwarding function) in our section */
/* Should locate a function descriptor */
fprintf(file,
- "\t[%4d] +base[%4d] %04lx %s -- %s\n",
- i, i+edt.base, eat_member, "Forwarder RVA",
- data + eat_member + adj);
+ "\t[%4ld] +base[%4ld] %04lx %s -- %s\n",
+ (long) i, (long) (i + edt.base), eat_member,
+ "Forwarder RVA", data + eat_member + adj);
}
else
{
/* Should locate a function descriptor in the reldata section */
fprintf(file,
- "\t[%4d] +base[%4d] %04lx %s\n",
- i, i+edt.base, eat_member, "Export RVA");
+ "\t[%4ld] +base[%4ld] %04lx %s\n",
+ (long) i, (long) (i + edt.base), eat_member, "Export RVA");
}
}
edt.npt_addr
+ (i*4) + adj);
- char *name = data + name_ptr + adj;
+ char *name = (char *) data + name_ptr + adj;
bfd_vma ord = bfd_get_16(abfd,
data +
edt.ot_addr
+ (i*2) + adj);
fprintf(file,
- "\t[%4d] %s\n", ord, name);
+ "\t[%4ld] %s\n", (long) ord, name);
}
free (data);
+
+ return true;
}
static boolean
-pe_print_pdata(abfd, vfile)
- bfd*abfd;
- void *vfile;
+pe_print_pdata (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
{
- FILE *file = vfile;
+ FILE *file = (FILE *) vfile;
bfd_byte *data = 0;
asection *section = bfd_get_section_by_name (abfd, ".pdata");
bfd_size_type datasize = 0;
bfd_size_type i;
bfd_size_type start, stop;
int onaline = 20;
- bfd_vma addr_value;
if (section == 0)
return true;
+ stop = bfd_section_size (abfd, section);
+ if ((stop % onaline) != 0)
+ fprintf (file, "Warning, .pdata section size (%ld) is not a multiple of %d\n",
+ (long)stop, onaline);
+
fprintf(file,
"\nThe Function Table (interpreted .pdata section contents)\n");
fprintf(file,
start = 0;
- stop = bfd_section_size (abfd, section);
-
for (i = start; i < stop; i += onaline)
{
bfd_vma begin_addr;
eh_data = bfd_get_32(abfd, data+i+12);
prolog_end_addr = bfd_get_32(abfd, data+i+16);
- if (begin_addr == 0)
+ if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
+ && eh_data == 0 && prolog_end_addr == 0)
{
/* We are probably into the padding of the
section now */
}
free (data);
+
+ return true;
}
static const char *tbl[6] =
"LOW",
"HIGHLOW",
"HIGHADJ",
-"unknown"
+"MIPS_JMPADDR"
};
static boolean
-pe_print_reloc(abfd, vfile)
- bfd*abfd;
- void *vfile;
+pe_print_reloc (abfd, vfile)
+ bfd *abfd;
+ PTR vfile;
{
- FILE *file = vfile;
+ FILE *file = (FILE *) vfile;
bfd_byte *data = 0;
asection *section = bfd_get_section_by_name (abfd, ".reloc");
bfd_size_type datasize = 0;
bfd_size_type i;
bfd_size_type start, stop;
- int onaline = 20;
- bfd_vma addr_value;
if (section == 0)
return true;
return true;
fprintf(file,
- "\n\nPE File Base Relocations (interpreted .reloc"
- " section contents)\n");
+ "\n\nPE File Base Relocations (interpreted .reloc section contents)\n");
data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
datasize = bfd_section_size (abfd, section);
}
fprintf (file,
- "\nVirtual Address: %08lx Chunk size %d (0x%x) "
- "Number of fixups %d\n",
+ "\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n",
virtual_address, size, size, number);
for (j = 0; j < number; ++j)
abort();
fprintf(file,
- "\treloc %4d offset %4x [%4x] %s\n",
- j, off, off+virtual_address, tbl[t]);
+ "\treloc %4d offset %4x [%4lx] %s\n",
+ j, off, (long) (off + virtual_address), tbl[t]);
}
i += size;
}
free (data);
+
+ return true;
}
static boolean
pe->real_flags = internal_f->f_flags;
+ if ((internal_f->f_flags & F_DLL) != 0)
+ pe->dll = 1;
+
#ifdef COFF_IMAGE_WITH_PE
if (aouthdr)
{
/* Copy any private info we understand from the input bfd
to the output bfd. */
+#undef coff_bfd_copy_private_bfd_data
#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data
static boolean
|| obfd->xvec->flavour != bfd_target_coff_flavour)
return true;
- pe_data(obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
+ pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
+ pe_data (obfd)->dll = pe_data (ibfd)->dll;
+
+ return true;
+}
+
+#ifdef COFF_IMAGE_WITH_PE
+
+/* Copy private section data. */
+
+#define coff_bfd_copy_private_section_data pe_bfd_copy_private_section_data
+
+static boolean pe_bfd_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
+
+static boolean
+pe_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
+ bfd *ibfd;
+ asection *isec;
+ bfd *obfd;
+ asection *osec;
+{
+ if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
+ || bfd_get_flavour (obfd) != bfd_target_coff_flavour)
+ return true;
+
+ if (coff_section_data (ibfd, isec) != NULL
+ && pei_section_data (ibfd, isec) != NULL)
+ {
+ if (coff_section_data (obfd, osec) == NULL)
+ {
+ osec->used_by_bfd =
+ (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));
+ if (osec->used_by_bfd == NULL)
+ return false;
+ }
+ if (pei_section_data (obfd, osec) == NULL)
+ {
+ coff_section_data (obfd, osec)->tdata =
+ (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));
+ if (coff_section_data (obfd, osec)->tdata == NULL)
+ return false;
+ }
+ pei_section_data (obfd, osec)->virt_size =
+ pei_section_data (ibfd, isec)->virt_size;
+ }
return true;
}
+
+#endif