diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-29 15:04:33 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-10-29 15:04:33 -0600 |
commit | 6be2a9ab1fba5f876c8cb2566280c5e4e6959d6e (patch) | |
tree | b56cebc7b136717accecbf580534524078a6e91c | |
parent | 8ee54925b48985e8e7102221e698bf50b800dd81 (diff) | |
download | binutils-6be2a9ab1fba5f876c8cb2566280c5e4e6959d6e.zip binutils-6be2a9ab1fba5f876c8cb2566280c5e4e6959d6e.tar.gz binutils-6be2a9ab1fba5f876c8cb2566280c5e4e6959d6e.tar.bz2 |
Add target_section constructor
This adds a constructor to target_section, simplifying the code that
creates instances of this.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* target-section.h (struct target_section): Add constructor.
* exec.c (build_section_table, add_target_sections_of_objfile):
Update.
* corelow.c (core_target::build_file_mappings): Update.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/corelow.c | 7 | ||||
-rw-r--r-- | gdb/exec.c | 18 | ||||
-rw-r--r-- | gdb/target-section.h | 9 |
4 files changed, 23 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3cef009..e282ea7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-10-29 Tom Tromey <tom@tromey.com> + + * target-section.h (struct target_section): Add constructor. + * exec.c (build_section_table, add_target_sections_of_objfile): + Update. + * corelow.c (core_target::build_file_mappings): Update. + 2020-10-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> PR gdb/19318 diff --git a/gdb/corelow.c b/gdb/corelow.c index a54d815..4f3c880 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -266,12 +266,7 @@ core_target::build_file_mappings () bfd_set_section_alignment (sec, 2); /* Set target_section fields. */ - m_core_file_mappings.emplace_back (); - target_section &ts = m_core_file_mappings.back (); - ts.addr = start; - ts.endaddr = end; - ts.owner = nullptr; - ts.the_bfd_section = sec; + m_core_file_mappings.emplace_back (start, end, sec); }); normalize_mem_ranges (&m_core_unavailable_mappings); @@ -598,12 +598,9 @@ build_section_table (struct bfd *some_bfd) if (!(aflag & SEC_ALLOC)) continue; - table.emplace_back (); - target_section § = table.back (); - sect.owner = NULL; - sect.the_bfd_section = asect; - sect.addr = bfd_section_vma (asect); - sect.endaddr = sect.addr + bfd_section_size (asect); + table.emplace_back (bfd_section_vma (asect), + bfd_section_vma (asect) + bfd_section_size (asect), + asect); } return table; @@ -662,12 +659,9 @@ add_target_sections_of_objfile (struct objfile *objfile) if (bfd_section_size (osect->the_bfd_section) == 0) continue; - table->emplace_back (); - target_section &ts = table->back (); - ts.addr = obj_section_addr (osect); - ts.endaddr = obj_section_endaddr (osect); - ts.the_bfd_section = osect->the_bfd_section; - ts.owner = (void *) objfile; + table->emplace_back (obj_section_addr (osect), + obj_section_endaddr (osect), + osect->the_bfd_section, (void *) objfile); } } diff --git a/gdb/target-section.h b/gdb/target-section.h index ec6932d..b19bcf9 100644 --- a/gdb/target-section.h +++ b/gdb/target-section.h @@ -26,6 +26,15 @@ struct target_section { + target_section (CORE_ADDR addr_, CORE_ADDR end_, struct bfd_section *sect_, + void *owner_ = nullptr) + : addr (addr_), + endaddr (end_), + the_bfd_section (sect_), + owner (owner_) + { + } + /* Lowest address in section. */ CORE_ADDR addr; /* Highest address in section, plus 1. */ |