blob: b575e6f186fc5e07581242fe2ea3917e13618b00 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// main calls libc through the PLT, each call a system call: a call followed
// down, through the stub and libc's wrapper to the kernel, and back up.
// Linked for lazy binding: a function's first call runs the loader's
// resolver, its second (the second read) goes straight to it.
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv) {
char buf[16];
int f = open(argv[0], O_RDONLY);
long n = read(f, buf, sizeof buf);
n += read(f, buf, sizeof buf);
close(f);
return n == 2 * sizeof buf ? 0 : 1;
}
|