From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11893 invoked by alias); 22 Jan 2013 16:44:28 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 11679 invoked by uid 306); 22 Jan 2013 16:44:25 -0000 Date: Tue, 22 Jan 2013 16:44:00 -0000 Message-ID: <20130122164424.11609.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-remove-obj_section: extend section-searching to cover data and bss sections as well X-Git-Refname: refs/heads/archer-tromey-remove-obj_section X-Git-Reftype: branch X-Git-Oldrev: 36b2db08d02bd45935a021c3f1446da432b7b94b X-Git-Newrev: db6a28f95f3c29c838e2454d7e03f61b837649a7 X-SW-Source: 2013-q1/txt/msg00025.txt.bz2 List-Id: The branch, archer-tromey-remove-obj_section has been updated via db6a28f95f3c29c838e2454d7e03f61b837649a7 (commit) from 36b2db08d02bd45935a021c3f1446da432b7b94b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit db6a28f95f3c29c838e2454d7e03f61b837649a7 Author: Tom Tromey Date: Tue Jan 22 09:43:47 2013 -0700 extend section-searching to cover data and bss sections as well the test suite tripped across a .sl without a $DATA$ section ----------------------------------------------------------------------- Summary of changes: gdb/solib-som.c | 10 +++++-- gdb/somread.c | 71 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 27 deletions(-) First 500 lines of diff: diff --git a/gdb/solib-som.c b/gdb/solib-som.c index 6c64f64..2678a22 100644 --- a/gdb/solib-som.c +++ b/gdb/solib-som.c @@ -869,11 +869,15 @@ som_solib_section_offsets (struct objfile *objfile, ALL_OBJFILE_OSECTIONS (objfile, sect) { - if (sect->the_bfd_section->index != objfile->sect_index_text - && sect->the_bfd_section->index != objfile->sect_index_bss - && sect->the_bfd_section->index != objfile->sect_index_data) + flagword flags = bfd_get_section_flags (objfile->obfd, + sect->the_bfd_section); + + if ((flags & SEC_CODE) != 0) offsets->offsets[sect->the_bfd_section->index] = offsets->offsets[SECT_OFF_TEXT (objfile)]; + else + offsets->offsets[sect->the_bfd_section->index] + = offsets->offsets[SECT_OFF_DATA (objfile)]; } return 1; diff --git a/gdb/somread.c b/gdb/somread.c index 967a9f7..4dfecbb 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -391,14 +391,22 @@ som_symfile_init (struct objfile *objfile) objfile->flags |= OBJF_REORDERED; } -/* An object of this type is passed to set_text_section_offset. */ +/* An object of this type is passed to find_section_offset. */ -struct text_section_offset_arg +struct find_section_offset_arg { /* The objfile. */ struct objfile *objfile; + /* Flags to invert. */ + + flagword invert; + + /* Flags to look for. */ + + flagword flags; + /* A text section with non-zero size, if any. */ asection *best_section; @@ -408,17 +416,20 @@ struct text_section_offset_arg asection *empty_section; }; -/* A callback for bfd_map_over_sections that may set the objfile's - text section offset. */ +/* A callback for bfd_map_over_sections that tries to find a section + with particular flags in an objfile. */ static void -set_text_section_offset (bfd *abfd, asection *sect, void *arg) +find_section_offset (bfd *abfd, asection *sect, void *arg) { - struct text_section_offset_arg *info = arg; + struct find_section_offset_arg *info = arg; flagword aflag; aflag = bfd_get_section_flags (abfd, sect); - if ((aflag & SEC_ALLOC) != 0 && (aflag & SEC_CODE) != 0) + + aflag ^= info->invert; + + if ((aflag & info->flags) == info->flags) { if (bfd_section_size (abfd, sect) > 0) { @@ -433,6 +444,27 @@ set_text_section_offset (bfd *abfd, asection *sect, void *arg) } } +/* Set a section index from a BFD. */ + +static void +set_section_index (struct objfile *objfile, flagword invert, flagword flags, + int *index_ptr) +{ + struct find_section_offset_arg info; + + info.objfile = objfile; + info.best_section = NULL; + info.empty_section = NULL; + info.invert = invert; + info.flags = flags; + bfd_map_over_sections (objfile->obfd, find_section_offset, &info); + + if (info.best_section) + *index_ptr = info.best_section->index; + else if (info.empty_section) + *index_ptr = info.empty_section->index; +} + /* SOM specific parsing routine for section offsets. Plain and simple for now. */ @@ -443,29 +475,20 @@ som_symfile_offsets (struct objfile *objfile, struct section_addr_info *addrs) int i; CORE_ADDR text_addr; asection *sect; - struct text_section_offset_arg info; objfile->num_sections = bfd_count_sections (objfile->obfd); objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->objfile_obstack, SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)); - info.objfile = objfile; - info.best_section = NULL; - info.empty_section = NULL; - bfd_map_over_sections (objfile->obfd, set_text_section_offset, &info); - - if (info.best_section) - objfile->sect_index_text = info.best_section->index; - else if (info.empty_section) - objfile->sect_index_text = info.empty_section->index; - - sect = bfd_get_section_by_name (objfile->obfd, "$DATA$"); - if (sect != NULL) - objfile->sect_index_data = sect->index; - sect = bfd_get_section_by_name (objfile->obfd, "$BSS$"); - if (sect != NULL) - objfile->sect_index_bss = sect->index; + set_section_index (objfile, 0, SEC_ALLOC | SEC_CODE, + &objfile->sect_index_text); + set_section_index (objfile, 0, SEC_ALLOC | SEC_DATA, + &objfile->sect_index_data); + set_section_index (objfile, SEC_LOAD, SEC_ALLOC | SEC_DATA | SEC_LOAD, + &objfile->sect_index_bss); + set_section_index (objfile, 0, SEC_ALLOC | SEC_READONLY, + &objfile->sect_index_rodata); /* First see if we're a shared library. If so, get the section offsets from the library, else get them from addrs. */ hooks/post-receive -- Repository for Project Archer.