(add_to_section_table): Initialize 'key' field.
(add_target_sections, remove_target_sections): Add 'key' argument.
* exec.h (add_target_sections, remove_target_sections): Add
'key' argument.
* solib.c (solib_map_sections, update_solib_list, clear_solib)
(reload_shared_libraries_1): Update.
* target.h (struct target_section) <key>: New field.
+2012-08-22 Tom Tromey <tromey@redhat.com>
+
+ * exec.c (exec_close, exec_file_attach): Update.
+ (add_to_section_table): Initialize 'key' field.
+ (add_target_sections, remove_target_sections): Add 'key' argument.
+ * exec.h (add_target_sections, remove_target_sections): Add
+ 'key' argument.
+ * solib.c (solib_map_sections, update_solib_list, clear_solib)
+ (reload_shared_libraries_1): Update.
+ * target.h (struct target_section) <key>: New field.
+
2012-08-22 Tom Tromey <tromey@redhat.com>
* cli/cli-cmds.c (filter_sals): Handle nelts == 0 case.
exec_bfd = NULL;
exec_bfd_mtime = 0;
- remove_target_sections (abfd);
+ remove_target_sections (&exec_bfd, abfd);
}
}
/* Add the executable's sections to the current address spaces'
list of sections. This possibly pushes the exec_ops
target. */
- add_target_sections (sections, sections_end);
+ add_target_sections (&exec_bfd, sections, sections_end);
xfree (sections);
/* Tell display code (if any) about the changed file name. */
if (!(aflag & SEC_ALLOC))
return;
+ (*table_pp)->key = NULL;
(*table_pp)->bfd = abfd;
(*table_pp)->the_bfd_section = asect;
(*table_pp)->addr = bfd_section_vma (abfd, asect);
current set of target sections. */
void
-add_target_sections (struct target_section *sections,
+add_target_sections (void *key,
+ struct target_section *sections,
struct target_section *sections_end)
{
int count;
if (count > 0)
{
int space = resize_section_table (table, count);
+ int i;
- memcpy (table->sections + space,
- sections, count * sizeof (sections[0]));
+ for (i = 0; i < count; ++i)
+ {
+ table->sections[space + i] = sections[i];
+ table->sections[space + i].key = key;
+ }
/* If these are the first file sections we can provide memory
from, push the file_stratum target. */
/* Remove all target sections taken from ABFD. */
void
-remove_target_sections (bfd *abfd)
+remove_target_sections (void *key, bfd *abfd)
{
struct target_section *src, *dest;
struct target_section_table *table = current_target_sections;
dest = table->sections;
for (src = table->sections; src < table->sections_end; src++)
- if (src->bfd != abfd)
+ if (src->key != key || src->bfd != abfd)
{
/* Keep this section. */
if (dest < src)
/* Remove all target sections taken from ABFD. */
-extern void remove_target_sections (bfd *abfd);
+extern void remove_target_sections (void *key, bfd *abfd);
/* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
current set of target sections. */
-extern void add_target_sections (struct target_section *sections,
+extern void add_target_sections (void *key,
+ struct target_section *sections,
struct target_section *sections_end);
/* Prints info about all sections defined in the TABLE. ABFD is
section tables. Do this immediately after mapping the object so
that later nodes in the list can query this object, as is needed
in solib-osf.c. */
- add_target_sections (so->sections, so->sections_end);
+ add_target_sections (so, so->sections, so->sections_end);
return 1;
}
/* Some targets' section tables might be referring to
sections from so->abfd; remove them. */
- remove_target_sections (gdb->abfd);
+ remove_target_sections (gdb, gdb->abfd);
free_so (gdb);
gdb = *gdb_link;
so_list_head = so->next;
observer_notify_solib_unloaded (so);
if (so->abfd)
- remove_target_sections (so->abfd);
+ remove_target_sections (so, so->abfd);
free_so (so);
}
if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
&& !solib_used (so))
free_objfile (so->objfile);
- remove_target_sections (so->abfd);
+ remove_target_sections (so, so->abfd);
free_so_symbols (so);
}
struct bfd_section *the_bfd_section;
+ /* A given BFD may appear multiple times in the target section
+ list, so each BFD is associated with a given key. The key is
+ just some convenient pointer that can be used to differentiate
+ the BFDs. These are managed only by convention. */
+ void *key;
+
bfd *bfd; /* BFD file pointer */
};