]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/uclibc/uclibc-0.9.27/thumb-static-main.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / uclibc / uclibc-0.9.27 / thumb-static-main.patch
1 # This patch almost works, it allows a statically linked application
2 # to be compiled with a thumb main and to have this work from a
3 # non-thumb uClibc build.  However it stops the same thing working
4 # in the dynamically linked case (because the value of 'main' doesn't
5 # have the low bit set when loaded - something must be wrong with the
6 # relocation for STT_ARM_TFUNC?)  At present it is not included for
7 # this reason.
8 --- uClibc-0.9.27/libc/misc/internals/__uClibc_main.c   2005-08-13 18:04:09.078682965 -0700
9 +++ uClibc-0.9.27/libc/misc/internals/__uClibc_main.c   2005-08-13 18:07:38.159839613 -0700
10 @@ -32,6 +32,13 @@
11  /*
12   * Prototypes.
13   */
14 +#if (defined __arm__ || defined __thumb__) && defined __THUMB_INTERWORK__ && defined __linux__
15 +/* Because when linking statically the GNU linker provides no glue for
16 + * main, so if main is thumb and we are arm or vice versa the static
17 + * link fails.
18 + */
19 +# define main __arm_main
20 +#endif
21  extern int  main(int argc, char **argv, char **envp);
22  extern void weak_function _stdio_init(void);
23  extern int *weak_const_function __errno_location(void);
24 --- uClibc-0.9.27/libc/sysdeps/linux/arm/Makefile       2005-01-11 23:59:21.000000000 -0800
25 +++ uClibc-0.9.27/libc/sysdeps/linux/arm/Makefile       2005-08-13 18:08:08.953777353 -0700
26 @@ -25,7 +25,7 @@
27  CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
28  
29  SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
30 -       bsd-_setjmp.S sigrestorer.S mmap64.S
31 +       bsd-_setjmp.S sigrestorer.S mmap64.S mainglue.S
32  SOBJS=$(patsubst %.S,%.o, $(SSRC))
33  
34  CSRC=brk.c syscall.c ioperm.c sigaction.c
35 --- uClibc-0.9.27/.pc/thumb-static-main.patch/libc/sysdeps/linux/arm/mainglue.S 2005-08-13 18:20:44.181300825 -0700
36 +++ uClibc-0.9.27/libc/sysdeps/linux/arm/mainglue.S     2005-08-13 19:11:05.031390937 -0700
37 @@ -0,0 +1,23 @@
38 +/*
39 + * Apparently the GNU linker doesn't generate the 'glue' code
40 + * required for ARM/thumb interwork for the 'main' function -
41 + * presumably glibc doesn't need it, but uClibc does.
42 + *
43 + * We can't provide this stuff, because the linker expects to
44 + * have generated the glue code itself and asserts if the code
45 + * is not in memory (because it has been read from a pre-existing
46 + * definition), therefore we must avoid the glue - so we make
47 + * __uClibc_main call __arm_main and define it here (in arm
48 + * code).
49 + */
50 +#if defined __THUMB_INTERWORK__
51 +       .text
52 +       .arm
53 +       .global __arm_main
54 +       .type   __arm_main, %function
55 +__arm_main:
56 +       ldr     ip, [pc]
57 +       bx      ip
58 +       .word   main
59 +       .size   __arm_main,.-__arm_main
60 +#endif