aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1994-04-04 01:28:51 +0000
committerJeff Law <law@redhat.com>1994-04-04 01:28:51 +0000
commit1f46bba3276eadac2108d002ad38a55e82224fbb (patch)
treed734e72785ffb713a53d6b1a55f6096336b21db3 /bfd
parentd54123026030d3532c01564f6671aa84270a244c (diff)
downloadgdb-1f46bba3276eadac2108d002ad38a55e82224fbb.zip
gdb-1f46bba3276eadac2108d002ad38a55e82224fbb.tar.gz
gdb-1f46bba3276eadac2108d002ad38a55e82224fbb.tar.bz2
* som.c (som_slurp_string_table): Use malloc to allocate space
for the cached copy of the native string table. (som_slurp_symbol_table): Likewise for the native symbol table. (som_slurp_reloc_table): Likewise for the native and generic relocation tables. (som_bfd_free_cached_info): Free the cached native strings, symbols, and relocations. Also free the canonical cached relocations.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog11
-rw-r--r--bfd/som.c45
2 files changed, 50 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f7b00c2..9eb9f46 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,14 @@
+Sun Apr 3 18:27:29 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_slurp_string_table): Use malloc to allocate space
+ for the cached copy of the native string table.
+ (som_slurp_symbol_table): Likewise for the native symbol table.
+ (som_slurp_reloc_table): Likewise for the native and generic
+ relocation tables.
+ (som_bfd_free_cached_info): Free the cached native strings,
+ symbols, and relocations. Also free the canonical cached
+ relocations.
+
Fri Apr 1 12:40:58 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* aoutx.h (aout_link_write_symbols): If keep_memory is false, make
diff --git a/bfd/som.c b/bfd/som.c
index ac7057d..63f406a 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -3530,8 +3530,17 @@ som_slurp_string_table (abfd)
if (obj_som_stringtab (abfd) != NULL)
return true;
+ /* I don't think this can currently happen, and I'm not sure it should
+ really be an error, but it's better than getting unpredictable results
+ from the host's malloc when passed a size of zero. */
+ if (obj_som_stringtab_size (abfd) == 0)
+ {
+ bfd_set_error (bfd_error_no_symbols);
+ return false;
+ }
+
/* Allocate and read in the string table. */
- stringtab = bfd_zalloc (abfd, obj_som_stringtab_size (abfd));
+ stringtab = malloc (obj_som_stringtab_size (abfd));
if (stringtab == NULL)
{
bfd_set_error (bfd_error_no_memory);
@@ -3634,7 +3643,7 @@ som_slurp_symbol_table (abfd)
stringtab = obj_som_stringtab (abfd);
symbase = (som_symbol_type *)
- bfd_zalloc (abfd, symbol_count * sizeof (som_symbol_type));
+ malloc (symbol_count * sizeof (som_symbol_type));
if (symbase == NULL)
{
bfd_set_error (bfd_error_no_memory);
@@ -4122,7 +4131,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
parsed. We must do so now to know how many relocations exist. */
if (section->reloc_count == -1)
{
- external_relocs = (char *) bfd_zalloc (abfd, fixup_stream_size);
+ external_relocs = (char *) malloc (fixup_stream_size);
if (external_relocs == (char *) NULL)
{
bfd_set_error (bfd_error_no_memory);
@@ -4158,8 +4167,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
if (section->relocation != (arelent *) NULL)
return true;
- internal_relocs = (arelent *) bfd_zalloc (abfd,
- num_relocs * sizeof (arelent));
+ internal_relocs = (arelent *) malloc (num_relocs * sizeof (arelent));
if (internal_relocs == (arelent *) NULL)
{
bfd_set_error (bfd_error_no_memory);
@@ -5442,6 +5450,32 @@ som_write_armap (abfd)
return true;
}
+/* Free all information we have cached for this BFD. We can always
+ read it again later if we need it. */
+
+static boolean
+som_bfd_free_cached_info (abfd)
+ bfd *abfd;
+{
+ asection *o;
+
+#define FREE(x) if (x != NULL) { free (x); x = NULL; }
+ /* Free the native string and symbol tables. */
+ FREE (obj_som_symtab (abfd));
+ FREE (obj_som_stringtab (abfd));
+ for (o = abfd->sections; o != (asection *) NULL; o = o->next)
+ {
+ /* Free the native relocations. */
+ o->reloc_count = -1;
+ FREE (som_section_data (o)->reloc_stream);
+ /* Free the generic relocations. */
+ FREE (o->relocation);
+ }
+#undef FREE
+
+ return true;
+}
+
/* End of miscellaneous support functions. */
#define som_bfd_debug_info_start bfd_void
@@ -5464,7 +5498,6 @@ som_write_armap (abfd)
#define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define som_bfd_final_link _bfd_generic_final_link
-#define som_bfd_free_cached_info bfd_true
/* Core file support is in the hpux-core backend. */
#define som_core_file_failing_command _bfd_dummy_core_file_failing_command