diff options
Diffstat (limited to 'targets/hello.c')
| -rw-r--r-- | targets/hello.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/targets/hello.c b/targets/hello.c new file mode 100644 index 0000000..b575e6f --- /dev/null +++ b/targets/hello.c @@ -0,0 +1,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; +} |
