Commit | Line | Data |
---|---|---|
241e64e3 L |
1 | #include <unistd.h> |
2 | #include <link.h> | |
3 | #include <syscall.h> | |
4 | ||
5 | #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1) | |
6 | ||
7 | int | |
8 | main (int argc, char **argv) | |
9 | { | |
10 | char **ev = &argv[argc + 1]; | |
11 | char **evp = ev; | |
12 | ElfW(auxv_t) *av; | |
13 | const ElfW(Phdr) *phdr = NULL; | |
14 | size_t phnum = 0; | |
15 | size_t loadnum = 0; | |
16 | int fd = STDOUT_FILENO; | |
17 | size_t i; | |
18 | ||
19 | while (*evp++ != NULL) | |
20 | ; | |
21 | ||
22 | av = (ElfW(auxv_t) *) evp; | |
23 | ||
24 | for (; av->a_type != AT_NULL; ++av) | |
25 | switch (av->a_type) | |
26 | { | |
27 | case AT_PHDR: | |
28 | phdr = (const void *) av->a_un.a_val; | |
29 | break; | |
30 | case AT_PHNUM: | |
31 | phnum = av->a_un.a_val; | |
32 | break; | |
33 | } | |
34 | ||
35 | for (i = 0; i < phnum; i++, phdr++) | |
36 | if (phdr->p_type == PT_LOAD) | |
37 | loadnum++; | |
38 | ||
39 | syscall (SYS_write, fd, STRING_COMMA_LEN ("PASS\n")); | |
40 | ||
41 | syscall (SYS_exit, !loadnum); | |
42 | return 0; | |
43 | } |