This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug: setjmp multilib appears broken


The move to the new configure/automake uses $(CCASCOMPILE) for compiling .S files into .o files. This ends up being the same gcc compiler used for C files. However, CCASCOMPILE uses its own set of flags: e.g. CCASFLAGS instead of CFLAGS.

Now, config-ml.in which adds the multilib logic gets special multilib flags from the compiler and appends them to a set of flags to be passed when building a particular multilib. It adds these flags to CFLAGS, but neglects to add them to CCASFLAGS.

I propose the attached patch to fix this. Shaun, please try it out.

DJ, I cc'd you as you are listed in the MAINTAINERS file for config-ml.in. Ok?

-- Jeff J.

Shaun Jackman wrote:
The functions setjmp and longmp in the thumb libc.a are in fact
compiled as ARM code.

The linker complains when I attempt to link my program.

/usr/local/lib/gcc/arm-elf/4.1.0/../../../../arm-elf/bin/ld:
/usr/local/lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/thumb/libg.a(lib_a-setjmp.o)(longjmp):


warning: interworking not enabled.
 first occurrence: proc.o: thumb call to arm
proc.o: In function `kexit':../../kernel/proc.c:55: warning: internal
error: dangerous error

$ arm-elf-objdump -rS ./arm-elf/thumb/newlib/libc/machine/arm/lib_a-setjmp.o

./arm-elf/thumb/newlib/libc/machine/arm/lib_a-setjmp.o:     file
format elf32-littlearm

Disassembly of section .text:

00000000 <setjmp>:
  0:   e8a07ff0        stmia   r0!, {r4, r5, r6, r7, r8, r9, sl, fp,
ip, sp, lr}
  4:   e3a00000        mov     r0, #0  ; 0x0
  8:   e31e0001        tst     lr, #1  ; 0x1
  c:   01a0f00e        moveq   pc, lr
 10:   e12fff1e        bx      lr

00000014 <longjmp>:
 14:   e8b07ff0        ldmia   r0!, {r4, r5, r6, r7, r8, r9, sl, fp,
ip, sp, lr}
 18:   e1b00001        movs    r0, r1
 1c:   03a00001        moveq   r0, #1  ; 0x1
 20:   e31e0001        tst     lr, #1  ; 0x1
 24:   01a0f00e        moveq   pc, lr
 28:   e12fff1e        bx      lr

Here are the relevant lines from the compilation:

make[9]: Entering directory
`/home/sjackman/src/toolchain/src/_build/arm-elf/thumb/newlib/libc/machine/arm'


arm-elf-gcc -B/home/sjackman/src/toolchain/src/_build/arm-elf/newlib/
-isystem /home/sjackman/src/toolchain/src/_build/arm-elf/newlib/targ-include
-isystem /home/sjackman/src/toolchain/src/newlib/libc/include -O2
-D__NO_SYSCALLS__ -DNO_FLOATING_POINT -DHAVE_FCNTL -DHAVE_GETTIMEOFDAY
-DHAVE_NANOSLEEP -fno-builtin -c -o lib_a-setjmp.o `test -f
'setjmp.S' || echo
'../../../../../../../newlib/libc/machine/arm/'`setjmp.S
rm -f lib.a
arm-elf-ar cru lib.a lib_a-setjmp.o lib_a-access.o
arm-elf-ranlib lib.a
make[9]: Leaving directory
`/home/sjackman/src/toolchain/src/_build/arm-elf/thumb/newlib/libc/machine/arm'



It looks as though the option -mthumb has been omitted.


Cheers,
Shaun

Index: config-ml.in
===================================================================
RCS file: /cvs/src/src/config-ml.in,v
retrieving revision 1.17
diff -u -p -r1.17 config-ml.in
--- config-ml.in	14 Jul 2005 01:24:56 -0000	1.17
+++ config-ml.in	2 Jun 2006 18:46:24 -0000
@@ -546,6 +546,7 @@ multi-do:
 		flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
 		if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
 				CFLAGS="$(CFLAGS) $${flags}" \
+				CCASFLAGS="$(CCASFLAGS) $${flags}" \
 				FCFLAGS="$(FCFLAGS) $${flags}" \
 				FFLAGS="$(FFLAGS) $${flags}" \
 				ADAFLAGS="$(ADAFLAGS) $${flags}" \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]