From 42b57fd5396d424483fb2856a3f2abc6ffae2fc4 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 10 Sep 2016 18:09:43 +0200 Subject: [PATCH] Fix another Ada false positive for format flags --- NEWS | 2 ++ bin/blhc | 21 ++++++++++++++------- t/logs/ada | 6 ++++++ t/logs/ada-pbuilder | 6 ++++++ t/tests.t | 8 +++++--- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 2f964cb..26a487e 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ Version 0.XX - Sync architecture specific hardening support with dpkg 1.18.10. - Fix false positive in "gcc > file" (Debian Bug #828789), reported by Mathieu Parent. +- Fix another Ada false positive for format flags (Debian Bug #833939), + reported by Nicolas Boulenguez. Version 0.06 diff --git a/bin/blhc b/bin/blhc index c4e814c..1e77495 100755 --- a/bin/blhc +++ b/bin/blhc @@ -89,10 +89,10 @@ my @source_no_preprocess_compile_cpp = ( qw( mii ), ); my @source_no_preprocess_compile_ada = ( + # Ada source + qw( ada ), # Ada body qw( adb ), - # If you add another file, fix use of @source_no_preprocess_compile_ada - # below (search for $compile_ada). ); my @source_no_preprocess_compile = ( # C @@ -106,11 +106,15 @@ my @source_no_preprocess_compile = ( # Ada @source_no_preprocess_compile_ada, ); +my @source_no_preprocess_no_compile_ada = ( + # Ada specification + qw( ads ), +); my @source_no_preprocess_no_compile = ( # Assembly qw( s ), - # Ada specification - qw( ads ), + # Ada + @source_no_preprocess_no_compile_ada, ); my @source_no_preprocess = ( @source_no_preprocess_compile, @@ -161,6 +165,10 @@ my %extensions_compile_cpp = map { $_ => 1 } ( @source_preprocess_compile_cpp, @source_no_preprocess_compile_cpp, ); +my %extensions_ada = map { $_ => 1 } ( + @source_no_preprocess_compile_ada, + @source_no_preprocess_no_compile_ada, +); my %extensions_object = map { $_ => 1 } ( @object, ); @@ -1230,10 +1238,9 @@ LINE: $compile_cpp = 1; # Ada needs special CFLAGS, use them if only ada files are compiled. } elsif ($ada - and $compile - and array_equal(\@extensions, - \@source_no_preprocess_compile_ada)) { + and extension_found(\%extensions_ada, @extensions)) { $compile_ada = 1; + $preprocess = 0; # Ada uses no CPPFLAGS @cflags_backup = @cflags; @cflags = @cflags_ada; } diff --git a/t/logs/ada b/t/logs/ada index c6f45fb..8e6c596 100644 --- a/t/logs/ada +++ b/t/logs/ada @@ -14,3 +14,9 @@ gcc-4.6 -c -fPIC -g -O2 -fstack-protector-strong -gnatn -gnatw.eH test-d.ads gcc -c -g -O2 test.c gcc -g -O2 test.c + +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -fstack-protector-strong -gnat2005 -gnato -gnatVa -fstack-check -gnatw.I -I- -o /«PKGBUILDDIR»/build/objects/arm_frm.o /«PKGBUILDDIR»/progs/arm_frm.adb +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -fstack-protector-strong -gnat2005 -gnato -gnatVa -fstack-check -I- -x ada -o /«PKGBUILDDIR»/build/objects/arm_form.o /«PKGBUILDDIR»/progs/arm_form.ada + +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -gnatw.I -I- -o /«PKGBUILDDIR»/build/objects/arm_frm.o /«PKGBUILDDIR»/progs/arm_frm.adb +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -I- -x ada -o /«PKGBUILDDIR»/build/objects/arm_form.o /«PKGBUILDDIR»/progs/arm_form.ada diff --git a/t/logs/ada-pbuilder b/t/logs/ada-pbuilder index a6f4d3b..9c75d30 100644 --- a/t/logs/ada-pbuilder +++ b/t/logs/ada-pbuilder @@ -15,3 +15,9 @@ gcc-4.6 -c -fPIC -g -O2 -fstack-protector-strong -gnatn -gnatw.eH test-d.ads gcc -c -g -O2 test.c gcc -g -O2 test.c + +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -fstack-protector-strong -gnat2005 -gnato -gnatVa -fstack-check -gnatw.I -I- -o /«PKGBUILDDIR»/build/objects/arm_frm.o /«PKGBUILDDIR»/progs/arm_frm.adb +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -fstack-protector-strong -gnat2005 -gnato -gnatVa -fstack-check -I- -x ada -o /«PKGBUILDDIR»/build/objects/arm_form.o /«PKGBUILDDIR»/progs/arm_form.ada + +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -gnatw.I -I- -o /«PKGBUILDDIR»/build/objects/arm_frm.o /«PKGBUILDDIR»/progs/arm_frm.adb +gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -I- -x ada -o /«PKGBUILDDIR»/build/objects/arm_form.o /«PKGBUILDDIR»/progs/arm_form.ada diff --git a/t/tests.t b/t/tests.t index 8050601..bd54050 100644 --- a/t/tests.t +++ b/t/tests.t @@ -751,11 +751,13 @@ LDFLAGS missing (-fPIE -pie -Wl,-z,relro -Wl,-z,now): g++-4.6 -Wl,-z,defs -o tes my $ada = 'CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc-4.6 -c -fPIC -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security test.c LDFLAGS missing (-Wl,-z,relro): /usr/bin/gcc-4.6 -shared -lgnat-4.6 -o libtest.so.2 test-a.o test-b.o test-c.o -Wl,--as-needed -CFLAGS missing (-fstack-protector-strong -Wformat -Werror=format-security): gcc -c -g -O2 test.c +CFLAGS missing (-fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc -c -g -O2 test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c -g -O2 test.c -CFLAGS missing (-fstack-protector-strong -Wformat -Werror=format-security): gcc -g -O2 test.c +CFLAGS missing (-fPIE -fstack-protector-strong -Wformat -Werror=format-security): gcc -g -O2 test.c CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 test.c -LDFLAGS missing (-Wl,-z,relro): gcc -g -O2 test.c +LDFLAGS missing (-fPIE -pie -Wl,-z,relro): gcc -g -O2 test.c +CFLAGS missing (-fstack-protector-strong): gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -gnatw.I -I- -o /«PKGBUILDDIR»/build/objects/arm_frm.o /«PKGBUILDDIR»/progs/arm_frm.adb +CFLAGS missing (-fstack-protector-strong): gcc-6 -c -I./ -I../progs -g -O2 -fPIE -gnat2005 -gnato -gnatVa -fstack-check -I- -x ada -o /«PKGBUILDDIR»/build/objects/arm_form.o /«PKGBUILDDIR»/progs/arm_form.ada '; is_blhc 'ada', '', 8, $ada; -- 2.43.2