This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC ARM Linker Problem- Static function
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Kanwal Preet Singh CHANANA <kanwalpreet dot singh at st dot com>
- Cc: gcc-help at gcc dot gnu dot org, crossgcc at sources dot redhat dot com
- Date: Thu, 31 Aug 2006 11:25:40 +0100
- Subject: Re: GCC ARM Linker Problem- Static function
- References: <002201c6cce6$91b65d70$5e0bc70a@dlh.st.com>
On Thu, 2006-08-31 at 11:16, Kanwal Preet Singh CHANANA wrote:
> Hi Richard,
>
> With your suggestion, using GCC-ARM ,I am able to link functions & symbols
> located in ROM. I am able to fix the crash occuring on jumping to Thumb
> function located in ROM.
>
Good, I'm glad some progress has been made.
> I am facing a new problem.I have many static functions in my source files.
> The image crashes when it enters a particular function in *.text section
> located in Flash. When I debug the image, I found that one of the static
> function is overwriting the original function code. This might have happened
> during the loading of *.bss & *.data sections during runtime.
>
> When I check Image.map file, I am not able to see this static function name.
> Also I tried to diassemble the Image.out file using arm-elf-objdump utility
> but still cannot find this function.
> The linker script file is correct since there is no section overlaps.
>
> Where will static section be placed in Image.out?
> Can we define address for static section also?
>
I'm not really sure what you are asking, and just at the moment I'm
afraid I don't have any time to help you any further.
Sorry, and good luck with your project,
R.
> Regards,
> Kanwal
>
>
> -----Original Message-----
> From: Richard Earnshaw [mailto:rearnsha@arm.com]
> Sent: Wednesday, August 30, 2006 1:18 PM
> To: Kanwal Preet Singh CHANANA
> Subject: RE: FW: GCC ARM Cross Linker Problem
>
>
> On Wed, 2006-08-30 at 05:05, Kanwal Preet Singh CHANANA wrote:
> > Hi Richard,
> >
> > Thanks for valuable suggestion. I will try the following to certify if
> > Image is running correctly on target.
> >
> > Another thing, the symbols I am linking are in ROM. ROM code is
> > compiled with ADSv1.2 & "symbols.o" was generated using "-symdefs
> > symbols.o" option for armlink. Now when I link my Flash (project) code
> > with "symbols.o" using ADSv1.2 or RVDSv2.2,linker generates image with
> > no error but if I use GCC-ARM ,linker gives a error " symbols.o: File
> > format not recognised". This occurs due to EABI differences between
> > ADS & GCC-ARM.
> >
> No, if you take a look at the symbols.o file, I think you will find that it
> is just a plain text file with some magic header that allows the arm linker
> to interpret it. The format is pretty self-intuitive, but you can find full
> details in the arm linker documentation.
>
> > As per your suggestion, one "sym.s" will be included in project code.
> > We want to use the same source code for ADS,RVDS & GCC-ARM(few changes
> > in *.s files are done using perl script). This will make sources to be
> > generic & compiled with above mentioned too chains.
> >
>
> > Can I change "symbols.o" in a way so that GCC-ARM linker recognises it
> > ? In this way I dont have to add "sym.s" file.
> >
>
> It ought to be possible to write a simple script that will process your
> symbols.o file into something that you can assemble with the gnu assembler
> into a real object file.
>
> R.
>
> > Regards,
> > Kanwal
> >
> > -----Original Message-----
> > From: Richard Earnshaw [mailto:Richard.Earnshaw@arm.com]
> > Sent: Tuesday, August 29, 2006 7:54 PM
> > To: Kanwal Preet Singh CHANANA
> > Cc: vinayakbhalkar@Math.net; gcc-help@gcc.gnu.org;
> > crossgcc@sources.redhat.com
> > Subject: RE: FW: GCC ARM Cross Linker Problem
> >
> >
> > The following works fine for me:
> >
> > sym.s:
> > .global tfunc
> > .type tfunc %function
> > .equ tfunc, 0x1235
> > main.c:
> > extern void tfunc(void);
> > int main()
> > {
> > tfunc();
> > return 0;
> > }
> >
> > arm-elf-as sym.s -o sym.o
> > arm-elf-gcc main.c sym.o -o main.exe
> > arm-elf-objdump -xd main.exe
> > ...
> > 00008224 <main>:
> > 8224: e1a0c00d mov ip, sp
> > 8228: e92dd800 stmdb sp!, {fp, ip, lr, pc}
> > 822c: e24cb004 sub fp, ip, #4 ; 0x4
> > 8230: eb0007f8 bl a218 <__tfunc_from_arm>
> > 8234: e3a03000 mov r3, #0 ; 0x0
> > 8238: e1a00003 mov r0, r3
> > 823c: e89da800 ldmia sp, {fp, sp, pc}
> > ...
> > 0000a218 <__tfunc_from_arm>:
> > a218: e59fc000 ldr ip, [pc, #0] ; a220
> > <__tfunc_from_arm
> > +0x8>
> > a21c: e12fff1c bx ip
> > a220: 00001235 andeq r1, r0, r5, lsr r2
> > ...
> >
> > Notice that __tfunc_from_arm loads the value 0x1235 into a register
> > and issues a bx instruction, which will then correctly switch to Thumb
> > state.
> >
> > R.
> >
> > On Tue, 2006-08-29 at 14:47, Kanwal Preet Singh CHANANA wrote:
> > > Hi Vinayak,
> > > Kindly refer to below mail. I am already using this following method
> > > but it is not working.
> > >
> > > Regards,
> > > Kanwal
> > >
> > > -----Original Message-----
> > > From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]
> > > On Behalf Of Vinayak Bhalkar
> > > Sent: Tuesday, August 29, 2006 5:42 PM
> > > To: kanwalpreet.singh@st.com
> > > Cc: gcc-help@gcc.gnu.org; crossgcc@sources.redhat.com
> > > Subject: Re: FW: GCC ARM Cross Linker Problem
> > >
> > >
> > >
> > > Try following-
> > >
> > > MaskInterrupt = 0x00c008f9;
> > >
> > > Regards,
> > > vinayak
> > >
> > > --- kanwalpreet.singh@st.com wrote:
> > >
> > > From: Kanwal Preet Singh CHANANA <kanwalpreet.singh@st.com>
> > > To: <gcc-help@gcc.gnu.org>, <crossgcc@sources.redhat.com>
> > > Subject: FW: GCC ARM Cross Linker Problem
> > > Date: Tue, 29 Aug 2006 14:59:35 +0530
> > >
> > > Hi all,
> > >
> > > I am able to compile & Link my source files with a workaround
> > > mentioned below:
> > >
> > > The absolute symbols defined in symbols.o are
> > >
> > > 0x000002a8 D CurTask
> > > 0x00c008f8 T MaskInterrupt
> > > Where Curtask is data located in RoM & MaskInterrupt is function in
> > > Thumb Mode.
> > >
> > > I used following definations in Linker Script
> > >
> > > pCurTask = 0x000002a8;
> > > MaskInterrupt = 0x00c008f8;
> > >
> > > With this I am able to link & built Image.axf file. But when running
> > > on target,the image crashes at a point when it jumps to
> > > MaskInterrupt(shown above) . The reason is that the Linker assumes
> > > MaskInterrupt function to be in ARM mode.When it jumps there, it
> > > expects 4 byte ARM instruction but the code at this location has 2
> > > Byte Thumb Instruction.
> > >
> > > The Thumb Interwork option is enabled in Build options.
> > >
> > > Can anyone suggest me a method to Link above symbols in a way so
> > > that
> > > GCC-ARMv4.0.3 knows whether the symbols is Data or Thumb Function or
> > > ARM function? If there is a way, then Image will run correctly on
> > > Target. Also if anyone needs any help on Project porting from ADS to
> > > GCC-ARM,then I can help him out.
> > >
> > > Please suggest a wayout to fix the above problem.
> > > Regards,
> > > Kanwal
> > >
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]
> > > On Behalf Of Kanwal Preet Singh CHANANA
> > > Sent: Monday, August 21, 2006 3:48 PM
> > > To: gcc-help@gcc.gnu.org
> > > Subject: GCC ARM Cross Linker Problem
> > >
> > >
> > > Hi all,
> > >
> > > I am porting my project from ADS from ARM to GCC ARM Tool chain. I
> > > am
> > > able to compile my source files but fail to link. I have a symbols file
> > (symbols.o) with absolute symbols addresses in format
> > > Symboladdress SymbolType Symbolname e.g
> > >
> > > 0x000002a8 D CurTask
> > > 0x00c008f8 T MaskInterrupt
> > >
> > > These symbols are located in ROM( code built with ADS) & project
> > > image
> > > will be in flash. When I use this same file during build with ARM ADS,
> > > it works fine but with GCC ARM tool chain,I get following error
> > > message
> > >
> > > "./symbols.o: file not recognized: File format not recognized"
> > >
> > > Can anybody please tell me the solution to this error? Can I link
> > > objects built with ADS with GCC ARM ?
> > >
> > > Regards,
> > > Kanwal
> > >
> > >
> > >
> > > _____________________________________________________________
> > > Get your free web-based e-mail account from http://www.Math.net Your
> > > online tourguide of Mathematics, with books, links, news, message
> > > boards, and much more!
> > >
> > >
> > > --
> > > For unsubscribe information see http://sourceware.org/lists.html#faq