summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2009-04-21 14:55:44 +0200
committerPetr Machata <pmachata@redhat.com>2009-04-21 14:47:39 +0200
commitb70557b7f8b506762fd98f7433a2ab5abf8288f2 (patch)
tree9affd58d9644eeba160511a7d0eaa3efa40ba81e
parent4925809503aca46986d7488e2914eba241165699 (diff)
downloadelfutils-b70557b7f8b506762fd98f7433a2ab5abf8288f2.tar.gz
dwarflint: Support aranges that fall into non-EXECINSTR sections
* ... warn about these though
-rw-r--r--src/dwarflint.c32
-rw-r--r--src/dwarflint.h9
2 files changed, 31 insertions, 10 deletions
diff --git a/src/dwarflint.c b/src/dwarflint.c
index d289ab06..b0b8ca7a 100644
--- a/src/dwarflint.c
+++ b/src/dwarflint.c
@@ -2143,7 +2143,8 @@ coverage_map_found_hole (uint64_t begin, uint64_t end,
are at least partially covered, we expect the same
coverage criteria as for .text. */
if (!sco->hit
- && (strcmp (scnname, ".init") == 0
+ && ((sco->sec->shdr.sh_flags & SHF_EXECINSTR) == 0
+ || strcmp (scnname, ".init") == 0
|| strcmp (scnname, ".fini") == 0
|| strcmp (scnname, ".plt") == 0))
return true;
@@ -2175,7 +2176,8 @@ coverage_map_found_hole (uint64_t begin, uint64_t end,
void
-section_coverage_init (struct section_coverage *sco, struct sec *sec)
+section_coverage_init (struct section_coverage *sco,
+ struct sec *sec, bool warn)
{
assert (sco != NULL);
assert (sec != NULL);
@@ -2183,12 +2185,15 @@ section_coverage_init (struct section_coverage *sco, struct sec *sec)
sco->sec = sec;
WIPE (sco->cov);
sco->hit = false;
+ sco->warn = warn;
}
bool
coverage_map_init (struct coverage_map *coverage_map,
struct elf_file *elf,
- Elf64_Xword mask, bool allow_overlap)
+ Elf64_Xword mask,
+ Elf64_Xword warn_mask,
+ bool allow_overlap)
{
assert (coverage_map != NULL);
assert (elf != NULL);
@@ -2201,11 +2206,13 @@ coverage_map_init (struct coverage_map *coverage_map,
{
struct sec *sec = elf->sec + i;
- if ((sec->shdr.sh_flags & mask) == mask)
+ bool normal = (sec->shdr.sh_flags & mask) == mask;
+ bool warn = (sec->shdr.sh_flags & warn_mask) == warn_mask;
+ if (normal || warn)
{
REALLOC (coverage_map, scos);
- section_coverage_init (coverage_map->scos + coverage_map->size++,
- sec);
+ section_coverage_init
+ (coverage_map->scos + coverage_map->size++, sec, !normal);
}
}
@@ -2280,6 +2287,12 @@ coverage_map_add (struct coverage_map *coverage_map,
overlap = true;
}
+ if (sco->warn)
+ wr_message (cat | mc_impact_2, where,
+ ": the range %#" PRIx64 "..%#" PRIx64
+ " covers section %s.\n",
+ address, end, sco->sec->name);
+
/* Section coverage... */
coverage_add (cov, cov_begin, cov_end - cov_begin);
sco->hit = true;
@@ -2302,7 +2315,7 @@ coverage_map_add (struct coverage_map *coverage_map,
wr_error (where,
": portion %#" PRIx64 "..%#" PRIx64
", of the range %#" PRIx64 "..%#" PRIx64
- " doesn't fall into any ALLOC & EXEC section.\n",
+ " doesn't fall into any ALLOC section.\n",
h_start + address, h_start + address + h_length - 1,
address, end);
return true;
@@ -3735,7 +3748,10 @@ static struct coverage_map *
coverage_map_alloc_XA (struct elf_file *elf, bool allow_overlap)
{
struct coverage_map *ret = xmalloc (sizeof (*ret));
- if (!coverage_map_init (ret, elf, SHF_ALLOC | SHF_EXECINSTR, allow_overlap))
+ if (!coverage_map_init (ret, elf,
+ SHF_EXECINSTR | SHF_ALLOC,
+ SHF_ALLOC,
+ allow_overlap))
{
free (ret);
return NULL;
diff --git a/src/dwarflint.h b/src/dwarflint.h
index bfd620a0..13997a86 100644
--- a/src/dwarflint.h
+++ b/src/dwarflint.h
@@ -179,6 +179,8 @@ extern "C"
struct sec *sec;
struct coverage cov;
bool hit; /* true if COV is not pristine. */
+ bool warn; /* dwarflint should emit a warning if a coverage
+ appears in this section */
};
struct coverage_map
@@ -191,10 +193,13 @@ extern "C"
size_t alloc;
};
- void section_coverage_init (struct section_coverage *sco, struct sec *sec);
+ void section_coverage_init (struct section_coverage *sco,
+ struct sec *sec, bool warn);
bool coverage_map_init (struct coverage_map *coverage_map,
struct elf_file *elf,
- Elf64_Xword mask, bool allow_overlap);
+ Elf64_Xword mask,
+ Elf64_Xword warn_mask,
+ bool allow_overlap);
void coverage_map_add (struct coverage_map *coverage_map,
uint64_t address, uint64_t length,
struct where *where, enum message_category cat);