case U802ROMAGIC:
case U802WRMAGIC:
case U802TOCMAGIC:
+#ifdef POWERMAC
+ /* PowerPC Macs use the same magic numbers as RS/6000 (because
+ that's how they were bootstrapped originally), but they are
+ always PowerPC architecture. */
+ arch = bfd_arch_powerpc;
+ machine = 601;
+#else
+ /* FIXME The architecture and machine can now (as of AIX 4.1) be
+ identified by looking at fields in the a.out header. */
arch = bfd_arch_rs6000;
machine = 6000;
+#endif /* POWERMAC */
break;
#endif
#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
#define coff_get_section_contents _bfd_generic_get_section_contents
-#define coff_bfd_copy_private_symbol_data \
- _bfd_generic_bfd_copy_private_symbol_data
-#define coff_bfd_copy_private_section_data \
- _bfd_generic_bfd_copy_private_section_data
+#ifndef coff_bfd_copy_private_symbol_data
+#define coff_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
+#endif
+
+#ifndef coff_bfd_copy_private_section_data
+#define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data
+#endif
+
+#ifndef coff_bfd_copy_private_bfd_data
#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#endif
+
#define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
#ifndef coff_bfd_print_private_bfd_data
-#define coff_bfd_print_private_bfd_data \
- _bfd_generic_bfd_print_private_bfd_data
+#define coff_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
#endif
#ifndef coff_bfd_is_local_label
filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
}
+#ifdef COFF_IMAGE_WITH_PE
+
static unsigned int
coff_swap_filehdr_out (abfd, in, out)
bfd *abfd;
return sizeof(FILHDR);
}
+#else
+
+static unsigned int
+coff_swap_filehdr_out (abfd, in, out)
+ bfd *abfd;
+ PTR in;
+ PTR out;
+{
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
+ FILHDR *filehdr_out = (FILHDR *)out;
+ bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
+ bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
+ bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
+ (bfd_byte *) filehdr_out->f_symptr);
+ bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
+ 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);
+}
+
+#endif
static void
{
scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
}
+ if (strcmp (scnhdr_int->s_name, _BSS) == 0)
+ {
+ scnhdr_int->s_size = scnhdr_int->s_paddr;
+ scnhdr_int->s_paddr = 0;
+ }
}
static unsigned int
section data is ever generated, we must add IMAGE_SCN_MEM_DISCARDABLE
(0x02000000). Also, the resource data should also be read and
writable. */
+
+ /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
+ /* FIXME: even worse, I don't see how to get the original alignment field*/
+ /* back... */
+
{
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 ;
+ else if (strcmp (scnhdr_int->s_name, ".reldata") == 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)
+ flags = IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE ;
+ /* end of ppc-nt additions */
bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
}
int j;
pe_data_type *pe = pe_data (abfd);
struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
- fprintf (file,"ImageBase\t\t");
+ fprintf (file,"\nImageBase\t\t");
fprintf_vma (file, i->ImageBase);
- fprintf (file,"SectionAlignment\t");
+ fprintf (file,"\nSectionAlignment\t");
fprintf_vma (file, i->SectionAlignment);
- fprintf (file,"FileAlignment\t\t");
+ fprintf (file,"\nFileAlignment\t\t");
fprintf_vma (file, i->FileAlignment);
- fprintf (file,"MajorOSystemVersion\t%d\n", i->MajorOperatingSystemVersion);
+ fprintf (file,"\nMajorOSystemVersion\t%d\n", i->MajorOperatingSystemVersion);
fprintf (file,"MinorOSystemVersion\t%d\n", i->MinorOperatingSystemVersion);
fprintf (file,"MajorImageVersion\t%d\n", i->MajorImageVersion);
fprintf (file,"MinorImageVersion\t%d\n", i->MinorImageVersion);
fprintf (file,"DllCharacteristics\t%08x\n", i->DllCharacteristics);
fprintf (file,"SizeOfStackReserve\t");
fprintf_vma (file, i->SizeOfStackReserve);
- fprintf (file,"SizeOfStackCommit\t");
+ fprintf (file,"\nSizeOfStackCommit\t");
fprintf_vma (file, i->SizeOfStackCommit);
- fprintf (file,"SizeOfHeapReserve\t");
+ fprintf (file,"\nSizeOfHeapReserve\t");
fprintf_vma (file, i->SizeOfHeapReserve);
- fprintf (file,"SizeOfHeapCommit\t");
+ fprintf (file,"\nSizeOfHeapCommit\t");
fprintf_vma (file, i->SizeOfHeapCommit);
- fprintf (file,"LoaderFlags\t\t%08lx\n", i->LoaderFlags);
+ fprintf (file,"\nLoaderFlags\t\t%08lx\n", i->LoaderFlags);
fprintf (file,"NumberOfRvaAndSizes\t%08lx\n", i->NumberOfRvaAndSizes);
for (j = 0; j < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; j++)
obj_conv_table_size (abfd) =
internal_f->f_nsyms;
+#ifdef COFF_IMAGE_WITH_PE
pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe;
+#endif
+
return (PTR) pe;
}
+/* Copy any private info we understand from the input bfd
+ to the output bfd. */
+
+#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data
+
+static boolean
+pe_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd, *obfd;
+{
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_coff_flavour
+ || obfd->xvec->flavour != bfd_target_coff_flavour)
+ return true;
+
+ pe_data(obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
+
+ return true;
+}
+