]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Fix bug in coverage analysis
authorPetr Machata <pmachata@redhat.com>
Fri, 27 Mar 2009 15:43:42 +0000 (16:43 +0100)
committerPetr Machata <pmachata@redhat.com>
Fri, 27 Mar 2009 15:39:42 +0000 (16:39 +0100)
src/dwarflint.c

index e25e1a0497290143b09fcfa15cfdc7274cf4954f..c130db9be5491a3406c821a9bf65c521d7305d9f 100644 (file)
@@ -2270,7 +2270,7 @@ coverage_map_add (struct coverage_map *coverage_map,
       struct coverage *cov = &sco->cov;
 
       Elf64_Addr s_end = shdr->sh_addr + shdr->sh_size;
-      if (end < shdr->sh_addr || address >= s_end)
+      if (end <= shdr->sh_addr || address >= s_end)
        /* no overlap */
        continue;
 
@@ -2286,12 +2286,17 @@ coverage_map_add (struct coverage_map *coverage_map,
 
       found = true;
 
+      if (end == address)
+       /* Empty range.  That means no actual coverage, and we can
+          also be sure that there are no more sections that this one
+          falls into.  */
+       break;
+
       uint64_t cov_begin
        = address < shdr->sh_addr ? 0 : address - shdr->sh_addr;
       uint64_t cov_end
        = (end < s_end ? end - shdr->sh_addr
-          : shdr->sh_size - 1); /* -1 because coverage
-                                   endpoint is inclusive.  */
+          : shdr->sh_size) - 1; /* -1 because cov_end is inclusive.  */
       assert (cov_begin <= cov_end);
 
       uint64_t r_cov_begin = cov_begin + shdr->sh_addr - address;