]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/i386lynx.c
Use bool in bfd
[thirdparty/binutils-gdb.git] / bfd / i386lynx.c
index 075d1c0e80432edeb6f835517deaacfe32811823..c477e661c81d542e8b53de511cd6af87616fdb70 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for i386 a.out binaries under LynxOS.
-   Copyright (C) 1990-2015 Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
 #ifndef WRITE_HEADERS
 #define WRITE_HEADERS(abfd, execp)                                           \
       {                                                                              \
-       bfd_size_type text_size; /* dummy vars */                             \
-       file_ptr text_end;                                                    \
        if (adata(abfd).magic == undecided_magic)                             \
-         NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);     \
-                                                                             \
+         NAME(aout,adjust_sizes_and_vmas) (abfd);                            \
+                                                                             \
        execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;        \
        execp->a_entry = bfd_get_start_address (abfd);                        \
-                                                                             \
+                                                                             \
        execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *                \
                           obj_reloc_entry_size (abfd));                      \
        execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *                \
        if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0                      \
            || bfd_bwrite (&exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
                          abfd) != EXEC_BYTES_SIZE)                           \
-         return FALSE;                                                       \
+         return false;                                                       \
        /* Now write out reloc info, followed by syms and strings */          \
-                                                                             \
-       if (bfd_get_symcount (abfd) != 0)                                     \
+                                                                             \
+       if (bfd_get_symcount (abfd) != 0)                                     \
            {                                                                 \
-             if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET)    \
+             if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (execp)), SEEK_SET)    \
                  != 0)                                                       \
-               return FALSE;                                                 \
+               return false;                                                 \
                                                                              \
-             if (! NAME(aout,write_syms) (abfd)) return FALSE;               \
+             if (! NAME(aout,write_syms) (abfd)) return false;               \
                                                                              \
-             if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET)   \
+             if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (execp)), SEEK_SET)   \
                  != 0)                                                       \
-               return FALSE;                                                 \
+               return false;                                                 \
                                                                              \
              if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd)))   \
-               return FALSE;                                                 \
-             if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET)   \
+               return false;                                                 \
+             if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (execp)), SEEK_SET)   \
                  != 0)                                                       \
-               return 0;                                                     \
+               return 0;                                                     \
                                                                              \
              if (!NAME(lynx,squirt_out_relocs) (abfd, obj_datasec (abfd)))   \
-               return FALSE;                                                 \
+               return false;                                                 \
            }                                                                 \
       }
 #endif
@@ -88,7 +86,7 @@
 
 char *lynx_core_file_failing_command ();
 int lynx_core_file_failing_signal ();
-bfd_boolean lynx_core_file_matches_executable_p ();
+bool lynx_core_file_matches_executable_p ();
 const bfd_target *lynx_core_file_p ();
 
 #define        MY_core_file_failing_command lynx_core_file_failing_command
@@ -281,7 +279,7 @@ NAME(lynx,swap_ext_reloc_out) (bfd *abfd,
    to give the true offset from the section */
 
 
-#define MOVE_ADDRESS(ad)                                                       \
+#define MOVE_ADDRESS(ad)                                               \
   if (r_extern)                                                                \
     {                                                                  \
    /* undefined symbol */                                              \
@@ -290,7 +288,7 @@ NAME(lynx,swap_ext_reloc_out) (bfd *abfd,
     }                                                                  \
   else                                                                 \
     {                                                                  \
-    /* defined, section relative. replace symbol with pointer to       \
+    /* defined, section relative. replace symbol with pointer to       \
        symbol which points to section  */                              \
     switch (r_index) {                                                 \
     case N_TEXT:                                                       \
@@ -315,7 +313,7 @@ NAME(lynx,swap_ext_reloc_out) (bfd *abfd,
       cache_ptr->addend = ad;                                          \
       break;                                                           \
     }                                                                  \
-  }                                                                    \
+  }                                                                    \
 
 static void
 NAME(lynx,swap_ext_reloc_in) (bfd *abfd,
@@ -369,7 +367,7 @@ NAME(lynx,swap_std_reloc_in) (bfd *abfd,
 
 /* Reloc hackery */
 
-static bfd_boolean
+static bool
 NAME(lynx,slurp_reloc_table) (bfd *abfd,
                              sec_ptr asect,
                              asymbol **symbols)
@@ -381,10 +379,10 @@ NAME(lynx,slurp_reloc_table) (bfd *abfd,
   size_t each_size;
 
   if (asect->relocation)
-    return TRUE;
+    return true;
 
   if (asect->flags & SEC_CONSTRUCTOR)
-    return TRUE;
+    return true;
 
   if (asect == obj_datasec (abfd))
     {
@@ -399,11 +397,11 @@ NAME(lynx,slurp_reloc_table) (bfd *abfd,
     }
 
   bfd_set_error (bfd_error_invalid_operation);
-  return FALSE;
+  return false;
 
-doit:
+ doit:
   if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
-    return FALSE;
+    return false;
   each_size = obj_reloc_entry_size (abfd);
 
   count = reloc_size / each_size;
@@ -411,20 +409,13 @@ doit:
 
   reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
   if (!reloc_cache && count != 0)
-    return FALSE;
+    return false;
 
-  relocs = bfd_alloc (abfd, reloc_size);
+  relocs = _bfd_alloc_and_read (abfd, reloc_size, reloc_size);
   if (!relocs && reloc_size != 0)
     {
       free (reloc_cache);
-      return FALSE;
-    }
-
-  if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
-    {
-      bfd_release (abfd, relocs);
-      free (reloc_cache);
-      return FALSE;
+      return false;
     }
 
   if (each_size == RELOC_EXT_SIZE)
@@ -456,14 +447,14 @@ doit:
   bfd_release (abfd, relocs);
   asect->relocation = reloc_cache;
   asect->reloc_count = count;
-  return TRUE;
+  return true;
 }
 
 
 
 /* Write out a relocation section into an object file.  */
 
-static bfd_boolean
+static bool
 NAME(lynx,squirt_out_relocs) (bfd *abfd, asection *section)
 {
   arelent **generic;
@@ -473,14 +464,14 @@ NAME(lynx,squirt_out_relocs) (bfd *abfd, asection *section)
   bfd_size_type natsize;
 
   if (count == 0)
-    return TRUE;
+    return true;
 
   each_size = obj_reloc_entry_size (abfd);
   natsize = count;
   natsize *= each_size;
   native = (unsigned char *) bfd_zalloc (abfd, natsize);
   if (!native)
-    return FALSE;
+    return false;
 
   generic = section->orelocation;
 
@@ -502,11 +493,11 @@ NAME(lynx,squirt_out_relocs) (bfd *abfd, asection *section)
   if (bfd_bwrite (native, natsize, abfd) != natsize)
     {
       bfd_release (abfd, native);
-      return FALSE;
+      return false;
     }
   bfd_release (abfd, native);
 
-  return TRUE;
+  return true;
 }
 
 /* This is stupid.  This function should be a boolean predicate */