]> sourceware.org Git - annobin.git/commitdiff
10.04: Annocheck: With gaps at the start/end of the .text section, check for special...
authorNick Clifton <nickc@redhat.com>
Wed, 15 Sep 2021 11:31:22 +0000 (12:31 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 15 Sep 2021 11:31:22 +0000 (12:31 +0100)
annobin-global.h
annocheck/hardened.c

index 1da97c6514f157e554df35c81fd985c6fead2152..bd7ee43526759f25072f66e4d961eb963266efe8 100644 (file)
@@ -19,7 +19,7 @@ extern "C" {
 /* The version of the package.
    NB/ This number is expected to be in the form "NNnn" where
    "NN" is major version number and "nn" is the minor version number.  */
-#define ANNOBIN_VERSION 1003
+#define ANNOBIN_VERSION 1004
 
 /* The version of the annotation specification supported.  */
 #define SPEC_VERSION  3
index cd74620e01fd8b8370691a8d605b3d833a313ac0..bde75534b90bb4437f2ceb091b20531370446975 100644 (file)
@@ -3887,7 +3887,7 @@ check_for_gaps (annocheck_data * data)
   /* FIXME: We should actually do this for every executable section.  */
   /* FIXME: we know that the PPC64 and S390 will put linker generated code at the start and/or
      end of the .text section, so we skip this next test.  Ideally we would have a way to detect
-     linker generated code...  */
+     linker generated code, such as detecting known stub function names...  */
   if (per_file.e_machine == EM_PPC64 || per_file.e_machine == EM_S390)
     {
       pass (data, TEST_NOTES, SOURCE_ANNOBIN_NOTES, "no gaps found");
@@ -3934,18 +3934,37 @@ check_for_gaps (annocheck_data * data)
        }
     }
 
-  /* FIXME _ SCAN FOR NOPS!  */
-  /* The AArch64 target can insert up to 0x3c bytes of padding...
-     cf BZ 1995224.  */
-  if ((per_file.text_section_range.end - per_file.text_section_range.start) > 0x3c
-      || (per_file.e_machine != EM_AARCH64 && (per_file.text_section_range.end > per_file.text_section_range.start)))
+  if (per_file.text_section_range.end > per_file.text_section_range.start)
     {
-      maybe (data, TEST_NOTES, SOURCE_ANNOBIN_NOTES, "not all of the .text section is covered by notes");
-      einfo (VERBOSE, "%s: debug: address range not covered: %lx..%lx",
-            get_filename (data), per_file.text_section_range.start, per_file.text_section_range.end);
+      const char * sym = annocheck_find_symbol_for_address_range (data, NULL, per_file.text_section_range.start,
+                                                                 per_file.text_section_range.end, false);
+
+      if (sym != NULL && skip_gap_sym (data, sym))
+       einfo (VERBOSE2, "gap ignored - special symbol: %s", sym);
+      else
+       {
+         ulong gap = per_file.text_section_range.end - per_file.text_section_range.start;
+
+         /* FIXME _ SCAN FOR NOPS!  */
+         /* The AArch64 target can insert up to 0x3c bytes of padding...
+            cf BZ 1995224.  */
+         if (gap > 0x3c || per_file.e_machine != EM_AARCH64)
+           {
+             maybe (data, TEST_NOTES, SOURCE_ANNOBIN_NOTES, "not all of the .text section is covered by notes");
+             if (sym != NULL)
+               einfo (VERBOSE, "%s: info: address range not covered: %lx..%lx (probable component: %s)",
+                      get_filename (data), per_file.text_section_range.start, per_file.text_section_range.end, sym);
+             else
+               einfo (VERBOSE, "%s: info: address range not covered: %lx..%lx",
+                      get_filename (data), per_file.text_section_range.start, per_file.text_section_range.end);                
+             return;
+           }
+         else
+           einfo (VERBOSE2, "small gap of %lx bytes ignored", gap);
+       }
     }
-  else
-    pass (data, TEST_NOTES, SOURCE_ANNOBIN_NOTES, "no gaps found");
+
+  pass (data, TEST_NOTES, SOURCE_ANNOBIN_NOTES, "no gaps found");
 }
 
 
This page took 0.058848 seconds and 5 git commands to generate.