* configure.in: Added new option --with[out]-mmap. Set USE_MMAP if it is given
authorKen Raeburn <raeburn@cygnus>
Thu, 9 Nov 1995 09:14:01 +0000 (09:14 +0000)
committerKen Raeburn <raeburn@cygnus>
Thu, 9 Nov 1995 09:14:01 +0000 (09:14 +0000)
and mmep is available.
* acconfig.h: Undef USE_MMAP.
* configure, config.in: Regenerated.
* aoutx.h: If USE_MMAP is not defined, do all symbol and string table handling
the old way.
(aout_get_external_symbols): Don't complain if last byte of string table is
nonzero.
* libbfd.c [HAVE_MADVISE]: Include sys/types.h and sys/mman.h.
(bfd_free_window) [! USE_MMAP]: Don't define.
(bfd_get_file_window, _bfd_generic_get_section_contents_in_window)
 [! USE_MMAP]: Abort.

bfd/ChangeLog
bfd/acconfig.h
bfd/aoutx.h

index 48f9a9083b10c7f810c9cb74ed8d784b42949902..0b460780db10cc276dbf31262ece084deed276c1 100644 (file)
@@ -1,3 +1,18 @@
+Thu Nov  9 04:00:38 1995  Ken Raeburn  <raeburn@cygnus.com>
+
+       * configure.in: Added new option --with[out]-mmap.  Set USE_MMAP
+       if it is given and mmep is available.
+       * acconfig.h: Undef USE_MMAP.
+       * configure, config.in: Regenerated.
+       * aoutx.h: If USE_MMAP is not defined, do all symbol and string
+       table handling the old way.
+       (aout_get_external_symbols): Don't complain if last byte of string
+       table is nonzero.
+       * libbfd.c [HAVE_MADVISE]: Include sys/types.h and sys/mman.h.
+       (bfd_free_window) [! USE_MMAP]: Don't define.
+       (bfd_get_file_window,
+       _bfd_generic_get_section_contents_in_window) [! USE_MMAP]: Abort.
+
 Wed Nov  8 20:03:44 1995  Eric Freudenthal <freudenthal@nyu.edu>
 
        * coff-a29k.c (SIGN_EXTEND_HWORD): Use ~0xffff rather than
index 3bf51033830438acd314763738b847b4c7bb785b..43bcf709004dc240962d7468c3632912e47d4429 100644 (file)
@@ -12,3 +12,6 @@
 
 /* Define only if <sys/procfs.h> is available *and* it defines prstatus_t.  */
 #undef HAVE_SYS_PROCFS_H
+
+/* Do we really want to use mmap if it's available?  */
+#undef USE_MMAP
index 8d36de5d1f6aeec826c7ea1104cda4bc5fdd38ad..c5da2192b7af759a6a7c1d45bf48617a60a8baf8 100644 (file)
@@ -496,10 +496,12 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   /* The default symbol entry size is that of traditional Unix. */
   obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
 
-  obj_aout_external_syms (abfd) = NULL;
+#ifdef USE_MMAP
   bfd_init_window (&obj_aout_sym_window (abfd));
-  obj_aout_external_strings (abfd) = NULL;
   bfd_init_window (&obj_aout_string_window (abfd));
+#endif
+  obj_aout_external_syms (abfd) = NULL;
+  obj_aout_external_strings (abfd) = NULL;
   obj_aout_sym_hashes (abfd) = NULL;
 
   if (! NAME(aout,make_sections) (abfd))
@@ -1228,11 +1230,32 @@ aout_get_external_symbols (abfd)
 
       count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
 
+#ifdef USE_MMAP
       if (bfd_get_file_window (abfd,
                               obj_sym_filepos (abfd), exec_hdr (abfd)->a_syms,
                               &obj_aout_sym_window (abfd), true) == false)
        return false;
       syms = (struct external_nlist *) obj_aout_sym_window (abfd).data;
