From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15680 invoked by alias); 24 Apr 2002 13:45:31 -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 15557 invoked from network); 24 Apr 2002 13:45:05 -0000 Received: from unknown (HELO mailhub.lss.emc.com) (168.159.1.79) by sources.redhat.com with SMTP; 24 Apr 2002 13:45:05 -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 g3ODj0Z03536 for ; Wed, 24 Apr 2002 09:45:00 -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 g3ODNaD22794 for ; Wed, 24 Apr 2002 09:23:36 -0400 (EDT) Message-ID: <3CC6B1E5.1080900@emc.com> Date: Wed, 24 Apr 2002 06:45: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 CC: gdb-patches@sources.redhat.com Subject: [RFA] should gdb require '.text' and '.data' sections? References: <02ea01c1e6eb$65f850c0$ad219fa8@lss.emc.com> <3CBEFC88.37807AEF@redhat.com> Content-Type: multipart/mixed; boundary="------------030506020903090107010609" X-SW-Source: 2002-04/txt/msg00933.txt.bz2 This is a multi-part message in MIME format. --------------030506020903090107010609 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1135 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. > This patch will set objfile->sect_index_code/data index to the first section that contains CODE/DATA flag when no section was named '.text'/'.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 via 'make headers'. gdb/ChangeLog: * symfile.c ( default_symfile_offsets): default index for '.text' and '.data' sections. --------------030506020903090107010609 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, --------------030506020903090107010609 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; --------------030506020903090107010609--