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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
# See ltrace.conf(5) for description of syntax of this file.
# XXX ltrace misses long double and long long support
typedef ldouble = double;
typedef llong = long;
typedef ullong = ulong;
void __libc_start_main(hide(void*), hide(int), array(string, arg2));
# arpa/inet.h
typedef in_addr = struct(hex(uint));
int inet_aton(string, +in_addr*);
hex(uint) inet_addr(string);
hex(uint) inet_network(string);
string inet_ntoa(in_addr);
in_addr inet_makeaddr(hex(int), hex(int));
hex(uint) inet_lnaof(in_addr);
hex(uint) inet_netof(in_addr);
# bfd.h
void bfd_init();
int bfd_set_default_target(string);
addr bfd_scan_vma(string, addr, int);
addr bfd_openr(string,string);
int bfd_check_format(addr,int);
# ctype.h
char tolower(char);
char toupper(char);
addr __ctype_b_loc();
addr __ctype_tolower_loc();
addr __ctype_toupper_loc();
ulong __ctype_get_mb_cur_max();
# curses.h
int waddch(addr, char);
int mvprintw(int, int, format);
int wmove(addr, int, int);
int waddnstr(addr, string, int);
string tgoto(string, int, int);
# dirent.h
# We can't portably rely on DIR internals at all. Ideally this would
# be implemented in a per-OS config file, but even on Linux, we don't
# know whether there's a lock in the structure or not. Luckily the
# one interesting datum, file descriptor, we can access reliably.
# Having the structure half-defined like this is potentially
# problematic as structure size influences parameter passing. But
# POSIX always uses pointer to the structure, so it's fine.
typedef DIR = struct(int);
typedef FILE = addr;
# XXX We can't represent the following portably without having either
# uulong, or directly uint64_t.'
typedef ino_t = ulong;
typedef ino_t64 = ulong;
typedef off_t = ulong;
typedef off_t64 = ulong;
typedef dirent = struct(ino_t, hide(off_t), hide(ushort), hide(char), string(array(char, zero(256))));
typedef dirent64 = struct(ino_t64, hide(off_t64), hide(ushort), hide(char), string(array(char, zero(256))));
dirent *readdir(DIR *);
dirent64 *readdir64(DIR *);
int closedir(DIR *);
DIR *opendir(string);
DIR *fdopendir(int);
int dirfd(DIR *);
void rewinddir(DIR *);
long telldir(DIR *);
void seekdir(DIR *, long);
# dlfcn.h
addr dlopen(string, int);
string dlerror();
addr dlsym(addr, string);
int dlclose(addr);
# errno.h
addr __errno_location();
# fcntl.h
int open(string,int,octal); ; WARNING: 3rd argument may not be there
int open64(string,int,octal); ; WARNING: 3rd argument may not be there
# fnmatch.h
int fnmatch(string, string, int);
# getopt.h
int getopt_long(int,addr,string,addr,int*);
int getopt_long_only(int,addr,string,addr,addr);
# grp.h
void endgrent();
addr getgrnam(string);
void setgrent();
addr getgrent();
# libintl.h
string __dcgettext(string,string,int);
string bindtextdomain(string, string);
string textdomain(string);
# libio.h
char _IO_getc(file);
int _IO_putc(char,file);
# locale.h
string setlocale(enum(LC_CTYPE=0, LC_NUMERIC=1, LC_TIME=2, LC_COLLATE=3, LC_MONETARY=4, LC_MESSAGES=5, LC_ALL=6, LC_PAPER=7, LC_NAME=8, LC_ADDRESS=9, LC_TELEPHONE=10, LC_MEASUREMENT=11, LC_IDENTIFICATION=12), string);
# mcheck.h
void mtrace();
void muntrace();
# mqueue.h
int mq_open(string, int, octal, addr); ; WARNING: 3rd and 4th arguments may not be there
int mq_close(int);
int mq_unlink(string);
int mq_getattr(int, addr);
int mq_setattr(int, addr, addr);
int mq_notify(int, addr);
int mq_send(int, string3, ulong, uint);
int mq_timedsend(int, string3, ulong, uint, addr);
long mq_receive(int, +string0, ulong, addr);
long mq_timedreceive(int, +string0, ulong, addr, addr);
# netdb.h
void endhostent();
void endnetent();
void endnetgrent();
void endprotoent();
void endservent();
void freeaddrinfo(addr);
string gai_strerror(int);
int getaddrinfo(string, string, addr, addr);
addr gethostbyaddr(string, uint, int);
addr gethostbyname(string);
addr gethostent();
int getnameinfo(addr, uint, string, uint, string, uint, uint);
addr getnetbyaddr(uint, int);
addr getnetbyname(string);
addr getnetent();
int getnetgrent(addr, addr, addr);
addr getprotobyname(string);
addr getprotobynumber(int);
addr getprotoent();
addr getservbyname(string, string);
addr getservbyport(int, string);
addr getservent();
void herror(string);
string hstrerror(int);
int rcmd(addr, ushort, string, string, string, addr);
int rcmd_af(addr, ushort, string, string, string, addr, int);
int rexec(addr, int, string, string, string, addr);
int rexec_af(addr, int, string, string, string, addr, int);
int rresvport (addr);
int rresvport_af (addr, int);
int ruserok(string, int, string, string);
int ruserok_af(string, int, string, string, int);
void sethostent(int);
void setnetent(int);
int setnetgrent(string);
void setprotoent(int);
void setservent(int);
# netinet/in.h
uint ntohs(uint);
# pcap.h
string pcap_lookupdev(addr);
addr pcap_open_live(string, int, int, int, addr);
int pcap_snapshot(addr);
int pcap_lookupnet(string, addr, addr, addr);
int pcap_compile(addr, addr, string, int, addr);
# pwd.h
string getpass(string);
void endpwent();
addr getpwnam(string);
void setpwent();
# readline/readline.h
string readline(string);
# signal.h
typedef signum = enum(SIGHUP=1, SIGINT=2, SIGQUIT=3, SIGILL=4, SIGTRAP=5, SIGABRT=6, SIGBUS=7, SIGFPE=8, SIGKILL=9, SIGUSR1=10, SIGSEGV=11, SIGUSR2=12, SIGPIPE=13, SIGALRM=14, SIGTERM=15, SIGSTKFLT=16, SIGCHLD=17, SIGCONT=18, SIGSTOP=19, SIGTSTP=20, SIGTTIN=21, SIGTTOU=22, SIGURG=23, SIGXCPU=24, SIGXFSZ=25, SIGVTALRM=26, SIGPROF=27, SIGWINCH=28, SIGIO=29, SIGPWR=30, SIGSYS=31, SIGRTMIN_0=32, SIGRTMIN_1=33, SIGRTMIN_2=34, SIGRTMIN_3=35, SIGRTMIN_4=36, SIGRTMIN_5=37, SIGRTMIN_6=38, SIGRTMIN_7=39, SIGRTMIN_8=40, SIGRTMIN_9=41, SIGRTMIN_10=42, SIGRTMIN_11=43, SIGRTMIN_12=44, SIGRTMIN_13=45, SIGRTMIN_14=46, SIGRTMIN_15=47, SIGRTMIN_16=48, SIGRTMIN_17=49, SIGRTMIN_18=50, SIGRTMIN_19=51, SIGRTMIN_20=52, SIGRTMIN_21=53, SIGRTMIN_22=54, SIGRTMIN_23=55, SIGRTMIN_24=56, SIGRTMIN_25=57, SIGRTMIN_26=58, SIGRTMIN_27=59, SIGRTMIN_28=60, SIGRTMIN_29=61, SIGRTMIN_30=62, SIGRTMIN_31=63);
typedef sigset_t = bitvec(ulong);
# elm3 should be flags
typedef sigaction = struct(addr, sigset_t, hex(int), addr);
int kill(int, signum);
int sigemptyset(+sigset_t*);
int sigaddset(+sigset_t*, signum);
int sigdelset(+sigset_t*, signum);
int sigfillset(+sigset_t*);
int sigismember(sigset_t*, signum);
addr signal(signum,addr);
int sigaction(signum, sigaction*, +sigaction*);
int sigprocmask(enum(SIG_BLOCK=1, SIG_UNBLOCK=2, SIG_SETMASK=3), sigset_t*, +sigset_t*);
int sigpending(+sigset_t*);
int sigsuspend(sigset_t*);
int sigisemptyset(sigset_t*);
int sigorset(+sigset_t*, sigset_t*, sigset_t*);
int sigandset(+sigset_t*, sigset_t*, sigset_t*);
# stdio.h
int fclose(file);
int feof(file);
int ferror(file);
int fflush(file);
char fgetc(file);
addr fgets(+string, int, file);
int fileno(file);
file fopen(string,string);
file fopen64(string,string);
file fdopen(int, string);
int fprintf(file,format);
int fputc(char,file);
int fputs(string,file);
ulong fread(addr,ulong,ulong,file);
ulong fread_unlocked(addr,ulong,ulong,file);
ulong fwrite(string,ulong,ulong,file);
ulong fwrite_unlocked(string,ulong,ulong,file);
int pclose(addr);
void perror(string);
addr popen(string, string);
int printf(format);
int puts(string);
int remove(string);
int snprintf(+string2,ulong,format);
int sprintf(+string,format);
string tempnam(string,string);
int vfprintf(file,string,addr);
int vsnprintf(+string2,ulong,string,addr);
int setvbuf(file,addr,int,ulong);
void setbuf(file,addr);
void setbuffer(file,addr,ulong);
void setlinebuf(file);
int rename(string,string);
# xlocale.h
typedef locale_t = void*;
locale_t newlocale(hex(int), string, locale_t);
# stdlib.h
long __strtol_internal(string, +string*, int);
ulong __strtoul_internal(string, +string*, int);
double strtod(string, +string*);
float strtof(string, +string*);
ldouble strtold(string, +string*);
double strtod_l(string, +string*, locale_t);
float strtof_l(string, +string*, locale_t);
ldouble strtold_l(string, +string*, locale_t);
int atexit(addr);
addr bsearch(string, addr, ulong, ulong, addr);
addr calloc(ulong, ulong);
void exit(int);
void free(addr);
string getenv(string);
int putenv(string);
int setenv(string,string,int);
void unsetenv(string);
addr malloc(ulong);
void qsort(addr,ulong,ulong,addr);
addr realloc(addr,ulong);
int system(string);
int rand();
int rand_r(uint*);
void srand(uint);
long random();
void srandom(uint);
void* initstate(uint, void*, ulong);
void* setstate(void*);
int random_r(void*, +int*);
int srandom_r(uint, void*);
int initstate_r(uint, void*, ulong, void*);
int setstate_r(void*, void*);
double drand48();
double erand48(+array(ushort,3)*);
long lrand48();
long nrand48(+array(ushort,3)*);
long mrand48();
long jrand48(+array(ushort,3)*);
void srand48(long);
array(ushort,3)* seed48(array(ushort,3)*);
void lcong48(array(ushort,7)*);
# string.h
void bcopy(addr,addr,ulong);
void bzero(addr,ulong);
string basename(string);
string index(string,char);
addr memchr(string,char,ulong);
addr memcpy(addr,string(array(char, arg3)*),ulong);
addr memmove(addr,string(array(char, arg3)*),ulong);
addr memset(addr,char,long);
string rindex(string,char);
addr stpcpy(addr,string);
int strcasecmp(string, string);
string strcat(string, string);
string strchr(string,char);
int strcoll(string,string);
ulong strlen(string);
int strcmp(string,string);
addr strcpy(addr,string);
addr strdup(string);
string strerror(int);
int strncmp(string,string,ulong);
addr strncpy(addr,string3,ulong);
string strrchr(string,char);
string strsep(addr,string);
ulong strspn(string,string);
ulong strcspn(string,string);
string strstr(string,string);
string strtok(string, string);
# sys/ioctl.h
int ioctl(int, int, addr);
# sys/socket.h
int socket(int,int,int);
# sys/stat.h
int __fxstat(int,int,addr);
int __xstat(int,string,addr);
int __lxstat(int,string,addr);
int __fxstat64(int,int,addr);
int __xstat64(int,string,addr);
int __lxstat64(int,string,addr);
int chmod(string,octal);
int fchmod(int,octal);
int mkfifo(string,octal);
octal umask(octal);
# sys/utsname.h
int uname(addr);
# sys/vfs.h
int statfs(string,addr);
# syslog.h
void closelog();
void openlog(string,int,int);
void syslog(int,format);
# term.h
int tputs(string, int, addr);
# termios.h
int tcgetattr(int,addr);
int tcsetattr(int,int,addr);
# time.h
string ctime(addr);
int gettimeofday(addr, addr);
addr gmtime(addr);
addr localtime(addr);
ulong strftime(+string2,ulong,string,addr);
long time(addr);
# XXX in fact (time_t, long), which may be (llong, long) on 32-bit
# arches. We don't have llong as of this writing.
typedef timespec = struct(long, long);
int nanosleep(timespec*, timespec*);
# unistd.h
void _exit(int);
int access(string, int);
uint alarm(uint);
int chdir(string);
int chown(string,int,int);
int close(int);
string crypt(string,string);
int dup2(int,int);
int execlp(string,string,addr,addr,addr);
int execv(string,addr);
int fchdir(int);
int fork();
int ftruncate(int,ulong);
string2 getcwd(addr,ulong);
int getdomainname(+string2,ulong);
int geteuid();
int getegid();
int getgid();
int gethostname(+string2,ulong);
string getlogin();
int getopt(int,addr,string);
int getpid();
int getppid();
int getuid();
int getpgrp();
int setpgrp();
int getpgid(int);
int isatty(int);
int link(string,string);
int mkdir(string,octal);
long read(int, +string[retval], ulong);
int rmdir(string);
int seteuid(uint);
int setgid(int);
int sethostname(+string2,ulong);
int setpgid(int,int);
int setreuid(uint, uint);
int setuid(int);
uint sleep(uint);
int symlink(string,string);
int sync();
int truncate(string,ulong);
string ttyname(int);
int unlink(string);
void usleep(uint);
long write(int, string3, ulong);
addr sbrk(long);
int getpagesize();
long lseek(int,long,int);
int pipe(addr);
# utmp.h
void endutent();
addr getutent();
void setutent();
# wchar.h
typedef wchar_t = string(uint);
typedef wint_t = string(int);
typedef wstring_t = string(array(uint, zero)*);
typedef wstring2_t = string(array(uint, zero(arg2))*);
typedef wstring3_t = string(array(uint, zero(arg3))*);
int fwide(FILE*, int);
wint_t btowc(int);
wint_t getwc(FILE *);
wint_t getwchar();
wint_t fgetwc(FILE*);
wstring_t fgetws(+wstring2_t, int, FILE*);
wint_t ungetwc(wint_t, FILE*);
wint_t fputwc(wchar_t, FILE*);
int fputws(wstring_t, FILE*);
wint_t putwc(wchar_t, FILE*);
wint_t putwchar(wchar_t);
int wprintf(format(wstring_t));
int fwprintf(FILE*, format(wstring_t));
int swprintf(+wstring2_t, ulong, format(wstring_t));
int vfwprintf(FILE*, wstring_t, addr);
int vwprintf(wstring_t, addr);
int vswprintf(+wstring2_t, ulong, wstring_t, addr);
; int wscanf(const wchar_t *restrict, ...);
; int fwscanf(FILE *restrict, const wchar_t *restrict, ...);
; int swscanf(const wchar_t *restrict, const wchar_t *restrict, ...);
; int vfwscanf(FILE *restrict, const wchar_t *restrict, va_list);
; int vswscanf(const wchar_t *restrict, const wchar_t *restrict, va_list);
; int vwscanf(const wchar_t *restrict, va_list);
int iswalnum(wint_t);
int iswalpha(wint_t);
int iswcntrl(wint_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
int iswprint(wint_t);
int iswpunct(wint_t);
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
uint wctype(string);
int iswctype(wint_t, uint);
ulong mbrlen(string, ulong, addr);
ulong mbrtowc(+wchar_t*, string[arg3], ulong, addr);
ulong mbsrtowcs(+wstring3_t, string*, ulong, addr);
ulong wctomb(+string0, wchar_t);
ulong wcrtomb(+string0, wchar_t, addr);
ulong wcsrtombs(+string3, wstring_t*, ulong, addr);
int mbsinit(addr);
wint_t towlower(wint_t);
wint_t towupper(wint_t);
wstring_t wcscat(wstring_t, wstring_t);
wstring_t wcsncat(wstring3_t, wstring_t, ulong);
wstring_t wcschr(wstring_t, wchar_t);
wstring_t wcsrchr(wstring_t, wchar_t);
int wcscmp(wstring_t, wstring_t);
int wcsncmp(wstring3_t, wstring3_t, ulong);
int wcscoll(wstring_t, wstring_t);
addr wcscpy(addr, wstring_t);
addr wcsncpy(addr, wstring_t, ulong);
ulong wcslen(wstring_t);
wstring_t wcsstr(wstring_t, wstring_t);
wstring_t wcswcs(wstring_t, wstring_t);
ulong wcscspn(wstring_t, wstring_t);
ulong wcsspn(wstring_t, wstring_t);
wstring_t wcspbrk(wstring_t, wstring_t);
wstring_t wcstok(wstring_t, wstring_t, +wstring_t*);
ulong wcsftime(+wstring2_t, ulong, wstring_t, addr);
double wcstod(wstring_t, +wstring_t*);
float wcstof(wstring_t, +wstring_t*);
ldouble wcstold(wstring_t, +wstring_t*);
long wcstol(wstring_t, +wstring_t*, int);
llong wcstoll(wstring_t, +wstring_t*, int);
ulong wcstoul(wstring_t, +wstring_t*, int);
ullong wcstoull(wstring_t, +wstring_t*, int);
int wcwidth(wchar_t);
int wcswidth(wstring2_t, ulong);
wstring_t wmemchr(wstring3_t, wchar_t, ulong);
int wmemcmp(wstring3_t, wstring3_t, ulong);
int wctob(wint_t);
wstring3_t wmemcpy(addr, wstring3_t, ulong);
wstring3_t wmemmove(addr, wstring3_t, ulong);
wstring3_t wmemset(addr, wchar_t, ulong);
# sys/wait.h
int wait(addr);
int waitpid(int,addr,int);
# other symbols not included above
long a64l(string);
string l64a(long);
void abort();
int abs(int);
long labs(long);
typedef mntent = struct(string, string, string, string, int, int);
int addmntent(file, mntent*);
int endmntent(file);
int __endmntent(file);
file setmntent(string,string);
file __setmntent(string,string);
mntent *getmntent(addr);
mntent *getmntent_r(file, +mntent*, string, int);
mntent *__getmntent_r(file, +mntent*, string, int);
string hasmntopt(mntent*, string);
|