Hello Pekka, *>> you have to create a new linker script, and either copy to it or include to it the default gcc 4.7 linker file for Linux. >> I tried my best to find the default script file ... I couldn't ... the only way to see it was "ld --verbose". >> Well, contrary to what you sayd, you actually could, with ld --verbose :-) I guess you used, with your native Linux 4.7 gcc, the >> command "gcc -Xlinker --verbose" or something like that.* I meant to say that the file is printed on command line only. I cannot find the file in the directory (to open and change it manually). What I was doing was to copy from command line and paste in my ../emulator/ld/linux.ld file. However, I noticed that I was using the script file from "ld --verbose" command ... But, in the emulator.mk file when I put --verbose to the LDFLAGS, I get correct GCC version used ... *g++ -m32 -march=i386 -m32 -demangle --verbose -o sketch main.o sketch.o ellduino.o "-L." "-L../variants/ellduino" "-lstm32f0" -lstdc++ Using built-in specs.COLLECT_GCC=g++COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapperTarget: x86_64-linux-gnuConfigured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-2ubuntu1~12.04' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnuThread model: posixgcc version 4.7.3 (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/32/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib32/:/lib/i386-linux-gnu/:/lib/../lib32/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib32/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/i386-linux-gnu/:/lib/:/usr/lib/i386-linux-gnu/:/usr/lib/COLLECT_GCC_OPTIONS='-march=i386' '-m32' '-demangle' '-v' '-o' 'sketch' '-L.' '-L../variants/ellduino' '-shared-libgcc' /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu --as-needed -dynamic-linker /lib/ld-linux.so.2 -z relro -o sketch /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtbegin.o -L. -L../variants/ellduino -L/usr/lib/gcc/x86_64-linux-gnu/4.7/32 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib32 -L/lib/i386-linux-gnu -L/lib/../lib32 -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu main.o sketch.o ellduino.o -lstm32f0 -lstdc++ -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../i386-linux-gnu/crtn.o../variants/ellduino/libstm32f0.a(system_init.o): In function `SystemInitPeripherals':/home/asif/Ell-i/Runtime/stm32/build/../system/stm32/src/system_init.c:111: undefined reference to `__peripheral_start'/home/asif/Ell-i/Runtime/stm32/build/../system/stm32/src/system_init.c:111: undefined reference to `__peripheral_end'* One other issue I wanted to share with you is that I found some linker script files at /usr/lib/ldscripts in my Ubuntu version of Linux ... most of the files were elfxx_i386 ... or elfxx_x86-64 and some files are i386linux.xx. From there I copied the linker script i386linux.x to ../emulator/ld/linux.ld and building emulator gives: *g++ -m32 -march=i386 -m32 -demangle -Xlinker -T -Xlinker /home/asif/Ell-i/Runtime/stm32/emulator/ld/linux.ld -o sketch main.o sketch.o ellduino.o "-L." "-L../variants/ellduino" "-lstm32f0" -lstdc++ /usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.so: could not read symbols: File in wrong formatcollect2: error: ld returned 1 exit status* I am also attaching the linker script files along with the emulator.mk I have been using for linking with LDFLAGS. I am struggling to find solution for these ... in the meanwhile you may also have a look what I am doing. Note: Once this issue is being solved, then I guess the only problem that is left will be to put the memory locations for __peripheral_start and __peripheral_end in the linker script file to build the emulator successfully. On Fri, Feb 21, 2014 at 8:16 AM, Pekka Nikander <pekka.nikander@xxxxxx>wrote: > > using default linker and removing the emulator_pre.o & emulator_post.o > from emulator.mk leaves errors which had to be solved: > > system_init.c:111: undefined reference to `__peripheral_start' > > system_init.c:111: undefined reference to `__peripheral_end' > > This is right, exactly as it should be. > > >> you have to create a new linker script, and either copy to it or > include to it the default gcc 4.7 linker file for Linux. > > I tried my best to find the default script file ... I couldn't ... the > only way to see it was "ld --verbose". > > Well, contrary to what you sayd, you actually could, with ld --verbose :-) > I guess you used, with your native Linux 4.7 gcc, the command "gcc > -Xlinker --verbose" or something like that. > > > I tried copying the default linker file content to emulator/ld/linux.ld > and then tried making emulator which left me with following errors: Note > here that, I have already installed g++-multilib, c++-multilib, > build-essentials, ia32-lib, etc Also, I tired to put paths to > LD_LIBRARY_PATH and LD_INCLUDE_PATH through export command. You may not > know the Linux related problems, but ... you might give a general idea > what's wrong now over here. > > > > g++ -m32 -L/usr/lib32 -march=i386 -m32 > -T/home/asif/Ell-i/Runtime/stm32/emulator/ld/linux.ld -o sketch main.o > sketch.o ellduino.o "-L." "-L../variants/ellduino" "-lstm32f0" -lstdc++ > > That command line looks good to me. > > > /usr/bin/ld: skipping incompatible ../variants/ellduino/libstm32f0.a > when searching for -lstm32f0 > > /usr/bin/ld: cannot find -lstm32f0 > > /usr/bin/ld: skipping incompatible > /usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.so when searching for > -lstdc++ > > /usr/bin/ld: skipping incompatible > /usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.a when searching for -lstdc++ > > /usr/bin/ld: skipping incompatible > /usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.so when searching for > -lstdc++ > > /usr/bin/ld: skipping incompatible > /usr/lib/gcc/x86_64-linux-gnu/4.7/32/libstdc++.a when searching for -lstdc++ > > /usr/bin/ld: skipping incompatible /usr/lib32/libm.so when searching for > -lm > > /usr/bin/ld: skipping incompatible /usr/lib32/libm.a when searching for > -lm > > etc. > > For some reason the linker is attempting to link for some other > architecture but i386, as it is rejecting the i386 version of libm.so and > libm.a I get the feeling that it may be trying to link for arm, for some > reason. > > Either you may be using an ARM version of the gcc, which doesn't seem to > be the case, as the compiler is not complaining about -march=i386 flag, > your main.o etc happened to be ARM binaries when you tried that, which I > think is unlikely, or there is something wrong elsewhere. Most likely > there is something wrong with your linker script. > > Could you please post here the path to the default Linux linker script > that you copied from, and a context diff (diff -c) from the default Linux > linker script to your own, i.e. > > diff -c <path-to-the-default-linux-linker-script> > /home/asif/Ell-i/Runtime/stm32/emulator/ld/linux.ld > > --Pekka > > > -- *With Best Regards,Asif Sardar.+358 43 8265795*
Attachment:
usr-lib-ldscripts-i386linux
Description: Binary data
Attachment:
ld-linker-script
Description: Binary data