2000-11-06 Kazu Hirata <kazu@hxi.com>
[deliverable/binutils-gdb.git] / bfd / nlm32-i386.c
index 45260c5cb751ba51c01db582cc03aa8f76f9456c..f16c74d985eb766bcf83b79c226ffe103ebc3572 100644 (file)
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 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.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -87,10 +87,7 @@ nlm_i386_read_reloc (abfd, sym, secp, rel)
   const char *name;
 
   if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   val = bfd_get_32 (abfd, temp);
 
@@ -176,7 +173,7 @@ nlm_i386_write_import (abfd, sec, rel)
       || rel->howto->src_mask != 0xffffffff
       || rel->howto->dst_mask != 0xffffffff)
     {
-      bfd_error = invalid_operation;
+      bfd_set_error (bfd_error_invalid_operation);
       return false;
     }
 
@@ -199,12 +196,12 @@ nlm_i386_write_import (abfd, sec, rel)
   else
     val -= nlm_get_data_low (abfd);
 
-  if (bfd_get_section (sym) != &bfd_und_section)
+  if (! bfd_is_und_section (bfd_get_section (sym)))
     {
       /* NetWare only supports absolute internal relocs.  */
       if (rel->howto->pc_relative)
        {
-         bfd_error = invalid_operation;
+         bfd_set_error (bfd_error_invalid_operation);
          return false;
        }
 
@@ -224,7 +221,7 @@ nlm_i386_write_import (abfd, sec, rel)
          /* PC relative relocs on NetWare must be pcrel_offset.  */
          if (! rel->howto->pcrel_offset)
            {
-             bfd_error = invalid_operation;
+             bfd_set_error (bfd_error_invalid_operation);
              return false;
            }
        }
@@ -232,10 +229,7 @@ nlm_i386_write_import (abfd, sec, rel)
   
   bfd_put_32 (abfd, val, temp);
   if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   return true;
 }
@@ -354,32 +348,29 @@ nlm_i386_read_import (abfd, sym)
   bfd_size_type rcount;                        /* number of relocs */
   bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
   unsigned char symlength;             /* length of symbol name */
+  char *name;
 
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   sym -> symbol.the_bfd = abfd;
-  sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
-  if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
-      != symlength)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+  name = bfd_alloc (abfd, symlength + 1);
+  if (name == NULL)
+    return false;
+  if (bfd_read (name, symlength, 1, abfd) != symlength)
+    return false;
+  name[symlength] = '\0';
+  sym -> symbol.name = name;
   sym -> symbol.flags = 0;
   sym -> symbol.value = 0;
-  sym -> symbol.section = &bfd_und_section;
+  sym -> symbol.section = bfd_und_section_ptr;
   if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+    return false;
   rcount = bfd_h_get_32 (abfd, temp);
   nlm_relocs = ((struct nlm_relent *)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
+  if (!nlm_relocs)
+    return false;
   sym -> relocs = nlm_relocs;
   sym -> rcnt = 0;
   while (sym -> rcnt < rcount)
@@ -406,24 +397,18 @@ nlm_i386_write_external (abfd, count, sym, relocs)
      asymbol *sym;
      struct reloc_and_sec *relocs;
 {
-  int i;
+  unsigned int i;
   bfd_byte len;
   unsigned char temp[NLM_TARGET_LONG_SIZE];
 
   len = strlen (sym->name);
   if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   bfd_put_32 (abfd, count, temp);
   if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   for (i = 0; i < count; i++)
     {
@@ -444,6 +429,7 @@ static const struct nlm_backend_data nlm32_i386_backend =
   0,   /* optional_prefix_size */
   bfd_arch_i386,
   0,
+  false,
   0,   /* backend_object_p */
   0,   /* write_prefix_func */
   nlm_i386_read_reloc,
@@ -455,6 +441,7 @@ static const struct nlm_backend_data nlm32_i386_backend =
   nlm_swap_fixed_header_in,
   nlm_swap_fixed_header_out,
   nlm_i386_write_external,
+  0,   /* write_export */
 };
 
 #define TARGET_LITTLE_NAME             "nlm32-i386"
This page took 0.025234 seconds and 4 git commands to generate.