[uClinux-dev] C++, IOStreams, relocation truncated to fit

Ken Treis ktreis at keyww.com
Wed Nov 21 17:39:03 EST 2001


David McCullough wrote:

>First problem is you should be using "-fPIC",  you should use "-msep-data"
>for XIP under uClinux.
>
>Also,  m68k PIC cannot do the impossible.  If you have a function that
>requires branches that are too big for the M68K relative branch,  you
>cannot compile it PIC.  Luckily,  it doesn't have to be PIC to use it.
>Just remove the '-msep-data' option from your build and you will get
>a fully relocated/no size limit version of the binary that can do anything
>except of course XIP ;-)
>
>So try -msep-data first,  then if you still get this error,  remove the
>-msep-data option completely,
>
>
>Cheers,
>Davidm
>
>
>
>>m68k-elf-g++ -Os -g -fomit-frame-pointer  -Dlinux -D__linux__ -Dunix 
>>-D__uClinux__ -DEMBED -I~/coldfire/uClinux/lib//include 
>>-I~/coldfire/uClinux/lib/libm -I~/coldfire/uClinux -fno-builtin 
>>-msep-data -I~/coldfire/uClinux//include  -fname-mangling-version-0 
>>-ansi -I../../CppTestKit -g -Wall -fPIC -m5307 -D__uClinux__ 
>>-Wl,-elf2flt DataDestination.o FrameBuffer.o Image.o ImageSource.o 
>>Normalizer.o Pixel.o RealNormalizer.o SimulatedNormalizer.o 
>>AssertImagesEqual.o NormalizerTest.o -L. -o test 
>>../../CppTestKit/coldfire/DumbConsole.o 
>>../../CppTestKit/coldfire/libTkCore.a -lc -lgcc
>>test.elf2flt: In function `_IO_fclose':
>>/home/davidm/work/m68k-elf-tools/m68k-elf-gcc/m68k-elf/m5307/msep-data/libio/../../../../../gcc-2.95.3/libio/iofclose.c:54: 
>>relocation truncated to fit: R_68K_PC16 __cmpdf2
>>/home/davidm/work/m68k-elf-tools/m68k-elf-gcc/m68k-elf/m5307/msep-data/libio/../../../../../gcc-2.95.3/libio/iofclose.c:54: 
>>relocation truncated to fit: R_68K_PC16 __cmpdf2
>>/home/davidm/work/m68k-elf-tools/m68k-elf-gcc/m68k-elf/m5307/msep-data/libio/../../../../../gcc-2.95.3/libio/iofclose.c:54: 
>>relocation truncated to fit: R_68K_PC16 __cmpdf2
>>test.elf2flt: In function `__muldi3':
>>/home/davidm/work/m68k-elf-tools/m68k-elf-gcc/gcc/../../gcc-2.95.3/gcc/libgcc2.c(.text+0x150e2): 
>>relocation truncated to fit: R_68K_PC16 __cmpdf2
>>collect2: ld returned 1 exit status
>>make: *** [test] Error 1
>>
Okay, here's some more info.  Bear with me, I'm new to the lower levels 
of C compilers.

The program wouldn't link when I used either "-fPIC -msep-data" or just 
"-fPIC" in my CFLAGS.  It successfully built the test.elf, but it seemed 
to be having trouble flattening it out.  I ran elf2flt myself and got a 
whole bunch of warnings, but ultimately it built a flat executable. 
 That executable never ran -- perhaps because I didn't give elf2flt the 
right arguments or perhaps because I couldn't figure out how to drive 
elf2flt correctly.

However, when I removed the -lgcc, it linked and ran on my eval board.

So some further questions:

- When do I really need libgcc.a?  Does the compiler automagically 
figure out when I need it?  I have vague recollections that colilo 
wouldn't build without it.
- Does link order matter here?  If I do turn out to need libgcc, should 
I put it "closer" in the link order to the .o files that call its functions?
- How is it that I was able to build and run without linking the 
libstdc++.a?
- By removing libgcc.a, am I just buying myself a little bit of space 
that may quickly be used up (and therefore cause this problem again in a 
few days / weeks / months)?
- What is XIP?  I don't even dare hazard a guess.

And thanks again (TAIA?).  :)

-- 
Ken Treis / Software Engineer
Key Technology, Inc.
ktreis at keyww.com
----
Abortion: 1 dead, 1 wounded



This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/



More information about the uClinux-dev mailing list