From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9344 invoked by alias); 22 Apr 2002 13:32:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9309 invoked from network); 22 Apr 2002 13:32:04 -0000 Received: from unknown (HELO mailhub.lss.emc.com) (168.159.1.79) by sources.redhat.com with SMTP; 22 Apr 2002 13:32:04 -0000 Received: from popimap.lss.emc.com (caduseus-ge.lss.emc.com [10.254.140.132]) by mailhub.lss.emc.com (Switch-2.2.0/Switch-2.2.0) with ESMTP id g3MDW0524997; Mon, 22 Apr 2002 09:32:01 -0400 (EDT) Received: from emc.com (lul1173.lss.emc.com [168.159.33.173]) by popimap.lss.emc.com (Switch-2.2.0/Switch-2.2.0) with ESMTP id g3MDVxD10238; Mon, 22 Apr 2002 09:32:00 -0400 (EDT) Message-ID: <3CC410E2.1070503@emc.com> Date: Mon, 22 Apr 2002 06:32:00 -0000 From: Josef Ezra User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: Michael Snyder CC: gdb-patches@sources.redhat.com Subject: Re: should gdb require '.text' and '.data' sections? References: <02ea01c1e6eb$65f850c0$ad219fa8@lss.emc.com> <3CBEFC88.37807AEF@redhat.com> Content-Type: multipart/mixed; boundary="------------090603090309000507080006" X-SW-Source: 2002-04/txt/msg00788.txt.bz2 This is a multi-part message in MIME format. --------------090603090309000507080006 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1120 Michael Snyder wrote: >josef ezra wrote: > >>Hello >> >>I'm trying to debug a symbol file that has no '.text' section. Unlike 5.0 >>version, the new SECT_OFF_TEXT(objfile) macro calls (no-return) internal >>error and prevent the read. >> >>Should gdb work that way (requiring '.text' and '.data' sections)? >> >>If not, can we consider the first sections flagged 'SEC_CODE'/'SEC_DATA' as >>substitutes? Or maybe better have a default 0/1 values (like 5.0)? Both >>should work in my case. >> > >I agree, gdb should not require .text and .data. For one thing, >a simple embedded assembler program might have no initialized data. >For another, those segments might be called something else. > Thanks Michael This patch will set the index of the first section that contains CODE/DATA flag as the default value of objfile->sect_index_code/data. - jezra bfd/ChangeLog: * section.c (bfd_get_first_code_section): new function. * section.c (bfd_get_first_data_section): new function. * bfd-in2.h: Regenerated. gdb/ChangeLog: * symfile.c ( default_symfile_offsets): default index for '.text' and '.data' sections. --------------090603090309000507080006 Content-Type: text/plain; name="sect_index_gdb.pat" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sect_index_gdb.pat" Content-length: 712 Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.58 diff -u -3 -r1.58 symfile.c --- gdb/symfile.c 29 Mar 2002 01:09:27 -0000 1.58 +++ gdb/symfile.c 22 Apr 2002 13:05:51 -0000 @@ -522,10 +522,14 @@ .rodata sections. */ sect = bfd_get_section_by_name (objfile->obfd, ".text"); + if (!sect) + sect = bfd_get_first_code_section (objfile->obfd); if (sect) objfile->sect_index_text = sect->index; sect = bfd_get_section_by_name (objfile->obfd, ".data"); + if (!sect) + sect = bfd_get_first_data_section (objfile->obfd) ; if (sect) objfile->sect_index_data = sect->index; --------------090603090309000507080006 Content-Type: text/plain; name="sect_index_bfd.pat" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sect_index_bfd.pat" Content-length: 1910 Index: bfd/section.c =================================================================== RCS file: /cvs/src/src/bfd/section.c,v retrieving revision 1.44 diff -u -3 -r1.44 section.c --- bfd/section.c 30 Jan 2002 18:12:16 -0000 1.44 +++ bfd/section.c 19 Apr 2002 21:19:44 -0000 @@ -772,6 +772,56 @@ /* FUNCTION + bfd_get_first_code_section + +SYNOPSIS + asection *bfd_get_first_code_section(bfd *abfd); + +DESCRIPTION + Run through @var{abfd} and return the first + <>s whose flagged SEC_CODE, <> + @xref{Sections} if none (just in case .. ) +*/ + +asection * +bfd_get_first_code_section (abfd) + bfd *abfd; +{ + asection *sect; + + for (sect = abfd->sections; sect != NULL; sect = sect->next) + if (sect->flags & SEC_CODE) + return sect; + return NULL; +} + +/* +FUNCTION + bfd_get_first_data_section + +SYNOPSIS + asection *bfd_get_first_data_section(bfd *abfd); + +DESCRIPTION + Run through @var{abfd} and return the first + <>s whose flagged SEC_DATA, <> + @xref{Sections} if none (just in case .. ) +*/ + +asection * +bfd_get_first_data_section (abfd) + bfd *abfd; +{ + asection *sect; + + for (sect = abfd->sections; sect != NULL; sect = sect->next) + if (sect->flags & SEC_DATA) + return sect; + return NULL; +} + +/* +FUNCTION bfd_get_unique_section_name SYNOPSIS Index: bfd/bfd-in2.h =================================================================== RCS file: /cvs/src/src/bfd/bfd-in2.h,v retrieving revision 1.149 diff -u -3 -r1.149 bfd-in2.h --- bfd/bfd-in2.h 4 Apr 2002 19:53:34 -0000 1.149 +++ bfd/bfd-in2.h 19 Apr 2002 21:19:45 -0000 @@ -1401,6 +1401,12 @@ asection * bfd_get_section_by_name PARAMS ((bfd *abfd, const char *name)); + +asection * +bfd_get_first_code_section PARAMS ((bfd *abfd)); + +asection * +bfd_get_first_data_section PARAMS ((bfd *abfd)); char * bfd_get_unique_section_name PARAMS ((bfd *abfd, --------------090603090309000507080006--