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
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
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
19 +# define main __arm_main
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
27 CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
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))
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
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.
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
50 +#if defined __THUMB_INTERWORK__
54 + .type __arm_main, %function
59 + .size __arm_main,.-__arm_main