Forum Discussion
ld: not warning undefined symbols
Hi!
I have a program which I have been linking against various libraries, and I have found that when there's a missing object, it doesn't say anything. Instead, when it tries to execute that object, it hangs. Is that a usual thing? I suppose that there's an option to tell the linker to warn about undefined symbols, so... anyone could point me to it? I've tried with "--no-undefined", bout it doesn't say anything new... Thank you aLeX7 Replies
- Altera_Forum
Honored Contributor
Did you add "-elf2flt" for linking to uClinux?
The elf2flt should fail on undefined symbols. Or you can check the link map file before elf2flt. - Altera_Forum
Honored Contributor
I'm not using "elf2flt", because I'm using the example I found in the documentation... In the Makefile, I wrote:
When I do "make all", it compiles my program and generates an .exe file. I've seen that it uses elf2fltTSTPRG = myprog.exe all: $(TSTPROG)
The strange thing is that it shows the same if I include the references to the libraries it needs, or if I don't include them. It doesn't warn about anything... any idea? aLeXnios2-linux-uclibc-gcc -nostdinc -O2 -I/home/indes/opo/kernel/uClinux-dist-test/uClibc/include -I/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/include -fno-optimize-sibling-calls -mhw-mul -mhw-mulx -Wall -c -o myprog.o myprog.c nios2-linux-uclibc-gcc -msys-crt0=/home/uClibc/lib/crt0.o -r -d -L/home/uClinux-dist-test/uClibc/lib -o myprog.bin myprog.o /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/lib/libm.a /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/libgcc.a /home/indes/opo/kernel/uClinux-dist-test/uClibc/lib/libc.a --no-undefined nios2-linux-uclibc-ld -T /opt/nios2/scripts/elf2flt.ld -Ur -o myprog.elf myprog.bin /opt/nios2/bin/elf2flt -o myprog.flt myprog.elf cp -f myprog.flt myprog.exe rm myprog.elf myprog.flt myprog.bin myprog.o - Altera_Forum
Honored Contributor
Though the same flow may work on arm linux.
It does not work for nios2 linux. You'd better follow the wiki, it is easy. http://nioswiki.jot.com/wikihome/operating...ms/compilehello (http://nioswiki.jot.com/wikihome/operatingsystems/compilehello) In case there are any undefined symbols, it will fail. - Altera_Forum
Honored Contributor
What the wiki says is more or less similar to whaat I've been doing. Maybe I have not been clear, but I'm able to compile the program correctly, and it executes. The problem is that I've had to track the library dependencies, because the compiler didn't warned me about them. the wiki didn't say anything about it.
The problem now is that I have to compile other programs with mucho more dependencies than the last one, and I don't want to include ALL my libraries in each program... aLeX - Altera_Forum
Honored Contributor
Please check man pages of "ld" .
1. map file, you can get map file after linkage, you can find if any undefined symbols. 2. you can ask "ld", ie "nios2-linux-uclibc-ld", to run multiple pass scanning. You can find more gnu tools guides from doc on www.gnu.org . The nios2-linux-uclibc-gcc will use uClibc by default. If you just want to compile uClinux apps, there is no need to use -msys-crt0, -nostdinc and -nostdlib ,etc. - Altera_Forum
Honored Contributor
I have read the man pages of "ld". I am running multiple pass ld, but the problem was to find waht libraries were needed, without having to link against all the libraries I have (I have many libraries and programs, some programs link with some libraries, and some with others).
The man pages of ld refer to standard ld, and it seems that nios2-linux-ld doesn't have ALL the options (doesn't recognize the option -M for mapping the output) Anyway, I'll try to link against ALL the libraries, even if the compile time gets increased a lot. The "-msys-crt0, -nostdinc and -nostdlib ,etc.", ... I used the Makefile that the Altera IDE generated at the beginning, before compiling in linux. Thank you... aLeX - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by abg@Nov 8 2006, 11:36 PM i have read the man pages of "ld". i am running multiple pass ld, but the problem was to find waht libraries were needed, without having to link against all the libraries i have (i have many libraries and programs, some programs link with some libraries, and some with others).the man pages of ld refer to standard ld, and it seems that nios2-linux-ld doesn't have all the options (doesn't recognize the option -m for mapping the output)
anyway, i'll try to link against all the libraries, even if the compile time gets increased a lot.
the "-msys-crt0, -nostdinc and -nostdlib ,etc.", ... i used the makefile that the altera ide generated at the beginning, before compiling in linux.
thank you...
alex
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19302)
--- quote end ---
--- Quote End --- You still should not use those "-msys-crt0, -nostdinc and -nostdlib " flags. You need them with altera's nios2-elf compiler. But DON'T use them with nios2-linux-uclibc compiler for uClinux. To pass flag to ld from gcc, you need -Wl, nios2-linux-uclibc-gcc -Wl,"-Map hello.map" -elf2flt hello.c -o hello You can have different target rule for each program and libs options in your Makefile. eg, make model1, or make model2 etc.