[PATCH] elf: allow anonymous mapping in gap for tst-link-map-contiguous-ldso
Xi Ruoyao
xry111@xry111.site
Mon Jan 19 10:03:47 GMT 2026
The initialization process of libc.so creates several anonymous mappings
and the kernel may lay them into the gap. If all pages in the gap are
occupied, the test would fail.
The failure reproduces most frequently on LoongArch because with the
commonly used page size (16 KiB) the gap only contains 4 pages and the
probability they are all occupied is not near to zero. With the changes
in the patch, a test run outputs:
info: ld.so link map is not contiguous
info: anonymous map found at 0x7ffff1c60000
info: anonymous map found at 0x7ffff1c64000
info: anonymous map found at 0x7ffff1c68000
info: anonymous map found at 0x7ffff1c6c000
But this is not really a LoongArch-only issue, on an AArch64 (with 4 KiB
pages) with those changes a test run outputs:
info: ld.so link map is not contiguous
info: hole without mapping data found at 0xffffbea08000
info: hole without mapping data found at 0xffffbea09000
/* snip */
info: hole without mapping data found at 0xffffbea17000
info: anonymous map found at 0xffffbea18000
info: anonymous map found at 0xffffbea19000
info: anonymous map found at 0xffffbea1a000
info: anonymous map found at 0xffffbea1b000
info: object "linux-vdso.so.1" found at 0xffffbea1c000
info: anonymous map found at 0xffffbea1d000
info: anonymous map found at 0xffffbea1e000
AFAIK there seems nothing to prevent the kernel from creating the
anonymous mappings in the gap, so we should just allow them (at least
for now, after the 2.43 release we may develop a way to stop it if we
really need).
Also take the chance to fix a mistake in the "object found at" message
which has puzzled me during the initial debug session.
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
elf/tst-link-map-contiguous-ldso.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/elf/tst-link-map-contiguous-ldso.c b/elf/tst-link-map-contiguous-ldso.c
index 9f97b8b95a..4d29a19a1c 100644
--- a/elf/tst-link-map-contiguous-ldso.c
+++ b/elf/tst-link-map-contiguous-ldso.c
@@ -64,12 +64,16 @@ do_test (void)
if ((void *) dlfo.dlfo_link_map != (void *) l)
{
printf ("info: object \"%s\" found at %p\n",
- dlfo.dlfo_link_map->l_name, ptr);
+ dlfo.dlfo_link_map->l_name, expected);
gap_found = true;
}
}
else
- TEST_COMPARE (dlfo_ret, -1);
+ {
+ TEST_COMPARE (dlfo_ret, -1);
+ printf ("info: anonymous map found at %p\n", expected);
+ gap_found = true;
+ }
xmunmap (ptr, 1);
addr += pagesize;
}
--
2.52.0
More information about the Libc-alpha
mailing list