Page 1 of 1

Raspberry Pi Makefile can't find objects

Posted: Sat Jun 14, 2014 5:54 am
by sdream
Hello every one !
I am new to OsDev and i found very good learning resources here . I was studying the mini kernel tutorial for Raspberry Pi from here
http://wiki.osdev.org/ARM_RaspberryPi_Tutorial_C

Make file giving here , is giving me error.


/usr/arm-none-eabi/bin/ld -Tlink-arm-eabi.ld -o kernel.elf
/usr/arm-none-eabi/bin/ld: no input files
make: *** [kernel.elf] Error 1


It is not building the kernel image. Can any body tell me why it is giving me error ?

Re: Raspberry Pi Makefile can't find objects

Posted: Sat Jun 14, 2014 6:37 am
by sortie
It's because you didn't link any objects into the kernel. You need to understand how linkers and compilers work to succeed in osdev. You also need a bit of Makefile knowledge, though I admit it's not the clearest format if you are not used to it. The interesting lines in the Makefile are:

Code: Select all

# source files
SOURCES_ASM := $(wildcard *.S)
SOURCES_C   := $(wildcard *.c)

# object files
OBJS        := $(patsubst %.S,%.o,$(SOURCES_ASM))
OBJS        += $(patsubst %.c,%.o,$(SOURCES_C))

# ...

kernel.elf: $(OBJS) link-arm-eabi.ld
	$(ARMGNU)-ld $(OBJS) -Tlink-arm-eabi.ld -o $@
Look up in the GNU Make Manual how this code works, btw. Basically it locates all the .c and .S files in the source directory, and sets the OBJS variable to all those files renamed to .o, which is the list of object files it wants to produce. The Makefile does its usual work (not relevant for this problem solving, at least yet) to produce those object files. Once it has made all the needed object files, it links them together with arm-none-eabi-ld ($(ARMGNU)-ld) to produce the kernel. However, notice your command line that failed. There is no object files specific on that line and that's why it fails. Assuming you didn't modify the Makefile and break things, that would mean OBJS is the empty string and specifies no object files. Since OBJS is produced via pattern matching and string rewriting based on the current directory, that would mean that it found no .c and .S files. Thus, I'd guess that the issue is that you either forgot to add any .c and .S files that you want compiled, or that you are running Make in the wrong directory.

Re: Raspberry Pi Makefile can't find objects

Posted: Sat Jun 14, 2014 8:29 am
by sdream
Thanx sortie !

I made a mistake in syntax , that's why it was not building . Now i am in new problem .
Building process is giving error in Boot.S file now. It is telling syntax error at :

.section ".text.boot" line in Boot.S

I am not getting why it is giving error at this line , i googled it out but unable to solve my problem .

Re: Raspberry Pi Makefile can't find objects

Posted: Sat Jun 14, 2014 10:20 am
by sortie
I guess that your browser helpfully replaces raw " characters with nearly-identical (but not bitwise) unicode characters. Be careful how you copy-paste from the wiki and ensure that real " characters are used. Or perhaps you didn't use the C preprocessor on the asesmbly files? You need to compile them with the cross-gcc. You need to give more information, such as exactly what the file used was (so we are certain and know whether there are junk on the previous line) and exactly what command you used to compile it with. Try compile the files without using the Makefile, if you are not so skilled with using Makefiles.