tags 323049 +patch
thanks
Lovingly arm is little-endian but has big-endian doubles[1]. This
patch adds a check for such cases. Verified to compile on arm,
while not regressing atleast x86.
[1] Truth is even more complicated. There are big-endian arms and new
floating-point units/softfloat toolchains do things in other ways.
However, Debian is le/be float.
--- libimage-exiftool-perl-5.53.orig/lib/Image/ExifTool.pm 2005-07-29
19:33:43.000000000 +0300
+++ libimage-exiftool-perl-5.53/lib/Image/ExifTool.pm 2005-08-16
01:13:04.000000000 +0300
@@ -1456,6 +1456,7 @@
# Utility routines to for reading binary data values from file
my $swapBytes; # set if EXIF header is not native byte ordering
+my $swapDoubles; # arm double quirk
my $currentByteOrder = 'MM'; # current byte ordering ('II' or 'MM')
my %unpackMotorola = ( S => 'n', L => 'N', C => 'C', c => 'c' );
my %unpackIntel = ( S => 'v', L => 'V', C => 'C', c => 'c' );
@@ -1500,6 +1501,29 @@
return unpack($template,$val);
}
+sub DoUnpackD(@)
+{
+ my ($bytes, $template, $dataPt, $pos) = @_;
+ my $val='';
+
+ if ($swapBytes) {
+ $val = '';
+ $val .= substr($$dataPt,$pos+$bytes,1) while $bytes--;
+ } else {
+ $val = substr($$dataPt,$pos,$bytes);
+ }
+
+ if ($swapDoubles) {
+ my $bot = substr($val,0,4);
+ my $top = substr($val,4,4);
+ $val=$top.$bot;
+ }
+
+ defined($val) or return undef;
+ return unpack($template,$val);
+}
+
+
# Swap bytes in data if necessary
# Inputs: 0) data
# Returns: swapped data
@@ -1520,7 +1544,7 @@
sub Get32s($$) { return DoUnpack(4, 'l', @_); }
sub Get32u($$) { return DoUnpackStd('L', @_); }
sub GetFloat($$) { return DoUnpack(4, 'f', @_); }
-sub GetDouble($$) { return DoUnpack(8, 'd', @_); }
+sub GetDouble($$) { return DoUnpackD(8, 'd', @_); }
sub GetRational16s($$)
{
@@ -1604,6 +1628,19 @@
warn sprintf("Unknown native byte order! (pattern %x)\n",$val);
return 0;
}
+
+ # little-endian arm has bigendian doubles on debian
+
+ my $double = pack ("d",1);
+ my $hex = unpack("h*",$double);
+ if ( $hex eq "00000ff300000000" ){
+ $swapDoubles=1;
+ }
+ else {
+ $swapDoubles=0;
+ }
+
+
# swap bytes if our native CPU byte ordering is not the same as the EXIF
$swapBytes = ($order ne $nativeOrder);
$currentByteOrder = $order; # save current byte order