I am trying to follow the tutorials in this link.
When I get down to the part where I start making a test.c file, I try to run the first compilation line.
in fact add -m32
you can keep -march=i686 ...
gcc -c -g -Os -march=i686 -m32 -ffreestanding -Wall -Werror test.c -o test.o
works
gcc -c -g -Os -march=i686 -m16 -ffreestanding -Wall -Werror test.c -o test.o
works
gcc -c -g -Os -march=i686 -m64 -ffreestanding -Wall -Werror test.c -o test.o
fails with ;
test.c:1:0: error: CPU you selected does not support x86-64 instruction set asm(".code16\n");
gcc -std=c99 -c -g -Os -march=i686 -m32 -ffreestanding -Wall -Werror test.c -o test.o
ld -static -T test.ld -m elf_i386 -nostdlib --nmagic -o test.elf test.o
Supply -m32
instead of -march=i686
.