help needed to resolve linking error

Hi Guys,

I am trying to compile my source code using arm-linux-gcc 4.1.1, but i am getting linking error.

make make -C main make[1]: Entering directory `/home/pritam/spi_boot_example/SDcard_bootloader_fat16/main'

arm-linux-gcc -MM -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include head.S main.c print.c spi.c sd_raw.c delay.c 1>.depend

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o head.o head.S

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o main.o main.c

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o print.o print.c

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o spi.o spi.c

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o sd_raw.o sd_raw.c

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -c -o delay.o delay.c

arm-linux-gcc -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include -r -o mainrom.o head.o main.o print.o spi.o sd_raw.o delay.o

/usr/local/arm/4.1.1-920t/lib/gcc/arm-linux-uclibc/4.1.1/../../../../arm-linux-uclibc/bin/ld: cannot find -lgcc_s

collect2: ld returned 1 exit status make[1]: *** [mainrom.o] Error 1 make[1]: Leaving directory `/home/pritam/spi_boot_example/SDcard_bootloader_fat16/main'

make: *** [SDcard_bootloader] Error 2

Can some one please tell what this error means and how to resolve this. I am new to arm-linux stuff and trying to get this thing working.

Thanks Tama

--------------------------------------- Posted through

formatting link

Reply to
tamamontu
Loading thread data ...

...

/usr/local/arm/4.1.1-920t/lib/gcc/arm-linux-uclibc/4.1.1/../../../../arm-linux-uclibc/bin/ld:

...

It says the linker (AKA loader) can't find the "gcc_s" library. You need to find a way to instruct the linker to find the library (command line argument perhaps or even a source code linker directive). You should dig into your tools documentation to figure it out.

JJS

Reply to
John Speth

to

argument

Hi I am trying to link standard libraries because my source code is using stdio,string,stdlib standard libraries.

Hence I added -L/usr/local/arm/4.1.1-920t/lib to the make file

----------------------------------------------------------------------------- TOPDIR := $(shell /bin/pwd) export TOPDIR

export CC=arm-linux-gcc export LD=arm-linux-ld OBJCOPY=arm-linux-objcopy OBJDUMP=arm-linux-objdump

export TOP_CFLAGS= -O2 -Wall -fPIC -mcpu=arm9tdmi -I../include

export LDFLAGS = -T SDcard_bootloader_fat16.lnk -Map SDcard_bootloader_fat16.map -L/usr/local/arm/4.1.1-920t/lib

ASFLAGS =

SDcard_bootloader: make -C main $(LD) $(LDFLAGS) -o SDcard_bootloader_fat16.elf main/mainrom.o $(OBJCOPY) -j rom -O binary SDcard_bootloader_fat16.elf SDcard_bootloader_fat16.bin

$(OBJDUMP) -D SDcard_bootloader_fat16.elf > SDcard_bootloader_fat16.diss

clean: make clean -C main

-----------------------------------------------------------------------------

But it then give a error =>

main/mainrom.o: In function `start_C': sd_raw.c:(rom+0x208): undefined reference to `puts' main/mainrom.o: In function `myputhex': sd_raw.c:(rom+0x338): undefined reference to `memcpy' make: *** [SDcard_bootloader] Error 1

Then I added -lc option to the make file, this give me a diff error

ain/mainrom.o: In function `start_C': sd_raw.c:(rom+0x208): undefined reference to `puts' main/mainrom.o: In function `myputhex': sd_raw.c:(rom+0x338): undefined reference to `memcpy' make: *** [SDcard_bootloader] Error 1

Any idea on how to link standard libraries.

Thanks Tama

--------------------------------------- Posted through

formatting link

Reply to
tamamontu

Let the compiler call the linker instead do it directly.

$(CC) -o

jbe

Reply to
Juergen Beisert

The main problem in my make file is

$(CC) $(CFLAGS) -r -o mainrom.o $(OBJ_y)

This line has -r option which is causing all the problem. If i remove -r option then i dont get any error but the problem is my application dosent execute.

Any idea that this option does. Or how to link to standard libraries with this option.

Thanks Tama

--------------------------------------- Posted through

formatting link

Reply to
tamamontu

It seems that you are not creating a program that is executable by itself, but a module for a larger program. Why did you not tell what you're attempting to achieve?

(My guess: adding the FAT 16 file system and SD card support to the u-boot loader).

Please get the GNU binutils documentation and read the ld manual for the switches.

--- clip from the manual ---

-r

--relocatable Generate relocatable output?i.e., generate an output file that can in turn serve as input to ld. This is often called partial linking. As a side effect, in environments that support standard Unix magic numbers, this option also sets the output file's magic number to OMAGIC. If this option is not specified, an absolute file is produced. When linking C++ programs, this option will not resolve references to constructors; to do that, use `-Ur'.

When an input file does not have the same format as the output file, partial linking is only supported if that input file does not contain any relocations. Different output formats can have further restrictions; for example some a.out-based formats do not support partial linking with input files in other formats at all.

This option does the same thing as `-i'.

-i Perform an incremental link (same as option `-r').

--- end of clip ---

A link with the -r switch does not create an executable output file, but it creates a linkable object file instead. This is normal practice in linking huge programs, e.g. the Linux kernel.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

Hi Tauno,

Thanks for your reply.

I am trying to implement a fat16 file system detection program along with the sdcard support for EP9307(cirrus logic arm9) chip. I am new to all embedded linux environment. The development kit came with arm-linux-gcc 3.4 tool chain. This dev kit also had a demo code for SPI boot through eeprom.

The make files in this demo code have "$(CC) $(CFLAGS) -r -o mainrom.o $(OBJ_y)" along with LDFLAGS and CFLAGS have -nostdlib.

I modified the source code to talk to sdcard. Now I want to implement fat16 file system so that I load the kernel directly from sdcard.

my fat16 source code uses standard libraries thats were i got into compiling/linking problem with -r option.

along with -r option the LDFLAGS and CFLAGS have -nostdlib.

All i want to do is use std libraries so that i can implement the file system. I am not using u-boot.

I am not a advance c user, any pointers would help me a lot. Thanks Tama

--------------------------------------- Posted through

formatting link

Reply to
tamamontu

It is fairly probable that you cannot use the standard libraries, or at least the memory allocation and standard I/O are not available in the boot code. This is because the standard libraries are using such operating system facilities that are not yet available at the boot time - you're all on your own. Boot programs are about as stand-alone code as it can get.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.