Browse Source
There are two state propagation functions in SCFI machinery - forward
and backward flow. The patch addresses two issues:
- In forward_flow_scfi_state (), the state being compared in forward flow
must be that at the exit of a prev bb and that at the entry of the
next bb. The variable holding the state to be compared was
previously (erroneously) stale.
- In cmp_scfi_state (), the assumption that two different control
flows, leading to the same basic block, cannot have a mismatched
notion of CFA base register, is not true. Remove the assertion and
instead return err if mismatch.
Fixing these issues helps correctly synthesize CFI, when previously
SCFI was erroring out for an otherwise valid input asm.
gas/
* scfi.c (cmp_scfi_state): Remove assertion and return mismatch
in return value as applicable.
(forward_flow_scfi_state): Update state object to be the same as
the exit state of the prev bb before comparing.
gas/testsuite/
* gas/scfi/x86_64/scfi-x86-64.exp: Add new test.
* gas/scfi/x86_64/scfi-cfg-5.d: New test.
* gas/scfi/x86_64/scfi-cfg-5.l: New test.
* gas/scfi/x86_64/scfi-cfg-5.s: New test.
master
5 changed files with 87 additions and 8 deletions
@ -0,0 +1,39 @@ |
|||
#as: --scfi=experimental -W |
|||
#as: |
|||
#objdump: -Wf |
|||
#name: Synthesize CFI in presence of control flow 5 |
|||
#... |
|||
Contents of the .eh_frame section: |
|||
|
|||
00000000 0+0014 0+0000 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 \(rsp\) ofs 8 |
|||
DW_CFA_offset: r16 \(rip\) at cfa-8 |
|||
DW_CFA_nop |
|||
DW_CFA_nop |
|||
|
|||
0+0018 0+002c 0000001c FDE cie=00000000 pc=0+0000..0+0017 |
|||
DW_CFA_advance_loc: 1 to 0+0001 |
|||
DW_CFA_def_cfa_offset: 16 |
|||
DW_CFA_offset: r6 \(rbp\) at cfa-16 |
|||
DW_CFA_advance_loc: 3 to 0+0004 |
|||
DW_CFA_def_cfa_register: r6 \(rbp\) |
|||
DW_CFA_advance_loc: 5 to 0+0009 |
|||
DW_CFA_remember_state |
|||
DW_CFA_advance_loc: 6 to 0+000f |
|||
DW_CFA_def_cfa_register: r7 \(rsp\) |
|||
DW_CFA_restore: r6 \(rbp\) |
|||
DW_CFA_def_cfa_offset: 8 |
|||
DW_CFA_advance_loc: 1 to 0+0010 |
|||
DW_CFA_restore_state |
|||
DW_CFA_advance_loc: 6 to 0+0016 |
|||
DW_CFA_def_cfa_register: r7 \(rsp\) |
|||
DW_CFA_restore: r6 \(rbp\) |
|||
DW_CFA_def_cfa_offset: 8 |
|||
|
|||
#pass |
|||
@ -0,0 +1,2 @@ |
|||
.*Assembler messages: |
|||
.*5: Warning: SCFI ignores most user-specified CFI directives |
|||
@ -0,0 +1,32 @@ |
|||
.text |
|||
.globl foo |
|||
.type foo, @function |
|||
foo: |
|||
.cfi_startproc |
|||
push %rbp |
|||
.cfi_def_cfa_offset 16 |
|||
.cfi_offset %rbp, -16 |
|||
mov %rsp, %rbp |
|||
.cfi_def_cfa_register %rbp |
|||
cmpl $-1, %eax |
|||
jne .L1 |
|||
.L2: |
|||
.cfi_remember_state |
|||
call bar |
|||
pop %rbp |
|||
.cfi_def_cfa_register %rsp |
|||
.cfi_restore %rbp |
|||
.cfi_def_cfa_offset 8 |
|||
ret |
|||
|
|||
.L1: |
|||
.cfi_restore_state |
|||
testq %rax, %rax |
|||
je .L2 |
|||
pop %rbp |
|||
.cfi_def_cfa_register %rsp |
|||
.cfi_restore %rbp |
|||
.cfi_def_cfa_offset 8 |
|||
ret |
|||
.cfi_endproc |
|||
.size foo,.-foo |
|||
Loading…
Reference in new issue