from ralphc: recognize some mips variants
[deliverable/binutils-gdb.git] / bfd / newsos3.c
index 8952c0febfec48d9b653965b8bab4fbefa22502a..8a1cfc84cfa45bf30cc15e9f1dc84331252d6a39 100644 (file)
@@ -17,17 +17,14 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-#define TARGET_BYTE_ORDER_BIG_P 1
-
 #define        PAGE_SIZE       4096
 #define        SEGMENT_SIZE    PAGE_SIZE
 #define TEXT_START_ADDR 0
 #define ARCH 32
 #define BYTES_IN_WORD 4
 
-#include <ansidecl.h>
-#include <sysdep.h>
 #include "bfd.h"
+#include "sysdep.h"
 #include "libbfd.h"
 #include "aout64.h"
 
@@ -54,19 +51,21 @@ bfd_target *
 DEFUN(newsos3_object_p,(abfd),
      bfd *abfd)
 {
-  unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
-  unsigned long magic;         /* Swapped magic number */
-
-  bfd_error = system_call_error;
+  struct external_exec exec_bytes;
+  struct internal_exec exec;
 
-  if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
-      sizeof (magicbuf))
+  if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+      != EXEC_BYTES_SIZE) {
+    bfd_error = wrong_format;
     return 0;
-  magic = bfd_h_get_32 (abfd, magicbuf);
+  }
 
-  if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
+  exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
 
-  return aout_32_some_aout_object_p (abfd, newsos3_callback);
+  if (N_BADMAG (exec)) return 0;
+
+  NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+  return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback);
 }
 
 /* Finish up the reading of a NEWS-OS a.out file header */
@@ -78,9 +77,10 @@ DEFUN(newsos3_callback,(abfd),
   
   WORK_OUT_FILE_POSITIONS(abfd, execp) ;
   
-  /* Determine the architecture and machine type of the object file.  */
-  abfd->obj_arch = bfd_arch_m68k;
-  abfd->obj_machine = 0;
+  /* Determine the architecture and machine type of the object file.
+   */
+  bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
+
 
   return abfd->xvec;
 }
@@ -145,7 +145,7 @@ DEFUN(newsos3_write_object_contents,(abfd),
 bfd_target newsos3_vec = /* Sony 68k-based machines running newsos3 */
 {
   "a.out-newsos3",             /* name */
-  bfd_target_aout_flavour_enum,
+  bfd_target_aout_flavour,
   true,                                /* target byte order */
   true,                                /* target headers byte order */
   (HAS_RELOC | EXEC_P |                /* object flags */
This page took 0.024097 seconds and 4 git commands to generate.