public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Fixup references to bfd_section_list... macros
@ 2005-05-03 12:11 Nick Clifton
  2005-05-03 12:49 ` Alan Modra
  2005-05-03 14:04 ` H. J. Lu
  0 siblings, 2 replies; 5+ messages in thread
From: Nick Clifton @ 2005-05-03 12:11 UTC (permalink / raw)
  To: binutils

Hi Guys,

  H.J.'s recent patch to update the bfd_section_list manipulation
  macros fixed a few small cases in the gas directory.  So I am going
  to apply the patch below to fix them.

Cheers
  Nick

gas/ChangeLog
2005-05-03  Nick Clifton  <nickc@redhat.com>

	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Fix invocations
	of bfd_section_list... macros.
	* config/tc-mmix.c (mmix_frob_file): Likewise.
	* config/tc-xtensa.c (xtensa_remove_section): Likewise.
	(xtensa_insert_section): Likewise.

Index: gas/config/obj-ecoff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-ecoff.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 obj-ecoff.c
*** gas/config/obj-ecoff.c	24 Mar 2005 20:40:25 -0000	1.13
--- gas/config/obj-ecoff.c	3 May 2005 11:55:43 -0000
*************** ecoff_frob_file_before_fix (void)
*** 78,84 ****
  
    addr = 0;
    for (i = 0; i < n_names; i++)
!     secs[i] = 0;
  
    for (sec = &stdoutput->sections; *sec !=  NULL;)
      {
--- 78,84 ----
  
    addr = 0;
    for (i = 0; i < n_names; i++)
!     secs[i] = NULL;
  
    for (sec = &stdoutput->sections; *sec !=  NULL;)
      {
*************** ecoff_frob_file_before_fix (void)
*** 86,92 ****
  	if (!strcmp ((*sec)->name, names[i]))
  	  {
  	    secs[i] = *sec;
! 	    bfd_section_list_remove (stdoutput, sec);
  	    break;
  	  }
        if (i == n_names)
--- 86,92 ----
  	if (!strcmp ((*sec)->name, names[i]))
  	  {
  	    secs[i] = *sec;
! 	    bfd_section_list_remove (stdoutput, *sec);
  	    break;
  	  }
        if (i == n_names)
*************** ecoff_frob_file_before_fix (void)
*** 104,110 ****
        }
    for (i = n_names - 1; i >= 0; i--)
      if (secs[i])
!       bfd_section_list_insert (stdoutput, &stdoutput->sections, secs[i]);
  
    /* Fill in the register masks.  */
    {
--- 104,110 ----
        }
    for (i = n_names - 1; i >= 0; i--)
      if (secs[i])
!       bfd_section_list_insert_after (stdoutput, stdoutput->sections, secs[i]);
  
    /* Fill in the register masks.  */
    {
Index: gas/config/tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 tc-mmix.c
*** gas/config/tc-mmix.c	20 Apr 2005 17:40:01 -0000	1.20
--- gas/config/tc-mmix.c	3 May 2005 11:55:44 -0000
*************** mmix_frob_file (void)
*** 3747,3764 ****
  
    if (real_reg_section != NULL)
      {
!       asection **secpp;
  
        /* FIXME: Pass error state gracefully.  */
        if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
  	as_fatal (_("register section has contents\n"));
  
        /* Really remove the section.  */
!       for (secpp = &stdoutput->sections;
! 	   *secpp != real_reg_section;
! 	   secpp = &(*secpp)->next)
  	;
!       bfd_section_list_remove (stdoutput, secpp);
        --stdoutput->section_count;
      }
  
--- 3747,3764 ----
  
    if (real_reg_section != NULL)
      {
!       asection *secp;
  
        /* FIXME: Pass error state gracefully.  */
        if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
  	as_fatal (_("register section has contents\n"));
  
        /* Really remove the section.  */
!       for (secp = stdoutput->sections;
! 	   secp != real_reg_section;
! 	   secp = secp->next)
  	;
!       bfd_section_list_remove (stdoutput, secp);
        --stdoutput->section_count;
      }
  
Index: gas/config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.36
diff -c -3 -p -r1.36 tc-xtensa.c
*** gas/config/tc-xtensa.c	22 Apr 2005 21:37:31 -0000	1.36
--- gas/config/tc-xtensa.c	3 May 2005 11:55:48 -0000
*************** xtensa_remove_section (segT sec)
*** 9690,9701 ****
    /* Handle brain-dead bfd_section_list_remove macro, which
       expect the address of the prior section's "next" field, not
       just the address of the section to remove.  */
  
!   segT *ps_next_ptr = &stdoutput->sections;
!   while (*ps_next_ptr != sec && *ps_next_ptr != NULL) 
!     ps_next_ptr = &(*ps_next_ptr)->next;
    
!   assert (*ps_next_ptr != NULL);
  
    bfd_section_list_remove (stdoutput, ps_next_ptr);
  }
--- 9690,9701 ----
    /* Handle brain-dead bfd_section_list_remove macro, which
       expect the address of the prior section's "next" field, not
       just the address of the section to remove.  */
+   segT ps_next_ptr = stdoutput->sections;
  
!   while (ps_next_ptr != sec && ps_next_ptr != NULL) 
!     ps_next_ptr = ps_next_ptr->next;
    
!   assert (ps_next_ptr != NULL);
  
    bfd_section_list_remove (stdoutput, ps_next_ptr);
  }
