shithub: elf-loader

ref: e5e12f806ecf322946c093fe59d909beb9160d0c
dir: /hello/hello.c/

View raw version
#define SYS_EXITS	8
#define SYS_PWRITE	51

typedef long long	vlong;

extern vlong syscall(vlong, ...);

_Noreturn
void
exits(char *msg)
{
	syscall(SYS_EXITS, msg);
	__builtin_unreachable();
}

long
pwrite(int fd, void *buf, long nbytes, vlong offset)
{
	return syscall(SYS_PWRITE, fd, buf, nbytes, offset);
}

long
strlen(char *s)
{
	char *p;
	for(p = s; *s; s++);
	return s-p;
}

void
puts(char *s)
{
	pwrite(1, s, strlen(s), -1LL);
	pwrite(1, "\n", 1, -1LL);
}

_Noreturn
void
main(char *argv[])
{
	while(*argv)
		puts(*argv++);
	exits(0);
}