This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to use .pushsection?
Hi Lee,
The document says
`.pushsection NAME , SUBSECTION'
I have applied the attached patch to fix the behaviour of the assembler so that
it conforms to this documentation.
Cheers
Nick
gas/ChangeLog
2007-10-11 Nick Clifton <nickc@redhat.com>
* config/obj-elf.c (obj_elf_section): When pushing a section, if
there is a a comma then the following argument must be a
subsection number.
gas/testsuite/ChangeLog
2007-10-11 Nick Clifton <nickc@redhat.com>
* gas/elf/elf.exp (run_elf_list_test): Run section6 test.
* gas/elf/section6.s: New file: Check behaviour of .pushsection
with a subsection argument.
* gas/elf/section6.d: New file: Expected disassembly.
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.105
diff -c -3 -p -r1.105 obj-elf.c
*** gas/config/obj-elf.c 8 Oct 2007 15:26:42 -0000 1.105
--- gas/config/obj-elf.c 11 Oct 2007 20:08:27 -0000
*************** obj_elf_section (int push)
*** 883,888 ****
--- 883,889 ----
int type, attr, dummy;
int entsize;
int linkonce;
+ subsegT new_subsection = -1;
#ifndef TC_I370
if (flag_mri)
*************** obj_elf_section (int push)
*** 921,927 ****
++input_line_pointer;
SKIP_WHITESPACE ();
! if (*input_line_pointer == '"')
{
beg = demand_copy_C_string (&dummy);
if (beg == NULL)
--- 922,932 ----
++input_line_pointer;
SKIP_WHITESPACE ();
! if (push)
! {
! new_subsection = (subsegT) get_absolute_expression ();
! }
! else if (*input_line_pointer == '"')
{
beg = demand_copy_C_string (&dummy);
if (beg == NULL)
*************** obj_elf_section (int push)
*** 1030,1035 ****
--- 1035,1043 ----
demand_empty_rest_of_line ();
obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push);
+
+ if (push && new_subsection != -1)
+ subseg_set (now_seg, new_subsection);
}
/* Change to the .data section. */
*** /dev/null 2007-10-11 10:59:37.536854224 +0100
--- gas/testsuite/gas/elf/section6.s 2007-10-11 17:18:17.000000000 +0100
***************
*** 0 ****
--- 1,10 ----
+ .section sec1
+ .byte 1
+ .subsection 2
+ .byte 2
+ .pushsection sec2,1
+ .byte 3
+ .subsection 0
+ .byte 4
+ .popsection
+ .byte 5
*** /dev/null 2007-10-11 10:59:37.536854224 +0100
--- gas/testsuite/gas/elf/section6.d 2007-10-11 17:19:45.000000000 +0100
***************
*** 0 ****
--- 1,13 ----
+ #objdump: -s
+ #name: elf section6
+
+ .*: +file format .*
+
+ # The MIPS includes a 'section .reginfo' and such here.
+ #...
+ Contents of section sec1:
+ 0+000 01 ?02 ?05.*
+ Contents of section sec2:
+ 0+000 04 ?03.*
+ # Arm includes a .ARM.attributes section here
+ #...