s-matyukevich/raspberry-pi-os

Is the file name would affect the compiler process?

xubenji opened this issue · 1 comments

If you change the boot.S to boot.asm, you won't get boot_s.o when you compiler boot.S.
As you can see in this picture, When I compile boot.S, it can be compiled correctly. But when I change it to boot.asm and other file names. it won't be compiled correctly.
IMELEXM`L(@KMXXG6AA%6PJ
Even it is a warning, it still can't generate the .o file.

Yes, the file name affects the compiler process. How gcc processes a file depends on its extension. See https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html:

file.s Assembler code.
file.S, file.sx: Assembler code that must be preprocessed.
other: An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

So gcc will not process file boot.asm in any way. It won't assemble it like it would file boot.s. Instead it passes it to the linker. And as gcc is called with -c for "compile/assemble only, do not link", it warns that the file is not used. See again https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html:

-c: Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.