|
@@ -381,20 +381,6 @@ struct map *map__clone(struct map *from)
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
-int map__overlap(struct map *l, struct map *r)
|
|
|
-{
|
|
|
- if (l->start > r->start) {
|
|
|
- struct map *t = l;
|
|
|
- l = r;
|
|
|
- r = t;
|
|
|
- }
|
|
|
-
|
|
|
- if (l->end > r->start)
|
|
|
- return 1;
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
size_t map__fprintf(struct map *map, FILE *fp)
|
|
|
{
|
|
|
return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
|
|
@@ -675,20 +661,42 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map)
|
|
|
static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
|
|
|
{
|
|
|
struct rb_root *root;
|
|
|
- struct rb_node *next;
|
|
|
+ struct rb_node *next, *first;
|
|
|
int err = 0;
|
|
|
|
|
|
down_write(&maps->lock);
|
|
|
|
|
|
root = &maps->entries;
|
|
|
- next = rb_first(root);
|
|
|
|
|
|
+ /*
|
|
|
+ * Find first map where end > map->start.
|
|
|
+ * Same as find_vma() in kernel.
|
|
|
+ */
|
|
|
+ next = root->rb_node;
|
|
|
+ first = NULL;
|
|
|
+ while (next) {
|
|
|
+ struct map *pos = rb_entry(next, struct map, rb_node);
|
|
|
+
|
|
|
+ if (pos->end > map->start) {
|
|
|
+ first = next;
|
|
|
+ if (pos->start <= map->start)
|
|
|
+ break;
|
|
|
+ next = next->rb_left;
|
|
|
+ } else
|
|
|
+ next = next->rb_right;
|
|
|
+ }
|
|
|
+
|
|
|
+ next = first;
|
|
|
while (next) {
|
|
|
struct map *pos = rb_entry(next, struct map, rb_node);
|
|
|
next = rb_next(&pos->rb_node);
|
|
|
|
|
|
- if (!map__overlap(pos, map))
|
|
|
- continue;
|
|
|
+ /*
|
|
|
+ * Stop if current map starts after map->end.
|
|
|
+ * Maps are ordered by start: next will not overlap for sure.
|
|
|
+ */
|
|
|
+ if (pos->start >= map->end)
|
|
|
+ break;
|
|
|
|
|
|
if (verbose >= 2) {
|
|
|
|