From cddaf9df9ec2eafe369a40b8d8eaf1edcd6557cd Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 27 Oct 2007 17:45:53 +0000 Subject: [PATCH] gas/ 2007-10-27 H.J. Lu 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-27 H.J. Lu PR gas/5221 * gas/elf/elf.exp: Run section7. * gas/elf/section7.d: New. * gas/elf/section7.s: Likewise. --- gas/ChangeLog | 9 +++++++++ gas/config/obj-elf.c | 17 +++++++++++++++-- gas/doc/as.texinfo | 6 ++++-- gas/testsuite/ChangeLog | 8 ++++++++ gas/testsuite/gas/elf/elf.exp | 1 + gas/testsuite/gas/elf/section7.d | 21 +++++++++++++++++++++ gas/testsuite/gas/elf/section7.s | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 gas/testsuite/gas/elf/section7.d create mode 100644 gas/testsuite/gas/elf/section7.s diff --git a/gas/ChangeLog b/gas/ChangeLog index eb1eed252..807d52db6 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2007-10-27 H.J. Lu + + PR gas/5221 + * config/obj-elf.c (obj_elf_section): Handle optional + parameters for .pushsection. + + * doc/as.texinfo: Document optional parameters for + .pushsection. + 2007-10-24 H.J. Lu * configure.in: Move AM_PROG_LIBTOOL after AC_GNU_SOURCE. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index ab1550df1..ccae61671 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -922,11 +922,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) @@ -1032,6 +1044,7 @@ obj_elf_section (int push) } } +done: demand_empty_rest_of_line (); obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push); diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 5d426ee01..21af11105 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -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 manipulation directives. The others are 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 diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index e18ddd437..8616469dd 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-10-27 H.J. Lu + + PR gas/5221 + * gas/elf/elf.exp: Run section7. + + * gas/elf/section7.d: New. + * gas/elf/section7.s: Likewise. + 2007-10-23 H.J. Lu * gas/i386/katmai.s: Remove cmpps opcode test. diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 1bcb101af..c5e292162 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -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" } diff --git a/gas/testsuite/gas/elf/section7.d b/gas/testsuite/gas/elf/section7.d new file mode 100644 index 000000000..94c57c6e0 --- /dev/null +++ b/gas/testsuite/gas/elf/section7.d @@ -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 +#... diff --git a/gas/testsuite/gas/elf/section7.s b/gas/testsuite/gas/elf/section7.s new file mode 100644 index 000000000..fe9aaa104 --- /dev/null +++ b/gas/testsuite/gas/elf/section7.s @@ -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 -- 2.11.4.GIT