aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/tst-leaks1.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/elf/tst-leaks1.c b/elf/tst-leaks1.c
index d67e8269c4..75bc92d25f 100644
--- a/elf/tst-leaks1.c
+++ b/elf/tst-leaks1.c
@@ -6,13 +6,28 @@
static int
do_test (void)
{
+ void *h;
+ int ret = 0;
+ /* Carry out *one* failing call to dlopen before starting mtrace to
+ force any one-time inintialization that may happen to the
+ executable link map e.g. expansion and caching of $ORIGIN. */
+ h = dlopen ("$ORIGIN/tst-leaks1.o", RTLD_LAZY);
+ if (h != NULL)
+ {
+ puts ("dlopen unexpectedly succeeded");
+ ret = 1;
+ dlclose (h);
+ }
+
+ /* Start tracing and run each test 5 times to see if there are any
+ leaks in the failing dlopen. */
mtrace ();
- int ret = 0;
for (int i = 0; i < 10; i++)
{
- void *h = dlopen (i < 5 ? "./tst-leaks1.c"
- : "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
+ h = dlopen (i < 5
+ ? "./tst-leaks1.c"
+ : "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
if (h != NULL)
{
puts ("dlopen unexpectedly succeeded");