[binutils-gdb] include: sframe: update code comments around SFrame FRE stack offsets

Indu Bhagat ibhagat@sourceware.org
Tue Jul 9 17:29:25 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4de9a5ccd666e218e5985d35895406f94db65f3c

commit 4de9a5ccd666e218e5985d35895406f94db65f3c
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date:   Fri Apr 19 16:48:17 2024 -0700

    include: sframe: update code comments around SFrame FRE stack offsets
    
    This also amends the incorrect comment:
        offset3 (intrepreted as FP = CFA + offset2)
    
    If RA tracking is enabled,  the offset to recover FP is at the third
    index.  The SFrame format (V2) has assumption that if FP is saved on
    stack, RA must have been saved as well.  This is true for the currently
    supported arch Aarch64.  For AMD64, RA tracking per SFrame FRE is not
    necessary.
    
    In future, when extending support for more architectures, this will
    likely need to be revisited.
    
    include/
            * sframe.h: Make the comments clearer by enumerating what
            happens per-ABI.

Diff:
---
 include/sframe.h | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/sframe.h b/include/sframe.h
index b3d0c2e937d..347dbc73787 100644
--- a/include/sframe.h
+++ b/include/sframe.h
@@ -282,20 +282,22 @@ typedef struct sframe_fre_info
      S is the size of the stack frame offset for the FRE, and
      N is the number of stack frame offsets in the FRE
 
-   The offsets are interpreted in order as follows:
+   The interpretation of FRE stack offsets is ABI-specific:
 
-    offset1 (interpreted as CFA = BASE_REG + offset1)
-
-    if RA is being tracked
-      offset2 (interpreted as RA = CFA + offset2)
-      if FP is being tracked
-	offset3 (intrepreted as FP = CFA + offset2)
-      fi
-    else
+   AMD64:
+     offset1 (interpreted as CFA = BASE_REG + offset1)
       if FP is being tracked
 	offset2 (intrepreted as FP = CFA + offset2)
       fi
-    fi
+
+    AARCH64:
+     offset1 (interpreted as CFA = BASE_REG + offset1)
+     if FP is being tracked (in other words, if frame record created)
+       offset2 (interpreted as RA = CFA + offset2)
+       offset3 (intrepreted as FP = CFA + offset3)
+     fi
+     Note that in AAPCS64, a frame record, if created, will save both FP and
+     LR on stack.
 */
 
 /* Used when SFRAME_FRE_TYPE_ADDR1 is specified as FRE type.  */


More information about the Binutils-cvs mailing list