*************** xtensa_remove_section (segT sec)
*** 9704,9716 ****
  static void
  xtensa_insert_section (segT after_sec, segT sec)
  {
!   segT *after_sec_next;
    if (after_sec == NULL)
!     after_sec_next = &stdoutput->sections;
    else
!     after_sec_next = &after_sec->next;
  
!   bfd_section_list_insert (stdoutput, after_sec_next, sec);
  }
  
  
--- 9704,9717 ----
  static void
  xtensa_insert_section (segT after_sec, segT sec)
  {
!   segT after_sec_next;
! 
    if (after_sec == NULL)
!     after_sec_next = stdoutput->sections;
    else
!     after_sec_next = after_sec->next;
  
!   bfd_section_list_insert_after (stdoutput, after_sec_next, sec);
  }
  
  
  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fixup references to bfd_section_list... macros
  2005-05-03 12:11 Fixup references to bfd_section_list... macros Nick Clifton
@ 2005-05-03 12:49 ` Alan Modra
  2005-05-03 13:25   ` Nick Clifton
  2005-05-03 17:07   ` Alan Modra
  2005-05-03 14:04 ` H. J. Lu
  1 sibling, 2 replies; 5+ messages in thread
From: Alan Modra @ 2005-05-03 12:49 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Tue, May 03, 2005 at 01:01:38PM +0100, Nick Clifton wrote:
> Hi Guys,
> 
>   H.J.'s recent patch to update the bfd_section_list manipulation
>   macros fixed a few small cases in the gas directory.  So I am going
>   to apply the patch below to fix them.

They aren't the only breakage.  Grrr.

> 	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Fix invocations
> 	of bfd_section_list... macros.

Um, this is still broken.  sec->next is trashed by HJ's
bfd_section_list_remove.

> 	* config/tc-mmix.c (mmix_frob_file): Likewise.

And this isn't ideal.  No need to traverse the list.

> 	* config/tc-xtensa.c (xtensa_remove_section): Likewise.

Same here.

> 	(xtensa_insert_section): Likewise.

And this is still broken.  You aren't having a good day.  :)

