Skip to content

DW_CFA_AARCH64_negate_ra_state_with_pc is fundamentally flawed #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
smithp35 opened this issue Apr 29, 2025 · 0 comments
Open

DW_CFA_AARCH64_negate_ra_state_with_pc is fundamentally flawed #327

smithp35 opened this issue Apr 29, 2025 · 0 comments

Comments

@smithp35
Copy link
Contributor

The DW_CFA_AARCH64_negate_ra_state_with_pc https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#44call-frame-instructions

A dwarf 'program' reads linearly through a file from a start location and needs to recreate the frame status that the CPU would see if it were to execute to that point. Most importantly, it does not follow the flow-graph of the program that the CPU executes.

The following program shows how control flow could lead to an incorrect location being saved.

  .cfi_startproc 
func:
   // Frame setup
   .cfi_save ...
   .cfi_negate_ra_with_pc  // Save auth state and remember location
   some code
   CBZ L0
   some more code
   // Restore frame
   .cfi_negate_ra_with_pc  // Restore state (using previously stored location)
   .cfi_restore ...
   RET
L0:
   .cfi_save ...
   .cfi_negate_ra_with_pc  // ERROR - this saves the wrong location
   Some additional code
   .cfi_negate_ra_with_pc     // Uses wrong location.
   RET
...  

It is not sufficient to define that the first .cfi_negate_ra_with_pc does the save as this may not be the first directive executed by the control flow, and we do not want to restrict the control flow of a program so that this directive can work.

A proposal will be made for a replacement for .cfi_negate_ra_with_pc and this directive will be deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant