Mon Jul 3 13:55:18 1995 Steve Chamberlain <sac@slash.cygnus.com>
[deliverable/binutils-gdb.git] / bfd / aout-target.h
index 2ee6ff43f3d5515dcb9f0df497c7d484564d4ec8..201fa1c33b600c22a29d6fc1d62bc37ecd7a4478 100644 (file)
@@ -27,11 +27,13 @@ extern CONST struct reloc_howto_struct * NAME(aout,reloc_type_lookup) ();
 /* Set parameters about this a.out file that are machine-dependent.
    This routine is called from some_aout_object_p just before it returns.  */
 #ifndef MY_callback
-static bfd_target *
+static const bfd_target *
 MY(callback) (abfd)
      bfd *abfd;
 {
   struct internal_exec *execp = exec_hdr (abfd);
+  unsigned int arch_align_power;
+  unsigned long arch_align;
 
   /* Calculate the file positions of the parts of a newly read aout header */
   obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
@@ -60,6 +62,26 @@ MY(callback) (abfd)
   bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
 #endif
 
+  /* Now that we know the architecture, set the alignments of the
+     sections.  This is normally done by NAME(aout,new_section_hook),
+     but when the initial sections were created the architecture had
+     not yet been set.  However, for backward compatibility, we don't
+     set the alignment power any higher than as required by the size
+     of the section.  */
+  arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
+  arch_align = 1 << arch_align_power;
+  if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
+       == obj_textsec (abfd)->_raw_size)
+      && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
+         == obj_datasec (abfd)->_raw_size)
+      && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
+         == obj_bsssec (abfd)->_raw_size))
+    {
+      obj_textsec (abfd)->alignment_power = arch_align_power;
+      obj_datasec (abfd)->alignment_power = arch_align_power;
+      obj_bsssec (abfd)->alignment_power = arch_align_power;
+    }
+
   /* Don't set sizes now -- can't be sure until we know arch & mach.
      Sizes get set in set_sizes callback, later.  */
 #if 0
@@ -79,13 +101,13 @@ MY(callback) (abfd)
 #ifndef MY_object_p
 /* Finish up the reading of an a.out file header */
 
-static bfd_target *
+static const bfd_target *
 MY(object_p) (abfd)
      bfd *abfd;
 {
   struct external_exec exec_bytes;     /* Raw exec header from file */
   struct internal_exec exec;           /* Cleaned-up exec header */
-  bfd_target *target;
+  const bfd_target *target;
 
   if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
       != EXEC_BYTES_SIZE) {
@@ -106,6 +128,12 @@ MY(object_p) (abfd)
 #endif
 
   NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+
+#ifdef SWAP_MAGIC
+  /* swap_exec_header_in read in a_info with the wrong byte order */
+  exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
+#endif /* SWAP_MAGIC */
+
   target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
 
 #ifdef ENTRY_CAN_BE_ZERO
@@ -159,9 +187,9 @@ MY(mkobject) (abfd)
 
 /* Copy private section data.  This actually does nothing with the
    sections.  It copies the subformat field.  We copy it here, because
-   we know whether this is a QMAGIC file before we set the section
-   contents, and copy_private_bfd_data is not called until after the
-   section contents have been set.  */
+   we need to know whether this is a QMAGIC file before we set the
+   section contents, and copy_private_bfd_data is not called until
+   after the section contents have been set.  */
 
 /*ARGSUSED*/
 static boolean
@@ -171,7 +199,8 @@ MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
      bfd *obfd;
      asection *osec;
 {
-  obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
+  if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
+    obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
   return true;
 }
 
@@ -208,11 +237,19 @@ MY(set_sizes) (abfd)
      bfd *abfd;
 {
   adata(abfd).page_size = PAGE_SIZE;
+
 #ifdef SEGMENT_SIZE
   adata(abfd).segment_size = SEGMENT_SIZE;
 #else
   adata(abfd).segment_size = PAGE_SIZE;
 #endif
+
+#ifdef ZMAGIC_DISK_BLOCK_SIZE
+  adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
+#else
+  adata(abfd).zmagic_disk_block_size = PAGE_SIZE;
+#endif
+
   adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
   return true;
 }
@@ -225,6 +262,9 @@ MY(set_sizes) (abfd)
 
 #ifndef MY_backend_data
 
+#ifndef MY_zmagic_contiguous
+#define MY_zmagic_contiguous 0
+#endif
 #ifndef MY_text_includes_header
 #define MY_text_includes_header 0
 #endif
@@ -248,7 +288,7 @@ MY(set_sizes) (abfd)
 #endif
 
 static CONST struct aout_backend_data MY(backend_data) = {
-  0,                           /* zmagic contiguous */
+  MY_zmagic_contiguous,
   MY_text_includes_header,
   MY_exec_hdr_flags,
   0,                           /* text vma? */
@@ -321,6 +361,9 @@ MY_bfd_final_link (abfd, info)
 #ifndef        MY_truncate_arname
 #define        MY_truncate_arname              bfd_bsd_truncate_arname
 #endif
+#ifndef MY_update_armap_timestamp
+#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
+#endif
 
 /* No core file defined here -- configure in trad-core.c separately.  */
 #ifndef        MY_core_file_failing_command
@@ -463,7 +506,7 @@ MY_bfd_final_link (abfd, info)
 #endif
 
 #ifndef MY_BFD_TARGET
-bfd_target MY(vec) =
+const bfd_target MY(vec) =
 {
   TARGETNAME,          /* name */
   bfd_target_aout_flavour,
This page took 0.025224 seconds and 4 git commands to generate.