Reputation: 1427
I am using the GCC like this:
gcc -std=gnu99 -fno-leading-underscore -m32 -c -o obj/entry.o src/entry.s
However, when I compile the linker says:
ld -melf_i386 -T kernel.ld -o kernel obj/entry.o obj/init.o
obj/entry.o:(multiboot+0x0): undefined reference to `MB_MAGIC'
obj/entry.o:(multiboot+0x4): undefined reference to `MB_FLAGS'
obj/entry.o:(multiboot+0x8): undefined reference to `MB_CHECKSUM'
Those references are defined in the entry.s file with the preprocessor:
#define MB_MAGIC 0x1badb002
#define MB_FLAGS 0x0
#define MB_CHECKSUM -(MB_MAGIC + MB_FLAGS)
How can I enable preprocessing?
Upvotes: 4
Views: 4712
Reputation: 7915
As explained in gcc's documentation, if the file name ends in capital .S
, it will be preprocessed automatically. You can add the -v
option to see what steps gcc follows. If you don't want to change the file name, you can also specify the language with -x assembler-with-cpp
(before the file name).
Upvotes: 9