-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlns.c
43 lines (33 loc) · 897 Bytes
/
dlns.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <pthread.h>
#include <elf.h>
#include <assert.h>
pthread_key_t local_pkey;
static __attribute__((noinline)) void pkey_destroy(void* p) {
fprintf(stderr, "called %s\n", __func__);
free(p);
}
int pause(void) {
fprintf(stderr, "called pause from dlns\n");
unsigned long* p = calloc(2, sizeof(long));
printf("calloc symbol resolved to %p\n", calloc);
printf("call calloc returned %p\n", p);
p[0] = 0x1234;
p[1] = 0x5678;
printf("free resolved to %p\n", free);
pthread_key_create(&local_pkey, pkey_destroy);
pthread_setspecific(local_pkey, p);
return syscall(SYS_pause);
}
__attribute__((constructor)) int dlns_init(void) {
fprintf(stderr, "dlns_init\n");
return 0;
}