-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GNU assembler 2.26 introduced the .cfi_label directive. It does not expand to any CFI instructions, but defines a label in .eh_frame/.debug_frame, which can be used by runtime patching code to locate the FDE. .cfi_label is not allowed for CIE's initial instructions, and can therefore be used to force the next instruction to be placed in a FDE instead of a CIE. In glibc since 2018, sysdeps/riscv/start.S utilizes .cfi_label to force DW_CFA_undefined to be placed in a FDE. arc/csky/loongarch ports have copied this use. ``` .cfi_startproc // DW_CFA_undefined is allowed for CIE's initial instructions. // Without .cfi_label, gas would place DW_CFA_undefined in a CIE. .cfi_label .Ldummy .cfi_undefined ra .cfi_endproc ``` No CFI instruction is associated with .cfi_label, so the `case MCCFIInstruction::OpLabel:` code in BOLT is unreachable and onlt to make -Wswitch happy. Close #97222 Pull Request: #97922
- Loading branch information
Showing
9 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# RUN: llvm-mc -triple x86_64 %s | FileCheck %s --check-prefix=ASM | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t | ||
# RUN: llvm-readelf -sX %t | FileCheck %s --check-prefix=SYMTAB | ||
# RUN: llvm-dwarfdump --eh-frame %t | FileCheck %s | ||
|
||
# RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym ERR=1 %s -o /dev/null 2>&1 | \ | ||
# RUN: FileCheck %s --check-prefix=ERR --implicit-check-not=error: | ||
|
||
# ASM: nop | ||
# ASM-NEXT: .cfi_label cfi1 | ||
# ASM-NEXT: .cfi_escape 0x00 | ||
# ASM: .globl cfi2 | ||
# ASM-NEXT: .cfi_label cfi2 | ||
# ASM: nop | ||
# ASM-NEXT: .cfi_label .Lcfi3 | ||
|
||
# SYMTAB: 000000000000002b 0 NOTYPE LOCAL DEFAULT 3 (.eh_frame) cfi1 | ||
# SYMTAB: 000000000000002d 0 NOTYPE GLOBAL DEFAULT 3 (.eh_frame) cfi2 | ||
# SYMTAB-NOT: {{.}} | ||
|
||
# CHECK: DW_CFA_remember_state: | ||
# CHECK-NEXT: DW_CFA_advance_loc: 1 to 0x1 | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_advance_loc: 1 to 0x2 | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_advance_loc: 1 to 0x3 | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_nop: | ||
# CHECK-NEXT: DW_CFA_restore_state: | ||
|
||
.globl foo | ||
foo: | ||
.cfi_startproc | ||
.cfi_remember_state | ||
nop | ||
.cfi_label cfi1 | ||
.cfi_escape 0 | ||
nop | ||
.globl cfi2 | ||
.cfi_label cfi2 | ||
.cfi_escape 0, 0 | ||
nop | ||
.cfi_label .Lcfi3 | ||
.cfi_escape 0, 0, 0 | ||
.cfi_restore_state | ||
ret | ||
|
||
# ERR: [[#@LINE+10]]:1: error: this directive must appear between .cfi_startproc and .cfi_endproc directives | ||
.ifdef ERR | ||
# ERR: [[#@LINE+1]]:12: error: symbol 'foo' is already defined | ||
.cfi_label foo | ||
# ERR: [[#@LINE+1]]:12: error: symbol '.Lcfi3' is already defined | ||
.cfi_label .Lcfi3 | ||
.endif | ||
.cfi_endproc | ||
|
||
.ifdef ERR | ||
.cfi_label after_endproc | ||
.endif |