GCC giving `invalid instruction suffix for `push'`
Posted: Wed Apr 08, 2015 1:45 pm
Last night I was trying to setup my i686-elf-gcc cross compiler. After spending like an hour trying to figure out what was wrong with my current installation (I had the binaries from the debian repository, which I had assumed would work but seemed to be broken for me) and eventually decided to compile it myself. When I was finally done, I tried compiling something and it worked just fine. However, after closing out of that shell and opening a new one it no longer worked properly and kept giving a variety of different errors. I figured out that I forgot to export some of my environment variables in my zshrc, but after fixing that (I think) it still seems broken. Here are the relevant files/errors:
Makefile:
src/hello.c:
error:
This is using the code from here, by the way (with some modifications to makefiles and other parts of the code unrelated to this), and I was able to compile the kernel as of last night... I'm now unable to compile both modules and the kernel but for simplicity I am just posting the test module: https://github.com/GruntTheDivine/infin ... ules/hello
Thanks very much, nv
Makefile:
Code: Select all
CC = /home/nv/opt/cross/bin/i686-elf-gcc
AS = nasm
AFLAGS = -f elf32
CFLAGS = -c -std=gnu99 -ffreestanding -O -Wall -w -g -I ../../include
LD = /home/nv/opt/cross/bin/i686-elf-gcc
LDFLAGS = -T linker.ld -ffreestanding -O2 -nostdlib -gcc
TARGET = bin/infinity.bin
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c) $(shell find ./src -name "*.c")) $(patsubst %.asm, %.o, $(wildcard *.asm) $(shell find ./src -name "*.asm"))
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(LD) -r -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) $^ -o $@
%.o: %.asm
$(AS) $(AFLAGS) $^ -o $@
clean:
rm $(TARGET) $(OBJECTS)
Code: Select all
#include <infinity/kernel.h>
int mod_init()
{
printk(KERN_INFO "Hello, infinity kernel!\n");
return 0;
}
int mod_uninit()
{
printk(KERN_INFO "Goodbye infinity kernel :(\n");
return 0;
}
Code: Select all
/tmp/ccdUfcT0.s: Assembler messages:
/tmp/ccdUfcT0.s:18: Error: invalid instruction suffix for `push'
/tmp/ccdUfcT0.s:44: Error: invalid instruction suffix for `push'
makefile:19: recipe for target 'src/hello.o' failed
make: *** [src/hello.o] Error 1
Thanks very much, nv