1 /* Test case for early TLS initialization in dynamic linker. */
8 #define MAGIC1 0xabcdef72
9 #define MAGIC2 0xd8675309
10 static __thread
unsigned int magic
[] = { MAGIC1
, MAGIC2
};
11 static __thread
int calloc_called
;
15 /* This calloc definition will be called by the dynamic linker itself.
16 We test that interposed calloc is called by the dynamic loader, and
17 that TLS is fully initialized by then. */
20 calloc (size_t n
, size_t m
)
24 /* Allow our calloc to be called more than once. */
26 if (magic
[0] != MAGIC1
|| magic
[1] != MAGIC2
)
28 printf ("{%x, %x} != {%x, %x}\n",
29 magic
[0], magic
[1], MAGIC1
, MAGIC2
);
37 void *ptr
= malloc (n
);
39 memset (ptr
, '\0', n
);
46 /* Make sure that our calloc is called from the dynamic linker at least
48 void *h
= dlopen("$ORIGIN/tst-auditmod9b.so", RTLD_LAZY
);
51 if (magic
[1] != MAGIC1
|| magic
[0] != MAGIC2
)
53 printf ("{%x, %x} != {%x, %x}\n", magic
[0], magic
[1], MAGIC2
, MAGIC1
);
60 #include <support/test-driver.c>