Ticket #50771: 0002-RT3885-OpenSSL-fails-to-cross-compile-on-32-bit-64-b.patch

File 0002-RT3885-OpenSSL-fails-to-cross-compile-on-32-bit-64-b.patch, 1.8 KB (added by neverpanic (Clemens Lang), 9 years ago)
  • crypto/perlasm/x86_64-xlate.pl

    From 11fc645255918aab77950ab35bd6c0476a1d40c4 Mon Sep 17 00:00:00 2001
    From: Todd Short <tshort@akamai.com>
    Date: Tue, 19 May 2015 14:46:40 -0400
    Subject: [PATCH 2/2] RT3885 OpenSSL fails to cross-compile on 32-bit->64-bit
    
    Older 32-bit versions of perl cannot handle 64-bit numbers, so when
    the x86_64-xlate.pl script encounters a 64-bit number, the oct()
    function munges it into a double-precision rather than a 64-bit
    integer. In this case, we know it's either a hex number or an octal
    number. So, if 64-bit hex, just pass through as hex string, otherwise
    allow oct() to handle it. There are some cases where immediate constants
    are multiplied together. The script assumes decimal numbers during mul,
    div, mod operations, so by handling only 64-bit numbers in this manner,
    the impact of this patch is minimized.
    
    This is a problem in ghash-x86_64.pl (ghash-x86_64.s), and the solution
    has an impact all 64-bit platforms. Ran the unit tests to make sure it's
    OK.
    ---
     crypto/perlasm/x86_64-xlate.pl | 8 +++++++-
     1 file changed, 7 insertions(+), 1 deletion(-)
    
    diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl
    index 29f94b5..d9d6454 100755
    a b my %globals; 
    192192        }
    193193        $ret;
    194194    }
     195    sub myoct {
     196        my $v = shift;
     197        return $v if ($v =~ /^0x[0-9a-f]{9,16}/i); # if 64-bit hex leave as-is
     198        use integer;
     199        return oct($v);
     200    }
    195201    sub out {
    196202        my $self = shift;
    197203
    198204        if ($gas) {
    199205            # Solaris /usr/ccs/bin/as can't handle multiplications
    200206            # in $self->{value}
    201             $self->{value} =~ s/(?<![\w\$\.])(0x?[0-9a-f]+)/oct($1)/egi;
     207            $self->{value} =~ s/(?<![\w\$\.])(0x?[0-9a-f]+)/myoct($1)/egi;
    202208            $self->{value} =~ s/([0-9]+\s*[\*\/\%]\s*[0-9]+)/eval($1)/eg;
    203209            sprintf "\$%s",$self->{value};
    204210        } else {