aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-19 12:18:04 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-19 12:18:36 -0400
commit68b888fff3164b5e8e347d9c1ca351c366f0aac4 (patch)
tree407df662edc349c3ec33bf23379f33d3bce06cd4 /gdb/symfile.c
parent62982abdee45cb20a7cfadb2b1bcc358655d4ad3 (diff)
downloadgdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.zip
gdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.tar.gz
gdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.tar.bz2
gdb: use std::vector to store segments in symfile_segment_data
Instead of maintaining two vectors, I added a small `segment` class which holds both the base address and size of one segment and replaced the two `segment_bases` and `segment_sizes` arrays with a single vector. The rest of the changes are straightforward, no behavior changes are expected. gdb/ChangeLog: * symfile.h (struct symfile_segment_data) <struct segment>: New. <segments>: New. <segment_bases, segment_sizes>: Remove. * symfile.c (default_symfile_segments): Update. * elfread.c (elf_symfile_segments): Update. * remote.c (remote_target::get_offsets): Update. * solib-target.c (solib_target_relocate_section_addresses): Update.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 9d5e282..22793e7 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -745,9 +745,6 @@ default_symfile_segments (bfd *abfd)
high = low + bfd_section_size (sect);
symfile_segment_data_up data (new symfile_segment_data);
- data->num_segments = 1;
- data->segment_bases = XCNEW (CORE_ADDR);
- data->segment_sizes = XCNEW (CORE_ADDR);
num_sections = bfd_count_sections (abfd);
data->segment_info = XCNEWVEC (int, num_sections);
@@ -768,8 +765,7 @@ default_symfile_segments (bfd *abfd)
data->segment_info[i] = 1;
}
- data->segment_bases[0] = low;
- data->segment_sizes[0] = high - low;
+ data->segments.emplace_back (low, high - low);
return data;
}
@@ -3663,13 +3659,13 @@ symfile_map_offsets_to_segments (bfd *abfd,
/* If we do not have segment mappings for the object file, we
can not relocate it by segments. */
gdb_assert (data != NULL);
- gdb_assert (data->num_segments > 0);
+ gdb_assert (data->segments.size () > 0);
for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
{
int which = data->segment_info[i];
- gdb_assert (0 <= which && which <= data->num_segments);
+ gdb_assert (0 <= which && which <= data->segments.size ());
/* Don't bother computing offsets for sections that aren't
loaded as part of any segment. */
@@ -3681,7 +3677,7 @@ symfile_map_offsets_to_segments (bfd *abfd,
if (which > num_segment_bases)
which = num_segment_bases;
- offsets[i] = segment_bases[which - 1] - data->segment_bases[which - 1];
+ offsets[i] = segment_bases[which - 1] - data->segments[which - 1].base;
}
return 1;
@@ -3699,7 +3695,7 @@ symfile_find_segment_sections (struct objfile *objfile)
if (data == NULL)
return;
- if (data->num_segments != 1 && data->num_segments != 2)
+ if (data->segments.size () != 1 && data->segments.size () != 2)
return;
for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)