I was in the middle of testing fixes for all these, plus some others in
bfd/.  Expect a commit sometime soon after I rerun the tests.  (My first
bash at fixing them wasn't too hot either..)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fixup references to bfd_section_list... macros
  2005-05-03 12:49 ` Alan Modra
@ 2005-05-03 13:25   ` Nick Clifton
  2005-05-03 17:07   ` Alan Modra
  1 sibling, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2005-05-03 13:25 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Hi Alan,

>>	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Fix invocations
>>	of bfd_section_list... macros.
> 
> 
> Um, this is still broken.  sec->next is trashed by HJ's
> bfd_section_list_remove.
> 
> 
>>	* config/tc-mmix.c (mmix_frob_file): Likewise.
> 
> 
> And this isn't ideal.  No need to traverse the list.
> 
> 
>>	* config/tc-xtensa.c (xtensa_remove_section): Likewise.
> 
> 
> Same here.
> 
> 
>>	(xtensa_insert_section): Likewise.
> 
> 
> And this is still broken.  You aren't having a good day.  :)
> 
> I was in the middle of testing fixes for all these, plus some others in
> bfd/.  Expect a commit sometime soon after I rerun the tests.  (My first
> bash at fixing them wasn't too hot either..)

Bows head in shame. :-(  OK - I will leave a proper fix to you.  Sorry Alan.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fixup references to bfd_section_list... macros
  2005-05-03 12:11 Fixup references to bfd_section_list... macros Nick Clifton
  2005-05-03 12:49 ` Alan Modra
@ 2005-05-03 14:04 ` H. J. Lu
  1 sibling, 0 replies; 5+ messages in thread
From: H. J. Lu @ 2005-05-03 14:04 UTC (permalink / raw)
  To: Nick Clifton, bob.wilson; +Cc: binutils

On Tue, May 03, 2005 at 01:01:38PM +0100, Nick Clifton wrote:
> Hi Guys,
> 
>   H.J.'s recent patch to update the bfd_section_list manipulation
>   macros fixed a few small cases in the gas directory.  So I am going
>   to apply the patch below to fix them.
> 
> Cheers
>   Nick
> 
> gas/ChangeLog
> 2005-05-03  Nick Clifton  <nickc@redhat.com>
> 
> 	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Fix invocations
> 	of bfd_section_list... macros.
> 	* config/tc-mmix.c (mmix_frob_file): Likewise.
> 	* config/tc-xtensa.c (xtensa_remove_section): Likewise.
> 	(xtensa_insert_section): Likewise.
> 

There is no need now to scan the section list when removing a section
and bfd_section_list_remove no longer updates the section pointer to be
removed.

Also xtensa_remove_section and xtensa_insert_section are used to work
around the problem with the singly linked list. Bob, I think it is
easier to use bfd_section_list_remove, bfd_section_list_insert_append
and bfd_section_list_insert_after directly. bfd_section_list_remove is
no longer brain-dead now :-).

This is an untested patch. Please take a look.


H.J.
----
2005-05-03  H.J. Lu  <hongjiu.lu@intel.com>

	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Updated for
	bfd_section_list... changes.
	* config/tc-mmix.c (mmix_frob_file): Likewise.
	* config/tc-xtensa.c (xtensa_remove_section): Removed.
	(xtensa_insert_section): Likewise.
	(xtensa_move_seg_list_to_beginning): Use bfd_section_list...
	directly.
	(xtensa_reorder_seg_list): Likewise.

--- gas/config/obj-ecoff.c.dbl	2005-03-26 09:11:48.000000000 -0800
+++ gas/config/obj-ecoff.c	2005-05-03 06:42:43.000000000 -0700
@@ -37,7 +37,7 @@ void
 ecoff_frob_file_before_fix (void)
 {
   bfd_vma addr;
-  asection **sec;
+  asection *sec, *n;
 
   /* Set the section VMA values.  We force the .sdata and .sbss
      sections to the end to ensure that their VMA addresses are close
@@ -80,20 +80,20 @@ ecoff_frob_file_before_fix (void)
   for (i = 0; i < n_names; i++)
     secs[i] = 0;
 
-  for (sec = &stdoutput->sections; *sec !=  NULL;)
+  for (sec = stdoutput->sections; sec != NULL; sec = n)
     {
+      next = sec->n;
       for (i = 0; i < n_names; i++)
-	if (!strcmp ((*sec)->name, names[i]))
+	if (!strcmp (sec->name, names[i]))
 	  {
-	    secs[i] = *sec;
+	    secs[i] = sec;
 	    bfd_section_list_remove (stdoutput, sec);
 	    break;
 	  }
       if (i == n_names)
 	{
-	  bfd_set_section_vma (stdoutput, *sec, addr);
-	  addr += bfd_section_size (stdoutput, *sec);
-	  sec = &(*sec)->next;
+	  bfd_set_section_vma (stdoutput, sec, addr);
+	  addr += bfd_section_size (stdoutput, sec);
 	}
     }
   for (i = 0; i < n_names; i++)
@@ -104,7 +104,8 @@ ecoff_frob_file_before_fix (void)
       }
   for (i = n_names - 1; i >= 0; i--)
     if (secs[i])
-      bfd_section_list_insert (stdoutput, &stdoutput->sections, secs[i]);
+      bfd_section_list_insert_before (stdoutput, stdoutput->sections,
+				      secs[i]);
 
   /* Fill in the register masks.  */
   {
--- gas/config/tc-mmix.c.dbl	2005-04-20 11:10:10.000000000 -0700
+++ gas/config/tc-mmix.c	2005-05-03 06:43:11.000000000 -0700
@@ -3747,18 +3747,11 @@ mmix_frob_file (void)
 
   if (real_reg_section != NULL)
     {
-      asection **secpp;
-
       /* FIXME: Pass error state gracefully.  */
       if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
 	as_fatal (_("register section has contents\n"));
 
-      /* Really remove the section.  */
-      for (secpp = &stdoutput->sections;
-	   *secpp != real_reg_section;
-	   secpp = &(*secpp)->next)
-	;
-      bfd_section_list_remove (stdoutput, secpp);
+      bfd_section_list_remove (stdoutput, real_reg_section);
       --stdoutput->section_count;
     }
 
--- gas/config/tc-xtensa.c.dbl	2005-04-25 08:46:23.000000000 -0700
+++ gas/config/tc-xtensa.c	2005-05-03 06:58:06.000000000 -0700
@@ -9682,38 +9682,6 @@ set_subseg_freq (segT seg, subsegT subse
 \f
 /* Segment Lists and emit_state Stuff.  */
 
-/* Remove the segment from the global sections list.  */
-
-static void
-xtensa_remove_section (segT sec)
-{
-  /* Handle brain-dead bfd_section_list_remove macro, which
-     expect the address of the prior section's "next" field, not
-     just the address of the section to remove.  */
-
-  segT *ps_next_ptr = &stdoutput->sections;
-  while (*ps_next_ptr != sec && *ps_next_ptr != NULL) 
-    ps_next_ptr = &(*ps_next_ptr)->next;
-  
-  assert (*ps_next_ptr != NULL);
-
-  bfd_section_list_remove (stdoutput, ps_next_ptr);
-}
-
-
-static void
-xtensa_insert_section (segT after_sec, segT sec)
-{
-  segT *after_sec_next;
-  if (after_sec == NULL)
-    after_sec_next = &stdoutput->sections;
-  else
-    after_sec_next = &after_sec->next;
-
-  bfd_section_list_insert (stdoutput, after_sec_next, sec);
-}
-
-
 static void
 xtensa_move_seg_list_to_beginning (seg_list *head)
 {
@@ -9724,8 +9692,9 @@ xtensa_move_seg_list_to_beginning (seg_l
 
       /* Move the literal section to the front of the section list.  */
       assert (literal_section);
-      xtensa_remove_section (literal_section);
-      xtensa_insert_section (NULL, literal_section);
+      bfd_section_list_remove (stdoutput, literal_section);
+      bfd_section_list_insert_before (stdoutput, stdoutput->sections,
+				      literal_section);
 
       head = head->next;
     }
@@ -9892,8 +9861,9 @@ xtensa_reorder_seg_list (seg_list *head,
       assert (literal_section);
       if (literal_section != after)
 	{
-	  xtensa_remove_section (literal_section);
-	  xtensa_insert_section (after, literal_section);
+	  bfd_section_list_remove (stdoutput, literal_section);
+	  bfd_section_list_insert_after (stdoutput, after,
+					 literal_section);
 	}
 
       head = head->next;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fixup references to bfd_section_list... macros
  2005-05-03 12:49 ` Alan Modra
  2005-05-03 13:25   ` Nick Clifton
@ 2005-05-03 17:07   ` Alan Modra
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Modra @ 2005-05-03 17:07 UTC (permalink / raw)
  To: Nick Clifton, binutils

This fixes all the problems I found.  Not clearing s->next in
bfd_section_list_remove makes list traversal nicer, and fixes a bug
introduced to _bfd_mips_elf_final_link and _bfd_xcoff_bfd_final_link.

bfd_section_list_prepend is needed because calling
  bfd_section_list_insert_before (abfd, abfd->sections, s)
doesn't work when abfd->sections is NULL, which may well happen in
obj-ecoff.c.

bfd/
	* section.c (bfd_section_list_remove): Don't clear s->next.
	(bfd_section_list_append): Always init s->prev.
	(bfd_section_list_prepend): Define.
	(bfd_section_list_insert_after): Minor optimization.
	(bfd_section_removed_from_list): Rewrite.
	* elf.c (assign_section_numbers): Simplify list traversal now that
	bfd_section_list_remove doesn't destroy removed section next ptr.
	* sunos.c (sunos_add_dynamic_symbols): Likewise.
	* elfxx-ia64.c (elfNN_ia64_object_p): Use bfd_section_list_prepend.
	* xcofflink.c (_bfd_xcoff_bfd_final_link): Simplify list traversal.
	* bfd-in2.h: Regenerate.

gas/
	* config/obj-ecoff.c (ecoff_frob_file_before_fix): Correct section
	list traversal.  Use bfd_section_list_prepend.
	* config/tc-mmix.c (mmix_frob_file): Don't needlessly iterate
	over the section list.
	* config/tc-xtensa.c (xtensa_remove_section): Delete.
	(xtensa_insert_section): Delete.
	(xtensa_move_seg_list_to_beginning): Use bfd_section_list_remove
	and bfd_section_list_prepend.
	(xtensa_reorder_seg_list): Use bfd_section_list_remove and
	bfd_section_list_insert_after.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.283
diff -u -p -r1.283 elf.c
--- bfd/elf.c	3 May 2005 01:05:00 -0000	1.283
+++ bfd/elf.c	3 May 2005 15:25:16 -0000
@@ -2762,14 +2762,11 @@ assign_section_numbers (bfd *abfd, struc
   /* SHT_GROUP sections are in relocatable files only.  */
   if (link_info == NULL || link_info->relocatable)
     {
-      asection *n;
-
       /* Put SHT_GROUP sections first.  */
-      for (sec = abfd->sections; sec; sec = n)
+      for (sec = abfd->sections; sec != NULL; sec = sec->next)
 	{
 	  d = elf_section_data (sec);
 
-	  n = sec->next;
 	  if (d->this_hdr.sh_type == SHT_GROUP)
 	    { 
 	      if (sec->flags & SEC_LINKER_CREATED)
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.154
diff -u -p -r1.154 elfxx-ia64.c
--- bfd/elfxx-ia64.c	3 May 2005 01:05:01 -0000	1.154
+++ bfd/elfxx-ia64.c	3 May 2005 15:26:03 -0000
@@ -4934,7 +4934,7 @@ elfNN_ia64_object_p (bfd *abfd)
 
 	  /* Move the fake group section to the beginning.  */
 	  bfd_section_list_remove (abfd, group);
-	  bfd_section_list_insert_before (abfd, abfd->sections, group);
+	  bfd_section_list_prepend (abfd, group);
 
 	  elf_next_in_group (group) = sec;
 
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.82
diff -u -p -r1.82 section.c
--- bfd/section.c	3 May 2005 01:05:02 -0000	1.82
+++ bfd/section.c	3 May 2005 15:26:16 -0000
@@ -552,10 +552,7 @@ CODE_FRAGMENT
 .      else						\
 .        (ABFD)->sections = _next;			\
 .      if (_next)					\
-.        {						\
-.          _next->prev = _prev;				\
-.          _s->next = NULL;				\
-.        }						\
+.        _next->prev = _prev;				\
 .      else						\
 .        (ABFD)->section_last = _prev;			\
 .    }							\
@@ -572,10 +569,32 @@ CODE_FRAGMENT
 .          _abfd->section_last->next = _s;		\
 .        }						\
 .      else						\
-.        _abfd->sections = _s;				\
+.        {						\
+.          _s->prev = NULL;				\
+.          _abfd->sections = _s;			\
+.        }						\
 .      _abfd->section_last = _s;			\
 .    }							\
 .  while (0)
+.#define bfd_section_list_prepend(ABFD, S) \
+.  do							\
+.    {							\
+.      asection *_s = S;				\
+.      bfd *_abfd = ABFD;				\
+.      _s->prev = NULL;					\
+.      if (_abfd->sections)				\
+.        {						\
+.          _s->next = _abfd->sections;			\
+.          _abfd->sections->prev = _s;			\
+.        }						\
+.      else						\
+.        {						\
+.          _s->next = NULL;				\
+.          _abfd->section_last = _s;			\
+.        }						\
+.      _abfd->sections = _s;				\
+.    }							\
+.  while (0)
 .#define bfd_section_list_insert_after(ABFD, A, S) \
 .  do							\
 .    {							\
@@ -586,7 +605,7 @@ CODE_FRAGMENT
 .      _s->prev = _a;					\
 .      _a->next = _s;					\
 .      if (_next)					\
-.        _s->next->prev = _s;				\
+.        _next->prev = _s;				\
 .      else						\
 .        (ABFD)->section_last = _s;			\
 .    }							\
@@ -607,7 +626,7 @@ CODE_FRAGMENT
 .    }							\
 .  while (0)
 .#define bfd_section_removed_from_list(ABFD, S) \
-.  ((S)->next == NULL && (S) != (ABFD)->section_last)
+.  ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
 .
 */
 
Index: bfd/sunos.c
===================================================================
RCS file: /cvs/src/src/bfd/sunos.c,v
retrieving revision 1.18
diff -u -p -r1.18 sunos.c
--- bfd/sunos.c	3 May 2005 01:05:03 -0000	1.18
+++ bfd/sunos.c	3 May 2005 15:26:18 -0000
@@ -859,11 +859,10 @@ sunos_add_dynamic_symbols (bfd *abfd,
     abfd->sections = NULL;
   else
     {
-      asection *s, *n;
+      asection *s;
 
-      for (s = abfd->sections; s != NULL; s = n)
+      for (s = abfd->sections; s != NULL; s = s->next)
 	{
-	  n = s->next;
 	  if ((s->flags & SEC_LINKER_CREATED) == 0)
 	    bfd_section_list_remove (abfd, s);
 	}
Index: bfd/xcofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/xcofflink.c,v
retrieving revision 1.39
diff -u -p -r1.39 xcofflink.c
--- bfd/xcofflink.c	3 May 2005 01:05:03 -0000	1.39
+++ bfd/xcofflink.c	3 May 2005 15:26:21 -0000
@@ -5436,19 +5436,18 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, st
 	{
 	  bfd_boolean saw_contents;
 	  int indx;
-	  asection **op;
 	  file_ptr sofar;
 
 	  /* Insert .pad sections before every section which has
 	     contents and is loaded, if it is preceded by some other
 	     section which has contents and is loaded.  */
 	  saw_contents = TRUE;
-	  for (op = &abfd->sections; *op != NULL; op = &(*op)->next)
+	  for (o = abfd->sections; o != NULL; o = o->next)
 	    {
-	      if (strcmp ((*op)->name, ".pad") == 0)
+	      if (strcmp (o->name, ".pad") == 0)
 		saw_contents = FALSE;
-	      else if (((*op)->flags & SEC_HAS_CONTENTS) != 0
-		       && ((*op)->flags & SEC_LOAD) != 0)
+	      else if ((o->flags & SEC_HAS_CONTENTS) != 0
+		       && (o->flags & SEC_LOAD) != 0)
 		{
 		  if (! saw_contents)
 		    saw_contents = TRUE;
@@ -5465,9 +5464,7 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, st
 		      n->alignment_power = 0;
 
 		      bfd_section_list_remove (abfd, n);
-		      bfd_section_list_insert_before (abfd, *op, n);
-
-		      op = &n->next;
+		      bfd_section_list_insert_before (abfd, o, n);
 		      saw_contents = FALSE;
 		    }
 		}
Index: gas/config/obj-ecoff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-ecoff.c,v
retrieving revision 1.14
diff -u -p -r1.14 obj-ecoff.c
--- gas/config/obj-ecoff.c	3 May 2005 12:02:47 -0000	1.14
+++ gas/config/obj-ecoff.c	3 May 2005 15:26:41 -0000
@@ -37,7 +37,7 @@ void
 ecoff_frob_file_before_fix (void)
 {
   bfd_vma addr;
-  asection **sec;
+  asection *sec;
 
   /* Set the section VMA values.  We force the .sdata and .sbss
      sections to the end to ensure that their VMA addresses are close
@@ -80,20 +80,19 @@ ecoff_frob_file_before_fix (void)
   for (i = 0; i < n_names; i++)
     secs[i] = NULL;
 
-  for (sec = &stdoutput->sections; *sec !=  NULL;)
+  for (sec = stdoutput->sections; sec != NULL; sec = sec->next)
     {
       for (i = 0; i < n_names; i++)
-	if (!strcmp ((*sec)->name, names[i]))
+	if (!strcmp (sec->name, names[i]))
 	  {
-	    secs[i] = *sec;
-	    bfd_section_list_remove (stdoutput, *sec);
+	    secs[i] = sec;
+	    bfd_section_list_remove (stdoutput, sec);
 	    break;
 	  }
       if (i == n_names)
 	{
-	  bfd_set_section_vma (stdoutput, *sec, addr);
-	  addr += bfd_section_size (stdoutput, *sec);
-	  sec = &(*sec)->next;
+	  bfd_set_section_vma (stdoutput, sec, addr);
+	  addr += bfd_section_size (stdoutput, sec);
 	}
     }
   for (i = 0; i < n_names; i++)
@@ -104,7 +103,7 @@ ecoff_frob_file_before_fix (void)
       }
   for (i = n_names - 1; i >= 0; i--)
     if (secs[i])
-      bfd_section_list_insert_after (stdoutput, stdoutput->sections, secs[i]);
+      bfd_section_list_prepend (stdoutput, secs[i]);
 
   /* Fill in the register masks.  */
   {
Index: gas/config/tc-mmix.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.c,v
retrieving revision 1.21
diff -u -p -r1.21 tc-mmix.c
--- gas/config/tc-mmix.c	3 May 2005 12:02:47 -0000	1.21
+++ gas/config/tc-mmix.c	3 May 2005 15:26:44 -0000
@@ -3747,18 +3747,11 @@ mmix_frob_file (void)
 
   if (real_reg_section != NULL)
     {
-      asection *secp;
-
       /* FIXME: Pass error state gracefully.  */
       if (bfd_get_section_flags (stdoutput, real_reg_section) & SEC_HAS_CONTENTS)
 	as_fatal (_("register section has contents\n"));
 
-      /* Really remove the section.  */
-      for (secp = stdoutput->sections;
-	   secp != real_reg_section;
-	   secp = secp->next)
-	;
-      bfd_section_list_remove (stdoutput, secp);
+      bfd_section_list_remove (stdoutput, real_reg_section);
       --stdoutput->section_count;
     }
 
Index: gas/config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.37
diff -u -p -r1.37 tc-xtensa.c
--- gas/config/tc-xtensa.c	3 May 2005 12:02:47 -0000	1.37
+++ gas/config/tc-xtensa.c	3 May 2005 15:26:50 -0000
@@ -9682,39 +9682,6 @@ set_subseg_freq (segT seg, subsegT subse
 \f
 /* Segment Lists and emit_state Stuff.  */
 
-/* Remove the segment from the global sections list.  */
-
-static void
-xtensa_remove_section (segT sec)
-{
-  /* Handle brain-dead bfd_section_list_remove macro, which
-     expect the address of the prior section's "next" field, not
-     just the address of the section to remove.  */
-  segT ps_next_ptr = stdoutput->sections;
-
-  while (ps_next_ptr != sec && ps_next_ptr != NULL) 
-    ps_next_ptr = ps_next_ptr->next;
-  
-  assert (ps_next_ptr != NULL);
-
-  bfd_section_list_remove (stdoutput, ps_next_ptr);
-}
-
-
-static void
-xtensa_insert_section (segT after_sec, segT sec)
-{
-  segT after_sec_next;
-
-  if (after_sec == NULL)
-    after_sec_next = stdoutput->sections;
-  else
-    after_sec_next = after_sec->next;
-
-  bfd_section_list_insert_after (stdoutput, after_sec_next, sec);
-}
-
-
 static void
 xtensa_move_seg_list_to_beginning (seg_list *head)
 {
@@ -9725,9 +9692,11 @@ xtensa_move_seg_list_to_beginning (seg_l
 
       /* Move the literal section to the front of the section list.  */
       assert (literal_section);
-      xtensa_remove_section (literal_section);
-      xtensa_insert_section (NULL, literal_section);
-
+      if (literal_section != stdoutput->sections)
+	{
+	  bfd_section_list_remove (stdoutput, literal_section);
+	  bfd_section_list_prepend (stdoutput, literal_section);
+	}
       head = head->next;
     }
 }
@@ -9893,8 +9862,8 @@ xtensa_reorder_seg_list (seg_list *head,
       assert (literal_section);
       if (literal_section != after)
 	{
-	  xtensa_remove_section (literal_section);
-	  xtensa_insert_section (after, literal_section);
+	  bfd_section_list_remove (stdoutput, literal_section);
+	  bfd_section_list_insert_after (stdoutput, after, literal_section);
 	}
 
       head = head->next;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-05-03 16:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-03 12:11 Fixup references to bfd_section_list... macros Nick Clifton
2005-05-03 12:49 ` Alan Modra
2005-05-03 13:25   ` Nick Clifton
2005-05-03 17:07   ` Alan Modra
2005-05-03 14:04 ` H. J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).