テスト用のプログラムはこんな感じです。単にシステムコール呼ぶだけです。
#define UNUSED __attribute__((unused)) int main(UNUSED int argc, UNUSED char **argv) { __asm__("mov $1, %eax\n\t" "int $0x80\n\t" ); return 0; }
自作カーネルは32bit用なので、gccとかldに32bitのオプションをつけてます。
libcとかは当然無いので、ldにはオプションとして-Bstaticをつけてスタティックなバイナリにしてます。
CC = gcc LD = ld target = hello CFLAGS = -Wall -Wextra -fno-builtin CFLAGS += -fno-common -nostdlib -nostdinc -nostartfiles -nodefaultlibs CFLAGS += -m32 CFLAGS += -mno-red-zone -ffreestanding -fno-stack-protector LDFLAGS = -m elf_i386 -Bstatic --entry=main objs = $(target).o $(target): $(objs) $(LD) $(LDFLAGS) $(objs) -o $(target) .c.o: $(CC) $(CFLAGS) -c $< clean: rm -f *~ $(target) $(objs)