Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@cygnus.com>
To: gdb-patches@sources.redhat.com
Cc: ezannoni@redhat.com, jimb@redhat.com
Subject: [RFA] symfile.c -- use bfd access methods
Date: Fri, 11 Jan 2002 15:58:00 -0000	[thread overview]
Message-ID: <200201112353.g0BNrAl09266@reddwarf.cygnus.com> (raw)


Some more cleanups of symfile.c, using bfd access methods instead of
accessing private bfd data fields.  In several cases (those that 
would require touching more than one source file) I've just added
a FIXME comment and deferred doing the actual work.

2002-01-11  Michael Snyder  <msnyder@redhat.com>

	* symfile.c (build_section_addr_info_from_section_tab):
	Use bfd access method instead of manipulating bfd directly.
	(syms_from_objfile): Ditto.
	(simple_overlay_update_1): Ditto.
	(simple_overlay_update): Ditto.
	(generic_load): Ditto.
	(overlay_unmapped_address): FIXME comment, bfd access methods.
	(sections_overlap): FIXME comment, bfd access methods.
	(pc_in_mapped_range): FIXME comment, bfd access methods.
	(pc_in_unmapped_range): FIXME comment, bfd access methods.
	(section_is_mapped): FIXME comment, bfd access methods.
	(section_is_overlay): FIXME comment, bfd access methods.

Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.46
diff -c -3 -p -r1.46 symfile.c
*** symfile.c	2002/01/08 02:09:31	1.46
--- symfile.c	2002/01/11 23:54:31
*************** build_section_addr_info_from_section_tab
*** 452,462 ****
  
    for (stp = start, oidx = 0; stp != end; stp++)
      {
!       if (stp->the_bfd_section->flags & (SEC_ALLOC | SEC_LOAD)
  	  && oidx < MAX_SECTIONS)
  	{
  	  sap->other[oidx].addr = stp->addr;
! 	  sap->other[oidx].name = xstrdup (stp->the_bfd_section->name);
  	  sap->other[oidx].sectindex = stp->the_bfd_section->index;
  	  oidx++;
  	}
--- 452,464 ----
  
    for (stp = start, oidx = 0; stp != end; stp++)
      {
!       if (bfd_get_section_flags (stp->bfd, 
! 				 stp->the_bfd_section) & (SEC_ALLOC | SEC_LOAD)
  	  && oidx < MAX_SECTIONS)
  	{
  	  sap->other[oidx].addr = stp->addr;
! 	  sap->other[oidx].name 
! 	    = xstrdup (bfd_section_name (stp->bfd, stp->the_bfd_section));
  	  sap->other[oidx].sectindex = stp->the_bfd_section->index;
  	  oidx++;
  	}
*************** syms_from_objfile (struct objfile *objfi
*** 708,714 ****
   	    for (i = 0; 
  	         !s_addr && i < MAX_SECTIONS && addrs->other[i].name;
  		 i++)
!  	      if (strcmp (s->the_bfd_section->name, addrs->other[i].name) == 0)
   	        s_addr = addrs->other[i].addr; /* end added for gdb/13815 */
   
  	  s->addr -= s->offset;
--- 710,718 ----
   	    for (i = 0; 
  	         !s_addr && i < MAX_SECTIONS && addrs->other[i].name;
  		 i++)
!  	      if (strcmp (bfd_section_name (s->objfile->obfd, 
! 					    s->the_bfd_section), 
! 			  addrs->other[i].name) == 0)
   	        s_addr = addrs->other[i].addr; /* end added for gdb/13815 */
   
  	  s->addr -= s->offset;
*************** generic_load (char *args, int from_tty)
*** 1222,1228 ****
      }
  
    for (s = loadfile_bfd->sections; s; s = s->next)
!     if (s->flags & SEC_LOAD)
        total_size += bfd_get_section_size_before_reloc (s);
  
    start_time = time (NULL);
--- 1226,1232 ----
      }
  
    for (s = loadfile_bfd->sections; s; s = s->next)
!     if (bfd_get_section_flags (loadfile_bfd, s) & SEC_LOAD)
        total_size += bfd_get_section_size_before_reloc (s);
  
    start_time = time (NULL);
*************** void (*target_overlay_update) (struct ob
*** 2512,2517 ****
--- 2516,2523 ----
  int
  section_is_overlay (asection *section)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
+ 
    if (overlay_debugging)
      if (section && section->lma != 0 &&
  	section->vma != section->lma)
*************** section_is_mapped (asection *section)
*** 2598,2603 ****
--- 2604,2611 ----
  CORE_ADDR
  pc_in_unmapped_range (CORE_ADDR pc, asection *section)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
+ 
    int size;
  
    if (overlay_debugging)
*************** pc_in_unmapped_range (CORE_ADDR pc, asec
*** 2616,2621 ****
--- 2624,2631 ----
  CORE_ADDR
  pc_in_mapped_range (CORE_ADDR pc, asection *section)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
+ 
    int size;
  
    if (overlay_debugging)
*************** pc_in_mapped_range (CORE_ADDR pc, asecti
*** 2634,2639 ****
--- 2644,2651 ----
  int
  sections_overlap (asection *a, asection *b)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
+ 
    CORE_ADDR a_start = a->vma;
    CORE_ADDR a_end = a->vma + bfd_get_section_size_before_reloc (a);
    CORE_ADDR b_start = b->vma;
*************** sections_overlap (asection *a, asection 
*** 2649,2654 ****
--- 2661,2668 ----
  CORE_ADDR
  overlay_unmapped_address (CORE_ADDR pc, asection *section)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
+ 
    if (overlay_debugging)
      if (section && section_is_overlay (section) &&
  	pc_in_mapped_range (pc, section))
*************** overlay_unmapped_address (CORE_ADDR pc, 
*** 2664,2669 ****
--- 2678,2685 ----
  CORE_ADDR
  overlay_mapped_address (CORE_ADDR pc, asection *section)
  {
+   /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
+ 
    if (overlay_debugging)
      if (section && section_is_overlay (section) &&
  	pc_in_unmapped_range (pc, section))
*************** static int
*** 3102,3124 ****
  simple_overlay_update_1 (struct obj_section *osect)
  {
    int i, size;
  
    size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
    for (i = 0; i < cache_novlys; i++)
!     if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
! 	cache_ovly_table[i][LMA] == osect->the_bfd_section->lma		/* &&
! 									   cache_ovly_table[i][SIZE] == size */ )
        {
  	read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES,
  				(int *) cache_ovly_table[i], 4);
! 	if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
! 	    cache_ovly_table[i][LMA] == osect->the_bfd_section->lma	/* &&
! 									   cache_ovly_table[i][SIZE] == size */ )
  	  {
  	    osect->ovly_mapped = cache_ovly_table[i][MAPPED];
  	    return 1;
  	  }
! 	else			/* Warning!  Warning!  Target's ovly table has changed! */
  	  return 0;
        }
    return 0;
--- 3118,3142 ----
  simple_overlay_update_1 (struct obj_section *osect)
  {
    int i, size;
+   bfd *obfd = osect->objfile->obfd;
+   osection *bsect = osect->the_bfd_section;
  
    size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
    for (i = 0; i < cache_novlys; i++)
!     if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
! 	&& cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
! 	/* && cache_ovly_table[i][SIZE] == size */ )
        {
  	read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES,
  				(int *) cache_ovly_table[i], 4);
! 	if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
! 	    && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
! 	    /* && cache_ovly_table[i][SIZE] == size */ )
  	  {
  	    osect->ovly_mapped = cache_ovly_table[i][MAPPED];
  	    return 1;
  	  }
! 	else	/* Warning!  Warning!  Target's ovly table has changed! */
  	  return 0;
        }
    return 0;
*************** simple_overlay_update (struct obj_sectio
*** 3161,3173 ****
      if (section_is_overlay (osect->the_bfd_section))
      {
        int i, size;
  
        size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
        for (i = 0; i < cache_novlys; i++)
! 	if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
! 	    cache_ovly_table[i][LMA] == osect->the_bfd_section->lma	/* &&
! 									   cache_ovly_table[i][SIZE] == size */ )
! 	  {			/* obj_section matches i'th entry in ovly_table */
  	    osect->ovly_mapped = cache_ovly_table[i][MAPPED];
  	    break;		/* finished with inner for loop: break out */
  	  }
--- 3179,3193 ----
      if (section_is_overlay (osect->the_bfd_section))
      {
        int i, size;
+       bfd *obfd = osect->objfile->obfd;
+       osection *bsect = osect->the_bfd_section;
  
        size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
        for (i = 0; i < cache_novlys; i++)
! 	if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
! 	    && cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
! 	    /* && cache_ovly_table[i][SIZE] == size */ )
! 	  { /* obj_section matches i'th entry in ovly_table */
  	    osect->ovly_mapped = cache_ovly_table[i][MAPPED];
  	    break;		/* finished with inner for loop: break out */
  	  }


             reply	other threads:[~2002-01-11 23:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-11 15:58 Michael Snyder [this message]
2002-01-11 21:40 ` Elena Zannoni
2002-01-12 21:56   ` Michael Snyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200201112353.g0BNrAl09266@reddwarf.cygnus.com \
    --to=msnyder@cygnus.com \
    --cc=ezannoni@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox