X-Git-Url: https://ruderich.org/simon/gitweb/?p=blhc%2Fblhc.git;a=blobdiff_plain;f=bin%2Fblhc;h=eb803248d784514aff2143a3c4835d475daa25db;hp=028dfbe53190d67f1a70768098fba0c3bfb33531;hb=f61763f97aa10059755d434556945465a4984aab;hpb=002738b1c775343f96d4a8228529ba4257085fd3 diff --git a/bin/blhc b/bin/blhc index 028dfbe..eb80324 100755 --- a/bin/blhc +++ b/bin/blhc @@ -475,6 +475,9 @@ my $exit = 0; FILE: foreach my $file (@ARGV) { open my $fh, '<', $file or die "$!: $file"; + # Architecture of this file. + my $arch = $option_arch; + # Hardening options. Not all architectures support all hardening options. my $harden_format = 1; my $harden_fortify = 1; @@ -549,9 +552,9 @@ FILE: foreach my $file (@ARGV) { last if $line =~ /^Build finished at \d{8}-\d{4}$/; # Detect architecture automatically unless overridden. - if (not $option_arch + if (not $arch and $line =~ /^dpkg-buildpackage: host architecture (.+)$/) { - $option_arch = $1; + $arch = $1; } # Ignore compiler warnings for now. @@ -655,7 +658,7 @@ FILE: foreach my $file (@ARGV) { } # Option or auto detected. - if ($option_arch) { + if ($arch) { # The following was partially copied from dpkg-dev 1.16.1.2 # (/usr/share/perl5/Dpkg/Vendor/Debian.pm, add_hardening_flags()), # copyright Raphaël Hertzog , Kees Cook @@ -663,10 +666,10 @@ FILE: foreach my $file (@ARGV) { # later. Keep it in sync. require Dpkg::Arch; - my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($option_arch); + my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($arch); # Disable unsupported hardening options. - if ($cpu =~ /^(ia64|alpha|mips|mipsel|hppa)$/ or $option_arch eq 'arm') { + if ($cpu =~ /^(ia64|alpha|mips|mipsel|hppa)$/ or $arch eq 'arm') { $harden_stack = 0; } if ($cpu =~ /^(ia64|hppa|avr32)$/) {