+#else
+      /* We allocate using malloc to make the values easy to free
+        later on.  If we put them on the obstack it might not be
+        possible to free them.  */
+      syms = ((struct external_nlist *)
+             malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
+      if (syms == (struct external_nlist *) NULL && count != 0)
+       {
+         bfd_set_error (bfd_error_no_memory);
+         return false;
+       }
+
+      if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+         || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
+             != exec_hdr (abfd)->a_syms))
+       {
+         free (syms);
+         return false;
+       }
+#endif
 
       obj_aout_external_syms (abfd) = syms;
       obj_aout_external_sym_count (abfd) = count;
@@ -1252,25 +1275,34 @@ aout_get_external_symbols (abfd)
        return false;
       stringsize = GET_WORD (abfd, string_chars);
 
+#ifdef USE_MMAP
       if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
                               &obj_aout_string_window (abfd), true) == false)
        return false;
       strings = (char *) obj_aout_string_window (abfd).data;
+#else
+      strings = (char *) malloc ((size_t) stringsize + 1);
+      if (strings == NULL)
+       {
+         bfd_set_error (bfd_error_no_memory);
+         return false;
+       }
+
+      /* Skip space for the string count in the buffer for convenience
+        when using indexes.  */
+      if (bfd_read (strings + BYTES_IN_WORD, 1, stringsize - BYTES_IN_WORD,
+                   abfd)
+         != stringsize - BYTES_IN_WORD)
+       {
+         free (strings);
+         return false;
+       }
+#endif
 
       /* Ensure that a zero index yields an empty string.  */
       strings[0] = '\0';
 
-      /* Using the "window" interface, we don't know that there's
-        writeable storage after the last byte of the string table.
-        Besides, every string in the string table should be null
-        terminated.  Check it here so the application doesn't crash,
-        but don't expend huge effort trying to correct a broken
-        object file.  */
-      if (stringsize > BYTES_IN_WORD && strings[stringsize - 1] != 0)
-       {
-         fprintf (stderr, "string table missing ending null\n");
-         strings[stringsize - 1] = 0;
-       }
+      strings[stringsize - 1] = 0;
 
       obj_aout_external_strings (abfd) = strings;
       obj_aout_external_string_size (abfd) = stringsize;
@@ -1741,7 +1773,11 @@ NAME(aout,slurp_symbol_table) (abfd)
   if (old_external_syms == (struct external_nlist *) NULL
       && obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
     {
+#ifdef USE_MMAP
       bfd_free_window (&obj_aout_sym_window (abfd));
+#else
+      free (obj_aout_external_syms (abfd));
+#endif
       obj_aout_external_syms (abfd) = NULL;
     }
 
@@ -2770,10 +2806,15 @@ NAME(aout,bfd_free_cached_info) (abfd)
 
 #define BFCI_FREE(x) if (x != NULL) { free (x); x = NULL; }
   BFCI_FREE (obj_aout_symbols (abfd));
+#ifdef USE_MMAP
   obj_aout_external_syms (abfd) = 0;
   bfd_free_window (&obj_aout_sym_window (abfd));
   bfd_free_window (&obj_aout_string_window (abfd));
   obj_aout_external_strings (abfd) = 0;
+#else
+  BFCI_FREE (obj_aout_external_syms (abfd));
+  BFCI_FREE (obj_aout_external_strings (abfd));
+#endif
   for (o = abfd->sections; o != (asection *) NULL; o = o->next)
     BFCI_FREE (o->relocation);
 #undef BFCI_FREE
@@ -2945,12 +2986,20 @@ aout_link_free_symbols (abfd)
 {
   if (obj_aout_external_syms (abfd) != (struct external_nlist *) NULL)
     {
+#ifdef USE_MMAP
       bfd_free_window (&obj_aout_sym_window (abfd));
+#else
+      free ((PTR) obj_aout_external_syms (abfd));
+#endif
       obj_aout_external_syms (abfd) = (struct external_nlist *) NULL;
     }
   if (obj_aout_external_strings (abfd) != (char *) NULL)
     {
+#ifdef USE_MMAP
       bfd_free_window (&obj_aout_string_window (abfd));
+#else
+      free ((PTR) obj_aout_external_strings (abfd));
+#endif
       obj_aout_external_strings (abfd) = (char *) NULL;
     }
   return true;
This page took 0.032269 seconds and 4 git commands to generate.