diff options
author | Ken Raeburn <raeburn@cygnus> | 1995-11-09 09:14:01 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@cygnus> | 1995-11-09 09:14:01 +0000 |
commit | 7ac847361b0b12d5cbac9db713318eb465329f7c (patch) | |
tree | f8906f577dd934f62a9945092f59df1708fbab03 /bfd/aoutx.h | |
parent | 653b07da0c7fee7394d8111d337481b3e449efa8 (diff) | |
download | gdb-7ac847361b0b12d5cbac9db713318eb465329f7c.zip gdb-7ac847361b0b12d5cbac9db713318eb465329f7c.tar.gz gdb-7ac847361b0b12d5cbac9db713318eb465329f7c.tar.bz2 |
* 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.
Diffstat (limited to 'bfd/aoutx.h')
-rw-r--r-- | bfd/aoutx.h | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 8d36de5..c5da219 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -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; |