* elfcode.h (elf_slurp_reloc_table): Add dynamic parameter.
[deliverable/binutils-gdb.git] / bfd / nlm32-sparc.c
index ef2f3948078e617988063d7be7033a189d438d81..5626a86611900e5e0ac7e0965e933667b9c114bd 100644 (file)
@@ -122,18 +122,14 @@ nlm_sparc_read_reloc (abfd, sym, secp, rel)
      asection **secp;
      arelent *rel;
 {
-  bfd_byte temp[4];
   bfd_vma val, addend;
-  const char *name;
   int index;
   unsigned int type;
   struct nlm32_sparc_reloc_ext tmp_reloc;
   asection *code_sec, *data_sec;
 
-  if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12) {
-    bfd_error = system_call_error;
+  if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
     return false;
-  }
 
   code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
   data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
@@ -173,7 +169,7 @@ nlm_sparc_write_reloc (abfd, sec, rel)
      arelent *rel;
 {
   bfd_vma val;
-  struct nlm32_sparc_reloc_ext tmp_reloc = {0};
+  struct nlm32_sparc_reloc_ext tmp_reloc;
   int index;
   int type = -1;
   reloc_howto_type *tmp;
@@ -257,17 +253,14 @@ nlm_sparc_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;
   
   /*
    * First, read in the number of relocation
    * entries for this symbol
    */
-  if (bfd_read ((PTR) temp, 4, 1, abfd)
-      != 4)
-    {
-      bfd_error = system_call_error;
-      return (false);
-    }
+  if (bfd_read ((PTR) temp, 4, 1, abfd) != 4)
+    return false;
   
   rcount = bfd_get_32 (abfd, temp);
   
@@ -277,23 +270,23 @@ nlm_sparc_read_import (abfd, sym)
   
   if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
       != sizeof (symlength))
+    return false;
+  sym -> symbol.the_bfd = abfd;
+  name = bfd_alloc (abfd, symlength + 1);
+  if (name == NULL)
     {
-      bfd_error = system_call_error;
-      return (false);
+      bfd_set_error (bfd_error_no_memory);
+      return false;
     }
-  sym -> symbol.the_bfd = abfd;
-  sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
   
   /*
    * Then read in the symbol
    */
   
-  if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
-      != symlength)
-    {
-      bfd_error = system_call_error;
-      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;
@@ -304,6 +297,11 @@ nlm_sparc_read_import (abfd, sym)
   
   nlm_relocs = ((struct nlm_relent *)
                bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
+  if (!nlm_relocs)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return false;
+    }
   sym -> relocs = nlm_relocs;
   sym -> rcnt = 0;
   while (sym -> rcnt < rcount)
@@ -373,18 +371,12 @@ nlm_sparc_write_external (abfd, count, sym, relocs)
 
   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;
 
   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;
 
   for (i = 0; i < count; i++)
     {
@@ -415,10 +407,7 @@ nlm_sparc_write_export (abfd, sym, value)
   if (bfd_write (temp, 4, 1, abfd) != 4
       || bfd_write (&len, 1, 1, abfd) != 1
       || bfd_write (sym->name, len, 1, abfd) != len)
-    {
-      bfd_error = system_call_error;
-      return false;
-    }
+    return false;
 
   return true;
 }
This page took 0.024481 seconds and 4 git commands to generate.