diff options
author | Alan Modra <amodra@gmail.com> | 2024-04-11 11:56:50 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-04-11 17:05:16 +0930 |
commit | af925905211930677751678183f43c1bda13e013 (patch) | |
tree | 4003f40a03ceebde7ac611aa9d7a1dc0dcd72d8a /bfd/pdp11.c | |
parent | de9dc65bd45c118d56600bbf1786322284fde795 (diff) | |
download | fsf-binutils-gdb-af925905211930677751678183f43c1bda13e013.zip fsf-binutils-gdb-af925905211930677751678183f43c1bda13e013.tar.gz fsf-binutils-gdb-af925905211930677751678183f43c1bda13e013.tar.bz2 |
Remove bfdwin.c
In commit b86d3af60ffc and 0ab0435fe672 I fixed SIGBUS errors found by
oss-fuzz now that --with-mmap defaults to enabled. It turns out there
are further problems with the aout mmap code: aout_read_minisymbols
returns the external symbol array, which is later freed by nm.c. If
the array is mmaped you can't free it. Now this could be fixed by
making aout minisymbols an array of pointers, but I figure there's not
much point in expending effort on that. So delete the aout mmap
support along with bfdwin.c and get_section_contents_in_window.
Diffstat (limited to 'bfd/pdp11.c')
-rw-r--r-- | bfd/pdp11.c | 90 |
1 files changed, 18 insertions, 72 deletions
diff --git a/bfd/pdp11.c b/bfd/pdp11.c index b20c396..ef86400 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -594,11 +594,6 @@ NAME (aout, some_aout_object_p) (bfd *abfd, /* The default symbol entry size is that of traditional Unix. */ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE; -#ifdef USE_MMAP - bfd_init_window (&obj_aout_sym_window (abfd)); - bfd_init_window (&obj_aout_string_window (abfd)); -#endif - if (! NAME (aout, make_sections) (abfd)) goto error_ret; @@ -1276,10 +1271,6 @@ NAME (aout, set_section_contents) (bfd *abfd, static bool aout_get_external_symbols (bfd *abfd) { -#ifdef USE_MMAP - ufile_ptr filesize = bfd_get_file_size (abfd); -#endif - if (obj_aout_external_syms (abfd) == NULL) { bfd_size_type count; @@ -1292,27 +1283,14 @@ aout_get_external_symbols (bfd *abfd) if (count == 0) return true; -#ifdef USE_MMAP - if (filesize >= (ufile_ptr) obj_sym_filepos (abfd) - && filesize - obj_sym_filepos (abfd) >= amt) - { - if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), amt, - &obj_aout_sym_window (abfd), true)) - return false; - syms = obj_aout_sym_window (abfd).data; - } - else -#endif - { - /* We allocate using malloc to make the values easy to free - later on. If we put them on the objalloc it might not be - possible to free them. */ - if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) - return false; - syms = _bfd_malloc_and_read (abfd, amt, amt); - if (syms == NULL) - return false; - } + /* We allocate using malloc to make the values easy to free + later on. If we put them on the objalloc it might not be + possible to free them. */ + if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) + return false; + syms = _bfd_malloc_and_read (abfd, amt, amt); + if (syms == NULL) + return false; obj_aout_external_syms (abfd) = syms; obj_aout_external_sym_count (abfd) = count; @@ -1340,33 +1318,20 @@ aout_get_external_symbols (bfd *abfd) return false; } -#ifdef USE_MMAP - if (stringsize >= BYTES_IN_LONG - && filesize >= (ufile_ptr) obj_str_filepos (abfd) - && filesize - obj_str_filepos (abfd) >= stringsize + 1) - { - if (! bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize + 1, - &obj_aout_string_window (abfd), true)) - return false; - strings = (char *) obj_aout_string_window (abfd).data; - } - else -#endif - { - strings = (char *) bfd_malloc (stringsize + 1); - if (strings == NULL) - return false; + strings = (char *) bfd_malloc (stringsize + 1); + if (strings == NULL) + return false; - if (stringsize >= BYTES_IN_LONG) + if (stringsize >= BYTES_IN_LONG) + { + amt = stringsize - BYTES_IN_LONG; + if (bfd_read (strings + BYTES_IN_LONG, amt, abfd) != amt) { - amt = stringsize - BYTES_IN_LONG; - if (bfd_read (strings + BYTES_IN_LONG, amt, abfd) != amt) - { - free (strings); - return false; - } + free (strings); + return false; } } + /* Ensure that a zero index yields an empty string. */ if (stringsize >= BYTES_IN_WORD) memset (strings, 0, BYTES_IN_LONG); @@ -1685,11 +1650,7 @@ NAME (aout, slurp_symbol_table) (bfd *abfd) if (old_external_syms == NULL && obj_aout_external_syms (abfd) != 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; } @@ -2567,15 +2528,8 @@ NAME (aout, bfd_free_cached_info) (bfd *abfd) #define BFCI_FREE(x) do { free (x); x = NULL; } while (0) BFCI_FREE (adata (abfd).line_buf); 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 (asection *o = abfd->sections; o != NULL; o = o->next) BFCI_FREE (o->relocation); #undef BFCI_FREE @@ -2654,21 +2608,13 @@ aout_link_free_symbols (bfd *abfd) { if (obj_aout_external_syms (abfd) != NULL) { -#ifdef USE_MMAP - bfd_free_window (&obj_aout_sym_window (abfd)); -#else free ((void *) obj_aout_external_syms (abfd)); -#endif obj_aout_external_syms (abfd) = NULL; } if (obj_aout_external_strings (abfd) != NULL) { -#ifdef USE_MMAP - bfd_free_window (&obj_aout_string_window (abfd)); -#else free ((void *) obj_aout_external_strings (abfd)); -#endif obj_aout_external_strings (abfd) = NULL; } return true; |