Check for unpaired .cfi_remember_state
authorDavid Benjamin <davidben@google.com>
Tue, 29 Jan 2019 23:41:39 +0000 (17:41 -0600)
committerKurt Roeckx <kurt@roeckx.be>
Sun, 17 Feb 2019 22:39:51 +0000 (23:39 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #8109

crypto/perlasm/x86_64-xlate.pl

index 080fc8d..4a7ec7a 100755 (executable)
@@ -649,7 +649,13 @@ my %globals;
            # why it starts with -8. Recall that CFA is top of caller's
            # stack...
            /startproc/ && do { ($cfa_reg, $cfa_rsp) = ("%rsp", -8); last; };
            # why it starts with -8. Recall that CFA is top of caller's
            # stack...
            /startproc/ && do { ($cfa_reg, $cfa_rsp) = ("%rsp", -8); last; };
-           /endproc/   && do { ($cfa_reg, $cfa_rsp) = ("%rsp",  0); last; };
+           /endproc/   && do { ($cfa_reg, $cfa_rsp) = ("%rsp",  0);
+                               # .cfi_remember_state directives that are not
+                               # matched with .cfi_restore_state are
+                               # unnecessary.
+                               die "unpaired .cfi_remember_state" if (@cfa_stack);
+                               last;
+                             };
            /def_cfa_register/
                        && do { $cfa_reg = $$line; last; };
            /def_cfa_offset/
            /def_cfa_register/
                        && do { $cfa_reg = $$line; last; };
            /def_cfa_offset/