From: Petr Machata Date: Fri, 27 Mar 2009 15:43:42 +0000 (+0100) Subject: dwarflint: Fix bug in coverage analysis X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91cf88243fc9690d3e202de4af11bd172ef35fd4;p=thirdparty%2Felfutils.git dwarflint: Fix bug in coverage analysis --- diff --git a/src/dwarflint.c b/src/dwarflint.c index e25e1a049..c130db9be 100644 --- a/src/dwarflint.c +++ b/src/dwarflint.c @@ -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;