77 lines
3.3 KiB
Diff
77 lines
3.3 KiB
Diff
From 3602da6fa285d6b22d87bcc39056e919e939ef07 Mon Sep 17 00:00:00 2001
|
|
From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
|
|
Date: Tue, 15 Apr 2025 12:20:40 +0300
|
|
Subject: [PATCH] gas: sframe: fix handling of .cfi_def_cfa_register
|
|
|
|
Fix PR gas/32879 sframe: Assembler internal error when translating
|
|
cfi_def_cfa_register
|
|
|
|
As per the documentation, .cfi_def_cfa_register modifies a rule for
|
|
computing CFA; the register is updated, but the offset remains the same.
|
|
|
|
While translating .cfi_def_cfa_register into SFrame context, we use the
|
|
information from last translated FRE to set the CFA offset. However,
|
|
there may be cases when the last translated FRE is empty. Use last FRE
|
|
only if available.
|
|
|
|
Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
|
|
Signed-off-by: Indu Bhagat <indu.bhagat@oracle.com>
|
|
---
|
|
diff -rupN binutils-2.43.1.orig/gas/gen-sframe.c binutils-2.43.1/gas/gen-sframe.c
|
|
--- binutils-2.43.1.orig/gas/gen-sframe.c 2025-07-21 10:18:20.701626832 +0100
|
|
+++ binutils-2.43.1/gas/gen-sframe.c 2025-07-21 10:19:04.972504129 +0100
|
|
@@ -1051,7 +1051,9 @@ sframe_xlate_do_def_cfa_register (struct
|
|
return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */
|
|
}
|
|
sframe_fre_set_cfa_base_reg (cur_fre, cfi_insn->u.ri.reg);
|
|
- sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset);
|
|
+ if (last_fre)
|
|
+ sframe_fre_set_cfa_offset (cur_fre, last_fre->cfa_offset);
|
|
+
|
|
cur_fre->merge_candidate = false;
|
|
|
|
return SFRAME_XLATE_OK;
|
|
diff -rupN binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.d binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.d
|
|
--- binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.d 1970-01-01 01:00:00.000000000 +0100
|
|
+++ binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.d 2025-07-21 10:18:35.950185785 +0100
|
|
@@ -0,0 +1,21 @@
|
|
+#as: --gsframe
|
|
+#objdump: --sframe=.sframe
|
|
+#name: Check .cfi_def_cfa_register with no previous offset
|
|
+#...
|
|
+Contents of the SFrame section .sframe:
|
|
+
|
|
+ Header :
|
|
+
|
|
+ Version: SFRAME_VERSION_2
|
|
+ Flags: NONE
|
|
+#? CFA fixed FP offset: \-?\d+
|
|
+#? CFA fixed RA offset: \-?\d+
|
|
+ Num FDEs: 1
|
|
+ Num FREs: 1
|
|
+
|
|
+ Function Index :
|
|
+
|
|
+ func idx \[0\]: pc = 0x0, size = 0 bytes
|
|
+ STARTPC +CFA +FP +RA +
|
|
+ 0+0000 +fp\+8 +u +f +
|
|
+#pass
|
|
diff -rupN binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.s binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.s
|
|
--- binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.s 1970-01-01 01:00:00.000000000 +0100
|
|
+++ binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-2.s 2025-07-21 10:18:35.950246411 +0100
|
|
@@ -0,0 +1,4 @@
|
|
+# Although not a useful construct by itself, ensure graceful handling.
|
|
+ .cfi_startproc
|
|
+ .cfi_def_cfa_register 6
|
|
+ .cfi_endproc
|
|
diff -rupN binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
|
|
--- binutils-2.43.1.orig/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp 2025-07-21 10:18:20.756742820 +0100
|
|
+++ binutils-2.43.1/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp 2025-07-21 10:19:33.756745567 +0100
|
|
@@ -89,6 +89,7 @@ if { [istarget "x86_64-*-*"] && [gas_sfr
|
|
if { [gas_x86_64_check] } then {
|
|
set ASFLAGS "$ASFLAGS --64"
|
|
run_dump_test "cfi-sframe-x86_64-1"
|
|
+ run_dump_test "cfi-sframe-x86_64-2"
|
|
set ASFLAGS "$old_ASFLAGS"
|
|
}
|
|
}
|