[PATCH 1/3] gas: sframe: guard block with support_sframe_p

Indu Bhagat indu.bhagat@oracle.com
Mon Jul 7 06:10:57 GMT 2025


SFrame is generated for ELF targets only.  Guard the block with
support_sframe_p like others for consistency.

We continue to issue an error on targets where SFrame is not supported:
    .sframe not supported for target

gas/
	* dw2gencfi.c (cfi_finish): Guard with support_sframe_p.
	(support_sframe_p): Remove stub to define to false for backends
	not supporting SFrame.

---
Notes:

In the RFD version, the whole block (including if and else) were guarded
with OBJ_ELF.  That was incorrect because we want to continue to issue
error (.sframe not supported for target), when SFrame is not supported.
Guarding only the if block with support_sframe_p looks like the right
thing to do.

[Changes from RFD]
  - Address review feedback to split out this change which is orthogonal
    to the addition of SHT_GNU_SFRAME.
[End of changes from RFD]
---
 gas/dw2gencfi.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c
index a21ae322488..7379198edec 100644
--- a/gas/dw2gencfi.c
+++ b/gas/dw2gencfi.c
@@ -91,11 +91,6 @@
 #define tc_cfi_reloc_for_encoding(e) BFD_RELOC_NONE
 #endif
 
-/* Targets which support SFrame format will define this and return true.  */
-#ifndef support_sframe_p
-# define support_sframe_p() false
-#endif
-
 /* Private segment collection list.  */
 struct dwcfi_seg_list
 {
@@ -2606,6 +2601,7 @@ cfi_finish (void)
 	- .sframe in the .cfi_sections directive.  */
   if (flag_gen_sframe || (all_cfi_sections & CFI_EMIT_sframe) != 0)
     {
+#ifdef support_sframe_p
       if (support_sframe_p () && !SUPPORT_FRAME_LINKONCE)
 	{
 	  segT sframe_seg;
@@ -2618,6 +2614,7 @@ cfi_finish (void)
 	  output_sframe (sframe_seg);
 	}
       else
+#endif
 	as_bad (_(".sframe not supported for target"));
     }
 
-- 
2.43.0



More information about the Binutils mailing list