[PATCH, ARM/libgloss]fix compilation error in linux-crt0.c when '-ffunction-sections' is specified
Mon Jan 16 10:49:00 GMT 2012
On Mon, Jan 16, 2012 at 06:51:51AM +0000, Bin Cheng wrote:
> 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
> successfully, Is it OK?
> 2012-01-16 Bin Cheng <firstname.lastname@example.org>
> * arm/linux-crt0.c: Use ldr instead of adr to get address of
> 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"
> - "\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:
ldr r0, .LC0
LC0: .word _start_thumb
.size _start .-_start
Principal Engineer, PD Software, ARM Ltd.
More information about the Newlib