From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19347 invoked by alias); 17 Jan 2013 21:55:09 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 19317 invoked by uid 306); 17 Jan 2013 21:55:08 -0000 Date: Thu, 17 Jan 2013 21:55:00 -0000 Message-ID: <20130117215508.19301.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-tromey-remove-obj_section: fix a hard-coded section index in hppa-tdep.c X-Git-Refname: refs/heads/archer-tromey-remove-obj_section X-Git-Reftype: branch X-Git-Oldrev: a2182695d1c8cf4a1f9e09a2bf45054d929503e7 X-Git-Newrev: 8cf1c381f45305c9616de802b263cf6ceaa0012b X-SW-Source: 2013-q1/txt/msg00018.txt.bz2 List-Id: The branch, archer-tromey-remove-obj_section has been updated via 8cf1c381f45305c9616de802b263cf6ceaa0012b (commit) via 364e76a8d5e91ec83151b0c1d5cb4964eee780dc (commit) from a2182695d1c8cf4a1f9e09a2bf45054d929503e7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 8cf1c381f45305c9616de802b263cf6ceaa0012b Author: Tom Tromey Date: Thu Jan 17 14:54:45 2013 -0700 fix a hard-coded section index in hppa-tdep.c commit 364e76a8d5e91ec83151b0c1d5cb4964eee780dc Author: Tom Tromey Date: Thu Jan 17 14:14:10 2013 -0700 try harder to find a text section for SOM the gdb readline-ask test case makes a file with only an empty text section if we don't find this, gdb will crash ----------------------------------------------------------------------- Summary of changes: gdb/hppa-tdep.c | 4 ++-- gdb/somread.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 11 deletions(-) First 500 lines of diff: diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 5ee758e..22454df 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for the HP PA-RISC architecture. - Copyright (C) 1986-1987, 1989-1996, 1998-2005, 2007-2012 Free + Copyright (C) 1986-1987, 1989-1996, 1998-2005, 2007-2013 Free Software Foundation, Inc. Contributed by the Center for Software Science at the @@ -328,7 +328,7 @@ read_unwind_info (struct objfile *objfile) struct hppa_unwind_info *ui; struct hppa_objfile_private *obj_private; - text_offset = ANOFFSET (objfile->section_offsets, 0); + text_offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); ui = (struct hppa_unwind_info *) obstack_alloc (&objfile->objfile_obstack, sizeof (struct hppa_unwind_info)); diff --git a/gdb/somread.c b/gdb/somread.c index 28fc02b..c7add8a 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -392,23 +392,46 @@ som_symfile_init (struct objfile *objfile) objfile->flags |= OBJF_REORDERED; } +/* An object of this type is passed to set_text_section_offset. */ + +struct text_section_offset_arg +{ + /* The objfile. */ + + struct objfile *objfile; + + /* A text section with non-zero size, if any. */ + + asection *best_section; + + /* An empty text section, if any. */ + + asection *empty_section; +}; + /* A callback for bfd_map_over_sections that may set the objfile's text section offset. */ static void set_text_section_offset (bfd *abfd, asection *sect, void *arg) { - struct objfile *objfile = arg; + struct text_section_offset_arg *info = arg; flagword aflag; - if (objfile->sect_index_text >= 0) - return; - aflag = bfd_get_section_flags (abfd, sect); - if ((aflag & SEC_ALLOC) != 0 - && (aflag & SEC_CODE) != 0 - && bfd_section_size (abfd, sect) > 0) - objfile->sect_index_text = sect->index; + if ((aflag & SEC_ALLOC) != 0 && (aflag & SEC_CODE) != 0) + { + if (bfd_section_size (abfd, sect) > 0) + { + if (info->best_section == NULL) + info->best_section = sect; + } + else + { + if (info->empty_section == NULL) + info->empty_section = sect; + } + } } /* SOM specific parsing routine for section offsets. @@ -421,13 +444,23 @@ 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)); - bfd_map_over_sections (objfile->obfd, set_text_section_offset, objfile); + 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; hooks/post-receive -- Repository for Project Archer.