This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR gas/5221: .pushsection is broken
- From: "H.J. Lu" <hjl at lucon dot org>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: binutils at sources dot redhat dot com, nickc at redhat dot com
- Date: Fri, 26 Oct 2007 08:50:03 -0700
- Subject: Re: PATCH: PR gas/5221: .pushsection is broken
- References: <20071026150628.GA20388@lucon.org> <je4pgdx5ak.fsf@sykes.suse.de>
On Fri, Oct 26, 2007 at 05:29:55PM +0200, Andreas Schwab wrote:
> "H.J. Lu" <hjl@lucon.org> writes:
>
> > --- gas/doc/as.texinfo.push 2007-10-17 08:48:37.000000000 -0700
> > +++ gas/doc/as.texinfo 2007-10-26 08:00:09.000000000 -0700
> > @@ -5468,7 +5468,7 @@ expanded. @xref{Macro}.
> >
> > @ifset ELF
> > @node PushSection
> > -@section @code{.pushsection @var{name} , @var{subsection}}
> > +@section @code{.pushsection @var{name} [, @var{subsection} [, "@var{flags}"[, @@@var{type}[,@var{arguments}]]]]}
>
> I think you should describe it like this:
>
> @section @code{.pushsection @var{name} [, @var{subsection}] [, "@var{flags}"[, @@@var{type}[,@var{arguments}]]]}
>
> since the subsection can be left out even if flags, etc. follow.
>
Good point. Thanks.
Here is the updated patch.
H.J.
----
gas/
2007-10-26 H.J. Lu <hongjiu.lu@intel.com>
PR gas/5221
* config/obj-elf.c (obj_elf_section): Handle optional
parameters for .pushsection.
* doc/as.texinfo: Document optional parameters for
.pushsection.
gas/testsuite/
2007-10-26 H.J. Lu <hongjiu.lu@intel.com>
PR gas/5221
* gas/elf/elf.exp: Run section7.
* gas/elf/section7.d: New.
* gas/elf/section7.s: Likewise.
--- gas/config/obj-elf.c.push 2007-10-26 06:23:23.000000000 -0700
+++ gas/config/obj-elf.c 2007-10-26 06:47:38.000000000 -0700
@@ -964,11 +964,23 @@ obj_elf_section (int push)
++input_line_pointer;
SKIP_WHITESPACE ();
- if (push)
+ if (push && ISDIGIT (*input_line_pointer))
{
+ /* .pushsection has an optional subsection. */
new_subsection = (subsegT) get_absolute_expression ();
+
+ SKIP_WHITESPACE ();
+
+ /* Stop if we don't see a comma. */
+ if (*input_line_pointer != ',')
+ goto done;
+
+ /* Skip the comma. */
+ ++input_line_pointer;
+ SKIP_WHITESPACE ();
}
- else if (*input_line_pointer == '"')
+
+ if (*input_line_pointer == '"')
{
beg = demand_copy_C_string (&dummy);
if (beg == NULL)
@@ -1074,6 +1086,7 @@ obj_elf_section (int push)
}
}
+done:
demand_empty_rest_of_line ();
obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push);
--- gas/doc/as.texinfo.push 2007-10-17 08:48:37.000000000 -0700
+++ gas/doc/as.texinfo 2007-10-26 08:46:26.000000000 -0700
@@ -5468,7 +5468,7 @@ expanded. @xref{Macro}.
@ifset ELF
@node PushSection
-@section @code{.pushsection @var{name} , @var{subsection}}
+@section @code{.pushsection @var{name} [, @var{subsection}] [, "@var{flags}"[, @@@var{type}[,@var{arguments}]]]}
@cindex @code{pushsection} directive
@cindex Section Stack
@@ -5479,7 +5479,9 @@ This is one of the ELF section stack man
This directive pushes the current section (and subsection) onto the
top of the section stack, and then replaces the current section and
-subsection with @code{name} and @code{subsection}.
+subsection with @code{name} and @code{subsection}. The optional
+@code{flags}, @code{type} and @code{arguments} are treated the same
+as in the @code{.section} (@pxref{Section}) directive.
@end ifset
@node Quad
--- gas/testsuite/gas/elf/elf.exp.push 2007-10-11 18:36:34.000000000 -0700
+++ gas/testsuite/gas/elf/elf.exp 2007-10-26 07:02:50.000000000 -0700
@@ -104,4 +104,5 @@ if { ([istarget "*-*-*elf*"]
run_dump_test "symver"
run_elf_list_test "type" "" "" "-s" "| grep \"1 \\\[FONTC\\\]\""
run_dump_test "section6"
+ run_dump_test "section7"
}
--- gas/testsuite/gas/elf/section7.d.push 2007-10-26 07:02:11.000000000 -0700
+++ gas/testsuite/gas/elf/section7.d 2007-10-26 07:52:44.000000000 -0700
@@ -0,0 +1,21 @@
+#objdump: -s
+#name: elf section7
+
+.*: +file format .*
+
+# The MIPS includes a 'section .reginfo' and such here.
+#...
+Contents of section .bar:
+ 0000 00000000 00000000 0000 .*
+Contents of section .bar1:
+ 0000 0102 .*
+Contents of section .bar2:
+ 0000 0102 .*
+Contents of section .bar3:
+ 0000 0103 .*
+Contents of section .bar4:
+ 0000 04 .*
+Contents of section .text:
+ 0000 feff .*
+# Arm includes a .ARM.attributes section here
+#...
--- gas/testsuite/gas/elf/section7.s.push 2007-10-26 07:02:13.000000000 -0700
+++ gas/testsuite/gas/elf/section7.s 2007-10-26 07:50:26.000000000 -0700
@@ -0,0 +1,38 @@
+ .section .bar,"a"
+ .byte 0
+.pushsection .bar1,2,"a"
+ .byte 2
+.popsection
+ .byte 0
+.pushsection .bar2,3,"a"
+ .byte 2
+.popsection
+ .byte 0
+.pushsection .bar3,2,"a", %progbits
+ .byte 3
+.popsection
+ .byte 0
+.pushsection .bar4
+ .byte 4
+.popsection
+ .byte 0
+.pushsection .text,1,"axG",%progbits,foo,comdat
+ .byte -1
+.popsection
+ .byte 0
+.pushsection .text,"axG",%progbits,foo,comdat
+ .byte -2
+.popsection
+ .byte 0
+.pushsection .bar1,"a"
+ .byte 1
+.popsection
+ .byte 0
+.pushsection .bar3,"a", %progbits
+ .byte 1
+.popsection
+ .byte 0
+.pushsection .bar2,"a"
+ .byte 1
+.popsection
+ .byte 0