]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Beef up the check_headers_and_includes script to make sure
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 30 Sep 2015 20:58:36 +0000 (20:58 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 30 Sep 2015 20:58:36 +0000 (20:58 +0000)
every assembler file instantiates MARK_STACK_NO_EXEC unconditionally.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15694

tests/check_headers_and_includes

index b154f416e7442a3d5a9d0cc32d1212f5910f031d..47491b2597dcb8fca4982241679884839641cbba 100755 (executable)
 # (7) include/*.h and tool *.[ch] must not use vg_assert
 # (8) coregrind/ *.[ch] must not use VG_(tool_panic)
 # (9) include/*.h and tool *.[ch] must not use VG_(core_panic)
+# (10) *.S must unconditionally instantiate MARK_STACK_NO_EXEC
+#
+# There can be false positives as we don't really parse the source files.
+# Instead we only match regular expressions.
 #-------------------------------------------------------------------
 
 use strict;
@@ -144,8 +148,8 @@ sub process_dir {
             next;
         }
 
-# Regular files; only interested in *.c and *.h
-        next if (! ($file =~ /\.[ch]$/));
+# Regular files; only interested in *.c, *.S and *.h
+        next if (! ($file =~ /\.[cSh]$/));
         my $path_name = defined $path ? "$path/$file" : $file;
         process_file($path_name);
     }
@@ -306,6 +310,36 @@ sub check_tool_file {
     }
 }
 
+#---------------------------------------------------------------------
+# Check an assembler file
+#---------------------------------------------------------------------
+sub check_assembler_file {
+    my ($path_name) = @_;
+    my $file = basename($path_name);
+    my $found = 0;
+
+    open(FILE, "<$file") || die "Cannot open file '$file'";
+
+    while (my $line = <FILE>) {
+        if ($line =~ /^\s*MARK_STACK_NO_EXEC/) {
+            $found = 1;
+            last;
+        }
+    }
+    if ($found == 0) {
+        error("File $path_name does not instantiate MARK_STACK_NO_EXEC\n");
+    } else {
+        while (my $line = <FILE>) {
+            if ($line =~ /^\s*#\s*endif/) {
+                error("File $path_name instantiates MARK_STACK_NO_EXEC"
+                      . " under a condition\n");
+                last;
+            }
+        }
+    }
+    close FILE;
+}
+
 sub process_file {
     my ($path_name) = @_;
 
@@ -318,6 +352,10 @@ sub process_file {
     } elsif (is_tool_file($path_name)) {
         check_tool_file($path_name);
     }
+
+    if ($path_name =~ /\.S$/) {
+        check_assembler_file($path_name);
+    }
 }
 
 sub error {