[PATCH, ARM/libgloss]fix compilation error in linux-crt0.c when '-ffunction-sections' is specified
Bin Cheng
bin.cheng@arm.com
Tue Jan 17 03:53:00 GMT 2012
Hi Matt & all,
Thanks for reminding, here is the new patch. Please review.
Thanks-chengbin
> -----Original Message-----
> From: Matthew Gretton-Dann
> Sent: Monday, January 16, 2012 6:50 PM
> To: Bin Cheng
> Cc: newlib@sources.redhat.com
> Subject: Re: [PATCH, ARM/libgloss]fix compilation error in linux-crt0.c
when
> '-ffunction-sections' is specified
>
> On Mon, Jan 16, 2012 at 06:51:51AM +0000, Bin Cheng wrote:
> > Hi,
> > Currently libgloss/arm/linux-crt0.c uses adr to get the address of
> > _start_thumb function.
> > It breaks the compilation when '-ffunction-sections' is specified, of
which
> > we want to
> > take advantage to decrease code size in binary.
> >
> > Here is a patch fix this issue.
> > I have compiled newlib/libgloss for various processor with or without
> > "-ffunction-sections"
> > successfully, Is it OK?
> >
> > Thanks
> >
> >
> > 2012-01-16 Bin Cheng <bin.cheng@arm.com>
> >
> > libgloss/
> > * arm/linux-crt0.c: Use ldr instead of adr to get address of
> > _start_thumb.
>
> > Index: libgloss/arm/linux-crt0.c
> > ===================================================================
> > RCS file: /cvs/src/src/libgloss/arm/linux-crt0.c,v
> > retrieving revision 1.3
> > diff -u -a -r1.3 linux-crt0.c
> > --- libgloss/arm/linux-crt0.c 13 Jul 2011 15:06:21 -0000 1.3
> > +++ libgloss/arm/linux-crt0.c 12 Jan 2012 09:56:28 -0000
> > @@ -18,7 +18,7 @@
> > ".global _start\n"
> > ".type _start, %function\n"
> > "_start:\n"
> > - "\tadr r0, _start_thumb+1\n"
> > + "\tldr r0, =_start_thumb\n"
> > "\tbx r0\n"
> > ".size _start, .-_start\n");
> >
>
> This causes an implicit literal pool entry to be generated, which will be
> generated in an arbitrary location decided by the linker (as there is no
> .ltorg directive). This is probably best avoided in libgloss.
>
> Better would be something like:
>
> _start:
> ldr r0, .LC0
> bx r0
> LC0: .word _start_thumb
> .size _start .-_start
>
> Thanks,
>
> Matt
>
>
> --
> Matthew Gretton-Dann
> Principal Engineer, PD Software, ARM Ltd.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arm-function-section-20120117.txt
URL: <http://sourceware.org/pipermail/newlib/attachments/20120117/3db873e9/attachment.txt>
More information about the Newlib
mailing list