This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[RFA] Doco and testsuite for last CFI update.
- From: Michal Ludvig <mludvig at suse dot cz>
- To: binutils at sources dot redhat dot com
- Date: Thu, 05 Jun 2003 12:01:00 +0200
- Subject: [RFA] Doco and testsuite for last CFI update.
Here are the patches for testsuite and documentation that I promised to
send.
OK to apply?
Michal Ludvig
2003-06-05 Michal Ludvig <mludvig@suse.cz>
* as.texinfo: Document new directives: .cfi_restore,
.cfi_undefined, .cfi_same_value, .cfi_return_column,
.cfi_remember_state, .cfi_restore_state, .cfi_nop.
Remove .cfi_verbose.
Index: as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.82
diff -u -p -r1.82 as.texinfo
--- as.texinfo 20 May 2003 07:58:07 -0000 1.82
+++ as.texinfo 5 Jun 2003 09:18:28 -0000
@@ -3691,14 +3691,20 @@ Some machine configurations provide addi
* Byte:: @code{.byte @var{expressions}}
* Comm:: @code{.comm @var{symbol} , @var{length} }
-* CFI directives:: @code{.cfi_startproc}
+* CFI directives:: @code{.cfi_startproc [simple]}
@code{.cfi_endproc}
@code{.cfi_def_cfa @var{register}, @var{offset}}
@code{.cfi_def_cfa_register @var{register}}
@code{.cfi_def_cfa_offset @var{offset}}
@code{.cfi_adjust_cfa_offset @var{offset}}
@code{.cfi_offset @var{register}, @var{offset}}
- @code{.cfi_verbose [1|0]}
+ @code{.cfi_restore @var{register}}
+ @code{.cfi_undefined @var{register}}
+ @code{.cfi_same_value @var{register}}
+ @code{.cfi_return_column @var{register}}
+ @code{.cfi_remember_state}
+ @code{.cfi_restore_state}
+ @code{.cfi_nop}
* Data:: @code{.data @var{subsection}}
@ifset COFF
@@ -3977,14 +3983,16 @@ undefined.
Each expression is assembled into the next byte.
@node CFI directives
-@section @code{.cfi_startproc}
+@section @code{.cfi_startproc [simple]}
@cindex @code{cfi_startproc} directive
@code{.cfi_startproc} is used at the beginning of each function that
should have an entry in @code{.eh_frame}. It initializes some internal
-data structures and emits architecture dependent initial CFI instructions.
-Don't forget to close the function by
+data structures. Don't forget to close the function by
@code{.cfi_endproc}.
+Unless @code{.cfi_startproc} is used along with parameter @code{simple}
+it also emits some architecture dependent initial CFI instructions.
+
@section @code{.cfi_endproc}
@cindex @code{cfi_endproc} directive
@code{.cfi_endproc} is used at the end of a function where it closes its
@@ -3992,31 +4000,67 @@ unwind entry previously opened by
@code{.cfi_startproc}. and emits it to @code{.eh_frame}.
@section @code{.cfi_def_cfa @var{register}, @var{offset}}
+@cindex @code{cfi_def_cfa} directive
@code{.cfi_def_cfa} defines a rule for computing CFA as: @i{take
address from @var{register} and add @var{offset} to it}.
@section @code{.cfi_def_cfa_register @var{register}}
+@cindex @code{cfi_def_cfa_register} directive
@code{.cfi_def_cfa_register} modifies a rule for computing CFA. From
now on @var{register} will be used instead of the old one. Offset
remains the same.
@section @code{.cfi_def_cfa_offset @var{offset}}
+@cindex @code{cfi_def_cfa_offset} directive
@code{.cfi_def_cfa_offset} modifies a rule for computing CFA. Register
remains the same, but @var{offset} is new. Note that it is the
absolute offset that will be added to a defined register to compute
CFA address.
@section @code{.cfi_adjust_cfa_offset @var{offset}}
+@cindex @code{cfi_adjust_cfa_offset} directive
Same as @code{.cfi_def_cfa_offset} but @var{offset} is a relative
value that is added/substracted from the previous offset.
@section @code{.cfi_offset @var{register}, @var{offset}}
+@cindex @code{cfi_offset} directive
Previous value of @var{register} is saved at offset @var{offset} from
CFA.
-@section @code{.cfi_verbose [1|0]}
-Switch on/off verbosity of the CFI machinery. @value{AS} will print
-lots of useful messages to standard output if you use this directive.
+@section @code{.cfi_register @var{register1}, @var{register2}}
+@cindex @code{cfi_register} directive
+Previous value of @var{register1} is saved in register @var{register2}.
+
+@section @code{.cfi_restore @var{register}}
+@cindex @code{cfi_restore} directive
+@code{.cfi_restore} says that the rule for @var{register} is now the
+same as it was at the beginning of the function, after all initial
+instruction added by @code{.cfi_startproc} were executed.
+
+@section @code{.cfi_undefined @var{register}}
+@cindex @code{cfi_undefined} directive
+From now on the previous value of @var{register} can't be restored anymore.
+
+@section @code{.cfi_same_value @var{register}}
+@cindex @code{cfi_same_value} directive
+Current value of @var{register} is the same like in the previous frame,
+i.e. no restoration needed.
+
+@section @code{.cfi_remember_state},
+@cindex @code{cfi_remember_state} directive
+First save all current rules for all registers by @code{.cfi_remember_state},
+then totally screw them up by subsequent @code{.cfi_*} directives and when
+everything is hopelessly bad, use @code{.cfi_restore_state} to restore
+the previous saved state.
+
+@section @code{.cfi_return_column @var{register}}
+@cindex @code{cfi_return_column} directive
+Change return column @var{register}, i.e. the return address is either
+directly in @var{register} or can be accessed by rules for @var{register}.
+
+@section @code{.cfi_nop}
+@cindex @code{cfi_nop} directive
+@i{Do nothing} directive. It just eats up a space.
@node Comm
@section @code{.comm @var{symbol} , @var{length} }
2003-06-05 Michal Ludvig <mludvig@suse.cz>
* testsuite/gas/cfi/cfi-x86_64.s: Test new directives
and different writings of registers and numbers.
* testsuite/gas/cfi/cfi-x86_64.d: Updated pattern to
match the above change.
Index: testsuite/gas/cfi/cfi-x86_64.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-x86_64.s,v
retrieving revision 1.1
diff -u -p -r1.1 cfi-x86_64.s
--- testsuite/gas/cfi/cfi-x86_64.s 20 May 2003 08:01:19 -0000 1.1
+++ testsuite/gas/cfi/cfi-x86_64.s 5 Jun 2003 09:52:15 -0000
@@ -35,9 +35,9 @@ func_prologue:
#; each instruction.
pushq %rbp
.cfi_def_cfa_offset 16
- .cfi_offset rbp,-16
+ .cfi_offset %rbp, -16
movq %rsp, %rbp
- .cfi_def_cfa_register rbp
+ .cfi_def_cfa_register %rbp
#; function body
call func_locvars
@@ -46,7 +46,7 @@ func_prologue:
#; epilogue with valid CFI
#; (we're better than gcc :-)
leaveq
- .cfi_def_cfa rsp,8
+ .cfi_def_cfa %rsp, 8
ret
.cfi_endproc
@@ -59,21 +59,21 @@ func_prologue:
func_otherreg:
.cfi_startproc
- #; save frame pointer to r12
- movq %rsp,%r12
- .cfi_def_cfa_register r12
+ #; save frame pointer to r8
+ movq %rsp,%r8
+ .cfi_def_cfa_register r8
#; alocate space for local vars
#; (no .cfi_{def,adjust}_cfa_offset here,
- #; because CFA is computed from r12!)
+ #; because CFA is computed from r8!)
sub $100,%rsp
#; function body
call func_prologue
addl $2, %eax
- #; restore frame pointer from r12
- movq %r12,%rsp
+ #; restore frame pointer from r8
+ movq %r8,%rsp
.cfi_def_cfa_register rsp
ret
.cfi_endproc
@@ -104,4 +104,37 @@ _start:
movq $0x3c,%rax
syscall
hlt
+ .cfi_endproc
+
+#; func_alldirectives
+#; - test for all .cfi directives.
+#; This function is never called and the CFI info doesn't make sense.
+
+ .type func_alldirectives,@function
+func_alldirectives:
+ .cfi_startproc simple
+ .cfi_def_cfa rsp,8
+ nop
+ .cfi_def_cfa_offset 16
+ nop
+ .cfi_def_cfa_register r8
+ nop
+ .cfi_adjust_cfa_offset 0x1234
+ nop
+ .cfi_offset %rsi, 0x10
+ nop
+ .cfi_register %r8, %r9
+ nop
+ .cfi_remember_state
+ nop
+ .cfi_restore %rbp
+ nop
+ .cfi_nop
+ nop
+ .cfi_undefined %rip
+ nop
+ .cfi_same_value rbx
+ nop
+ .cfi_restore_state
+ ret
.cfi_endproc
Index: testsuite/gas/cfi/cfi-x86_64.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi-x86_64.d,v
retrieving revision 1.3
diff -u -p -r1.3 cfi-x86_64.d
--- testsuite/gas/cfi/cfi-x86_64.d 27 May 2003 16:52:49 -0000 1.3
+++ testsuite/gas/cfi/cfi-x86_64.d 5 Jun 2003 09:52:15 -0000
@@ -35,7 +35,7 @@ The section .eh_frame contains:
00000050 00000014 00000054 FDE cie=00000000 pc=00000058..0000006b
DW_CFA_advance_loc: 3 to 0000005b
- DW_CFA_def_cfa_reg: r12
+ DW_CFA_def_cfa_reg: r8
DW_CFA_advance_loc: 15 to 0000006a
DW_CFA_def_cfa_reg: r7
DW_CFA_nop
@@ -46,6 +46,43 @@ The section .eh_frame contains:
DW_CFA_nop
0000007c 00000010 00000080 FDE cie=00000000 pc=00000084..00000096
+ DW_CFA_nop
+ DW_CFA_nop
+ DW_CFA_nop
+
+00000090 00000010 00000000 CIE
+ Version: 1
+ Augmentation: "zR"
+ Code alignment factor: 1
+ Data alignment factor: -8
+ Return address column: 16
+ Augmentation data: 1b
+
+ DW_CFA_def_cfa: r7 ofs 8
+
+000000a4 00000030 00000018 FDE cie=00000090 pc=000000ac..000000b8
+ DW_CFA_advance_loc: 1 to 000000ad
+ DW_CFA_def_cfa_offset: 16
+ DW_CFA_advance_loc: 1 to 000000ae
+ DW_CFA_def_cfa_reg: r8
+ DW_CFA_advance_loc: 1 to 000000af
+ DW_CFA_def_cfa_offset: 4676
+ DW_CFA_advance_loc: 1 to 000000b0
+ DW_CFA_offset_extended_sf: r5 at cfa\+16
+ DW_CFA_advance_loc: 1 to 000000b1
+ DW_CFA_register: r8 in r9
+ DW_CFA_advance_loc: 1 to 000000b2
+ DW_CFA_remember_state
+ DW_CFA_advance_loc: 1 to 000000b3
+ DW_CFA_restore: r6
+ DW_CFA_advance_loc: 1 to 000000b4
+ DW_CFA_nop
+ DW_CFA_advance_loc: 1 to 000000b5
+ DW_CFA_undefined: r16
+ DW_CFA_advance_loc: 1 to 000000b6
+ DW_CFA_same_value: r1
+ DW_CFA_advance_loc: 1 to 000000b7
+ DW_CFA_restore_state
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop