This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH, ARM/libgloss]fix compilation error in linux-crt0.c when '-ffunction-sections' is specified
- From: Matthew Gretton-Dann <matthew dot gretton-dann at arm dot com>
- To: Bin Cheng <bin dot cheng at arm dot com>
- Cc: "newlib at sources dot redhat dot com" <newlib at sources dot redhat dot com>
- Date: Mon, 16 Jan 2012 10:49:35 +0000
- Subject: Re: [PATCH, ARM/libgloss]fix compilation error in linux-crt0.c when '-ffunction-sections' is specified
- References: <004001ccd41b$557de020$0079a060$@cheng@arm.com>
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.