* elf.c (assign_file_positions_for_segments): Set next_file_pos even
[deliverable/binutils-gdb.git] / bfd / cpu-arm.c
index 9ef527cb94360058da7f3a79e31fc43c6342c991..ea923c3409f35a082c1877d73d18a5adf316f6b7 100644 (file)
@@ -1,5 +1,6 @@
 /* BFD support for the ARM processor
-   Copyright 1994, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 1994, 1997, 1999, 2000, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -155,7 +156,7 @@ const bfd_arch_info_type bfd_arm_arch =
 
 /* Support functions used by both the COFF and ELF versions of the ARM port.  */
 
-/* Handle the mergeing of the 'machine' settings of input file IBFD
+/* Handle the merging of the 'machine' settings of input file IBFD
    and an output file OBFD.  These values actually represent the
    different possible ARM architecture variants.
    Returns TRUE if they were merged successfully or FALSE otherwise.  */
@@ -172,7 +173,7 @@ bfd_arm_merge_machines (ibfd, obfd)
   if (out == bfd_mach_arm_unknown)
     bfd_set_arch_mach (obfd, bfd_arch_arm, in);
 
-  /* If the input architecure is unknown,
+  /* If the input architecture is unknown,
      then so must be the output architecture.  */
   else if (in == bfd_mach_arm_unknown)
     /* FIXME: We ought to have some way to
@@ -184,7 +185,7 @@ bfd_arm_merge_machines (ibfd, obfd)
     ;
 
   /* Otherwise the general principle that a earlier architecture can be
-     linked with a later architecure to produce a binary that will execute
+     linked with a later architecture to produce a binary that will execute
      on the later architecture.
 
      We fail however if we attempt to link a Cirrus EP9312 binary with an
@@ -194,9 +195,8 @@ bfd_arm_merge_machines (ibfd, obfd)
           && (out == bfd_mach_arm_XScale || out == bfd_mach_arm_iWMMXt))
     {
       _bfd_error_handler (_("\
-ERROR: %s is compiled for the EP9312, whereas %s is compiled for XScale"),
-                         bfd_archive_filename (ibfd),
-                         bfd_get_filename (obfd));
+ERROR: %B is compiled for the EP9312, whereas %B is compiled for XScale"),
+                         ibfd, obfd);
       bfd_set_error (bfd_error_wrong_format);
       return FALSE;
     }
@@ -204,9 +204,8 @@ ERROR: %s is compiled for the EP9312, whereas %s is compiled for XScale"),
           && (in == bfd_mach_arm_XScale || in == bfd_mach_arm_iWMMXt))
     {
       _bfd_error_handler (_("\
-ERROR: %s is compiled for the EP9312, whereas %s is compiled for XScale"),
-                         bfd_archive_filename (obfd),
-                         bfd_get_filename (ibfd));
+ERROR: %B is compiled for the EP9312, whereas %B is compiled for XScale"),
+                         obfd, ibfd);
       bfd_set_error (bfd_error_wrong_format);
       return FALSE;
     }
@@ -286,7 +285,7 @@ bfd_arm_update_notes (abfd, note_section)
 {
   asection *     arm_arch_section;
   bfd_size_type  buffer_size;
-  char *         buffer;
+  bfd_byte *     buffer;
   char *         arch_string;
   char *         expected;
 
@@ -298,16 +297,11 @@ bfd_arm_update_notes (abfd, note_section)
   if (arm_arch_section == NULL)
     return TRUE;
 
-  buffer_size = arm_arch_section->_raw_size;
+  buffer_size = arm_arch_section->size;
   if (buffer_size == 0)
     return FALSE;
 
-  buffer = bfd_malloc (buffer_size);
-  if (buffer == NULL)
-    return FALSE;
-  
-  if (! bfd_get_section_contents (abfd, arm_arch_section, buffer,
-                                 (file_ptr) 0, buffer_size))
+  if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer))
     goto FAIL;
 
   /* Parse the note.  */
@@ -351,7 +345,8 @@ bfd_arm_update_notes (abfd, note_section)
   return TRUE;
 
  FAIL:
-  free (buffer);
+  if (buffer != NULL)
+    free (buffer);
   return FALSE;
 }
 
@@ -385,7 +380,7 @@ bfd_arm_get_mach_from_notes (abfd, note_section)
 {
   asection *     arm_arch_section;
   bfd_size_type  buffer_size;
-  char *         buffer;
+  bfd_byte *     buffer;
   char *         arch_string;
   int            i;
 
@@ -397,16 +392,11 @@ bfd_arm_get_mach_from_notes (abfd, note_section)
   if (arm_arch_section == NULL)
     return bfd_mach_arm_unknown;
 
-  buffer_size = arm_arch_section->_raw_size;
+  buffer_size = arm_arch_section->size;
   if (buffer_size == 0)
     return bfd_mach_arm_unknown;
 
-  buffer = bfd_malloc (buffer_size);
-  if (buffer == NULL)
-    return bfd_mach_arm_unknown;
-  
-  if (! bfd_get_section_contents (abfd, arm_arch_section, buffer,
-                                 (file_ptr) 0, buffer_size))
+  if (!bfd_malloc_and_get_section (abfd, arm_arch_section, &buffer))
     goto FAIL;
 
   /* Parse the note.  */
@@ -422,6 +412,7 @@ bfd_arm_get_mach_from_notes (abfd, note_section)
       }
 
  FAIL:
-  free (buffer);
+  if (buffer != NULL)
+    free (buffer);
   return bfd_mach_arm_unknown;
 }
This page took 0.024638 seconds and 4 git commands to generate.