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;
} else {
# Ignore lines with no compiler commands.
- next if $line !~ /\b(cc\b|gcc\b|g\+\+|c\+\+)/;
+ next if $line !~ /\b(cc|gcc|g\+\+|c\+\+)(\s|\\)/;
# Ignore false positives.
#
}
foreach my $line (@input) {
+ # Ignore false positives.
+ #
+ # ./configure summary.
+ next if $line =~ /^Compiler:\s+(cc|gcc|g\+\+|c\+\+)$/;
+
# Is this a compiler or linker command?
my $compiler = 1;
my $linker = 0;
# Linker commands.
- if ($line =~ /\s-l[A-Za-z0-9.-]+(\s|\\|$)/
+ 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+--tag=CC\s+--mode=link}) {
+ or $line =~ m{\s*/bin/bash .+?libtool\s+(.+?\s+)?--mode=(re)?link}) {
$compiler = 0;
$linker = 1;
}