diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2023-08-06 17:10:44 +0000 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2023-08-08 13:27:17 -0700 |
commit | 3ce3dd8ca965209b42660d943a3e9c8c662913fe (patch) | |
tree | c2e33d6a5f41bb86ba1d209e0a8ee37cc61e0d86 /linux-user/elfload.c | |
parent | 5f4e5b34092556ab1577e25d1262bd5975b26980 (diff) |
util/selfmap: Rewrite using qemu/interval-tree.h
We will want to be able to search the set of mappings.
For this patch, the two users iterate the tree in order.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r-- | linux-user/elfload.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e72497c4b4..fb137345f6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2620,7 +2620,8 @@ static uintptr_t pgd_find_hole_fallback(uintptr_t guest_size, uintptr_t brk, static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_size, long align, uintptr_t offset) { - GSList *maps, *iter; + IntervalTreeRoot *maps; + IntervalTreeNode *iter; uintptr_t this_start, this_end, next_start, brk; intptr_t ret = -1; @@ -2638,12 +2639,15 @@ static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_size, /* The first hole is before the first map entry. */ this_start = mmap_min_addr; - for (iter = maps; iter; - this_start = next_start, iter = g_slist_next(iter)) { + for (iter = interval_tree_iter_first(maps, 0, -1); + iter; + this_start = next_start, + iter = interval_tree_iter_next(iter, 0, -1)) { + MapInfo *info = container_of(iter, MapInfo, itree); uintptr_t align_start, hole_size; - this_end = ((MapInfo *)iter->data)->start; - next_start = ((MapInfo *)iter->data)->end; + this_end = info->itree.start; + next_start = info->itree.last + 1; align_start = ROUND_UP(this_start + offset, align); /* Skip holes that are too small. */ |