Update copyright year
[openssl.git] / crypto / perlasm / x86_64-xlate.pl
index b612c215a0548ceb2ee5d583f16da1b7d85f61ce..29a0eacfd532a6a41db6e986e144b33471920990 100755 (executable)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2005-2019 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the OpenSSL license (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -212,8 +212,9 @@ my %globals;
            }
            sprintf "\$%s",$self->{value};
        } else {
-           $self->{value} =~ s/0x([0-9a-f]+)/0$1h/ig if ($masm);
-           sprintf "%s",$self->{value};
+           my $value = $self->{value};
+           $value =~ s/0x([0-9a-f]+)/0$1h/ig if ($masm);
+           sprintf "%s",$value;
        }
     }
 }
@@ -530,7 +531,7 @@ my %globals;
        );
 
     # Following constants are defined in x86_64 ABI supplement, for
-    # example avaiable at https://www.uclibc.org/docs/psABI-x86_64.pdf,
+    # example available at https://www.uclibc.org/docs/psABI-x86_64.pdf,
     # see section 3.7 "Stack Unwind Algorithm".
     my %DW_reg_idx = (
        "%rax"=>0,  "%rdx"=>1,  "%rcx"=>2,  "%rbx"=>3,
@@ -540,10 +541,11 @@ my %globals;
        );
 
     my ($cfa_reg, $cfa_rsp);
+    my @cfa_stack;
 
     # [us]leb128 format is variable-length integer representation base
     # 2^128, with most significant bit of each byte being 0 denoting
-    # *last* most significat digit. See "Variable Length Data" in the
+    # *last* most significant digit. See "Variable Length Data" in the
     # DWARF specification, numbered 7.6 at least in versions 3 and 4.
     sub sleb128 {
        use integer;    # get right shift extend sign
@@ -647,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; };
-           /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/
@@ -687,6 +695,14 @@ my %globals;
                                                      cfa_expression($$line)));
                                last;
                              };
+           /remember_state/
+                       && do { push @cfa_stack, [$cfa_reg, $cfa_rsp];
+                               last;
+                             };
+           /restore_state/
+                       && do { ($cfa_reg, $cfa_rsp) = @{pop @cfa_stack};
+                               last;
+                             };
            }
 
            $self->{value} = ".cfi_$dir\t$$line" if ($dir);
@@ -876,7 +892,7 @@ my %globals;
                                                        $var=~s/^(0b[0-1]+)/oct($1)/eig;
                                                        $var=~s/^0x([0-9a-f]+)/0$1h/ig if ($masm);
                                                        if ($sz eq "D" && ($current_segment=~/.[px]data/ || $dir eq ".rva"))
-                                                       { $var=~s/([_a-z\$\@][_a-z0-9\$\@]*)/$nasm?"$1 wrt ..imagebase":"imagerel $1"/egi; }
+                                                       { $var=~s/^([_a-z\$\@][_a-z0-9\$\@]*)/$nasm?"$1 wrt ..imagebase":"imagerel $1"/egi; }
                                                        $var;
                                                    };
 
@@ -1426,6 +1442,6 @@ close STDOUT;
 #
 # (*)  Note that we're talking about run-time, not debug-time. Lack of
 #      unwind information makes debugging hard on both Windows and
-#      Unix. "Unlike" referes to the fact that on Unix signal handler
+#      Unix. "Unlike" refers to the fact that on Unix signal handler
 #      will always be invoked, core dumped and appropriate exit code
 #      returned to parent (for user notification).