Skip to content

Instantly share code, notes, and snippets.

@ryanchapman
Last active August 29, 2015 14:13
Show Gist options
  • Save ryanchapman/793492f77728eec466f1 to your computer and use it in GitHub Desktop.
Save ryanchapman/793492f77728eec466f1 to your computer and use it in GitHub Desktop.
write a string to standard output using syscall(2)
/* save as test.c, compile with gcc test.c -o test -m64 */
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
void main() {
const char *buf="test\n";
syscall(1, /* sys_write */
1, /* stdout */
buf, /* buf, or string to write to stdout */
5 /* num of chars in buf */
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment