X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=6fb0f21b491ebbd7b4cb4592ea82416e60bcc64d;hb=b7365f756ee0d81d1d5b7286f09c9dfc5b6fe892;hp=b99e7dc813eea3fe8ece2a0e62a04194fc792b34;hpb=1e14f11b78c973963f9aafeb3ed8c1cd2f0f76f8;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index b99e7dc..6fb0f21 100755 --- a/bin/blhc +++ b/bin/blhc @@ -44,6 +44,14 @@ sub error_flags { error_color($message, 'red'), $flags, error_color(':', 'yellow'), $line; } +sub error_nonverbose_build { + my ($line) = @_; + + printf "%s%s %s", + error_color('NONVERBOSE BUILD', 'red'), + error_color(':', 'yellow'), + $line; +} sub error_color { my ($message, $color) = @_; @@ -87,7 +95,7 @@ sub pic_pie_conflict { my ($line, $pie, $missing_flags_ref, @flags_pie) = @_; return 0 if not $pie; - return 0 if not any_flags_used($line, ('-fPIC')); + return 0 if not any_flags_used($line, ('-fPIC', '-fpic')); my %flags = map { $_ => 1 } @flags_pie; @@ -107,6 +115,9 @@ sub pic_pie_conflict { # CONSTANTS/VARIABLES +# Regex to catch compiler commands. +my $cc_regex = qr/((?) { # Ignore compiler warnings for now. next if $line =~ /$warning_regex/; + # Try to detect non verbose build logs. + if ($line =~ /^checking if you want to see long compiling messages\.\.\. no/ + or $line =~ /^\s*(CC|CCLD)\s+/ + or $line =~ /^\s*(C|c)ompiling\s+/ + or $line =~ /^\s*\[[\d ]+%\] Building /) { + error_nonverbose_build($line); + $exit |= 1 << 2; + } + + # One line may contain multiple commands (";"). Treat each one as single # line. my @line = split /(?) { } else { # Ignore lines with no compiler commands. - next if $line !~ /\b(cc|gcc|g\+\+|c\+\+)(\s|\\)/; + next if $line !~ /\b$cc_regex(\s|\\)/; # Ignore false positives. # @@ -268,19 +289,22 @@ foreach my $line (@input) { # Ignore false positives. # # ./configure summary. - next if $line =~ /^Compiler:\s+(cc|gcc|g\+\+|c\+\+)$/; + next if $line =~ /^\s*(C|c)ompiler[\s.]*:\s+$cc_regex(\s-std=[a-z0-9:+]+)?\s*$/ + or $line =~ /^\s*- (CC|CXX)\s*=\s*$cc_regex\s*$/ + or $line =~ /^\s*-- Check for working (C|CXX) compiler: /; # Is this a compiler or linker command? my $compiler = 1; my $linker = 0; # Linker commands. - if ($line =~ m{\s-o # -o - [\s\\]*\s+ # possible line continuation - ([A-Za-z0-9_/.-]+/)? # path to file - [A-Za-z0-9_-]+ # binary name (no dots!) - (\.so([0-9.])*|\.la)? # library (including version) - (\s|\\|\$) # end of file name + if ($line =~ m{\s-o # -o + [\s\\]*\s+ # possible line continuation + ([A-Za-z0-9_/.-]+/)? # path to file + [A-Za-z0-9_-]+ # binary name (no dots!) + ([0-9.]*\.so[0-9.]*[a-z]? # library (including version) + |\.la)? + (\s|\\|\$) # end of file name }x or $line =~ /^libtool: link: / or $line =~ m{\s*/bin/bash .+?libtool\s+(.+?\s+)?--mode=(re)?link}) { @@ -301,17 +325,17 @@ foreach my $line (@input) { # with -fPIE as well. It's no error if only PIE flags are missing. and not pic_pie_conflict($line, $pie, \@missing, @cflags_pie)) { error_flags('CFLAGS missing', \@missing, \%flag_renames, $line); - $exit |= 1 << 2; + $exit |= 1 << 3; } if ($compiler and not all_flags_used($line, \@missing, @cppflags)) { error_flags('CPPFLAGS missing', \@missing, \%flag_renames, $line); - $exit |= 1 << 2; + $exit |= 1 << 3; } if ($linker and not all_flags_used($line, \@missing, @ldflags) # Same here, -fPIC conflicts with -fPIE. and not pic_pie_conflict($line, $pie, \@missing, @ldflags_pie)) { error_flags('LDFLAGS missing', \@missing, \%flag_renames, $line); - $exit |= 1 << 2; + $exit |= 1 << 3; } } @@ -392,6 +416,10 @@ Invalid arguments/options given to blhc. =item B<4> +Non verbose build. + +=item B<8> + Missing hardening flags. =back