This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Fixup references to bfd_section_list... macros
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Nick Clifton <nickc at redhat dot com>, bob dot wilson at acm dot org
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 3 May 2005 07:00:26 -0700
- Subject: Re: Fixup references to bfd_section_list... macros
- References: <m3ll6wmsbh.fsf@redhat.com>
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
/* 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;