public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: ARM thumb-interwork libgcc asm functions have no bx
[not found] <200008042216.PAA16939@elmo.cygnus.com>
@ 2000-08-07 2:58 ` Richard Earnshaw
0 siblings, 0 replies; 2+ messages in thread
From: Richard Earnshaw @ 2000-08-07 2:58 UTC (permalink / raw)
To: Nick Clifton; +Cc: rearnsha
> Hi Giuliano,
>
> : Some of the gcc/libgcc/interwork/*.o use BX, some don't (rm-elf-objdump -d
> : $i | grep -q bx && echo $i). The ones that do not use BX seem to all come
> : from:
> :
> : ../egcs-20000619/gcc/config/arm/lib1funcs.asm
>
> It sounds like you have a broken build of libgcc.a.
>
Nick,
I think Giuliano is right. Consider the following code snippets.
file1.c:
int foo(a, b)
{
return a / b;
}
file2.c:
int bar(a, b)
{
return a / b;
}
file3.c:
int main()
{
foo (55, 2);
bar (55, 2);
return 0;
}
gcc -O -c -minterwork file1.c
gcc -O -c -mthumb -minterwork file2.c
Now, lets link with the ARM interworking libraries:
gcc -minterwork file3.c file1.o file2.o -o arm-code
We then get the division routine from the ARM+interworking library (ARM
code): but this doesn't use a bx instruction to return, so the call from
within bar will fail to switch back to thumb mode on return.
So, lets link with the thumb interworking libraries:
gcc -minterwork -mthumb file3.c file1.o file2.o -o thumb-code
We then get the division routine from the Thumb+interworking library
(Thumb code): but this doesn't use a bx instruction either, so the call
from within foo will fail.
I'm having a think about the problem. It isn't entirely obvious what is
the best solution is (I'm not convinced we should be switching in and out
of thumb/ARM mode for such low-level routines).
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: ARM thumb-interwork libgcc asm functions have no bx
@ 2000-08-08 2:26 Giuliano Procida
0 siblings, 0 replies; 2+ messages in thread
From: Giuliano Procida @ 2000-08-08 2:26 UTC (permalink / raw)
To: 'Nick Clifton'; +Cc: gcc, Simon Gooch, gcc-bugs, rearnsha
Nick Clifton wrote:
> It sounds like you have a broken build of libgcc.a.
> All the functions in lib1funcs.asm come in two varieties, an ARM
> encoded version and a Thumb encoded version.
Agreed.
> The versions in your
> gcc/libgcc/interwork/*.o should all be the Thumb encoded versions not
> the ARM encoded ones.
[omitted discussion about possible (non-)interworking/Thumb/ARM libgccs]
In any case, libgcc has been compiled for ARM with thumb-interwork and this
has produced a bad library. It should be possible to either compile both ARM
(interworking) and Thumb (interworking) libgccs, or the former should be
detected as a configuration error.
> The building of the Thumb version of the lib1funcs.asm functions is
> controlled by the presence of the __thumb__ define when the library is
> built. I would guess that this value is not being defined for some
> reason.
I would imagine so.
> The definition of __thumb__ is normally controlled by the
> CPP_ISA_SPEC macro in gcc/config/arm/arm.h which gets added into the
> EXTRA_SPECS macro. I would check your spec strings to see if this is
> being defined properly.
This was a basically unmodified snapshot with the configuration I gave. I
have checked the file you mention and it seems to do the right thing for
CPP_ISA_SPEC. The problem is that xgcc is not being invoked with -mthumb
(this is removing one of the .o files, then remaking):
make GCC_FOR_TARGET="/omitted/build-gcc/gcc/xgcc -B/omitted/build-gcc/gcc/
-B/usr/local/arm-elf/bin/ -I/usr/local/arm-elf/include" \
HOST_PREFIX="" HOST_PREFIX_1="loser-" \
AR_FOR_TARGET="arm-elf-ar" \
AR_CREATE_FOR_TARGET="arm-elf-ar rc" \
AR_FLAGS_FOR_TARGET="" \
OLDCC="cc" CCLIBFLAGS="-O" CFLAGS="-g -O2" \
RANLIB_FOR_TARGET="arm-elf-ranlib" \
RANLIB_TEST_FOR_TARGET="[ -f arm-elf-ranlib ] || ( [ "i686-pc-linux-gnu" =
"arm-unknown-elf" ] && [ -f /usr/bin/ranlib -o -f /bin/ranlib ] )" \
LIBGCC2_CFLAGS="-O2 -DCROSS_COMPILE -DIN_GCC `echo -g -O2|sed -e
's/-pedantic//g' -e 's/-Wtraditional//g'` -isystem ./include -Dinhibit_libc
-fno-inline -g1 -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED " \
INCLUDES="-I. -I../../egcs-20000619/gcc -I../../egcs-20000619/gcc/config
-I../
../egcs-20000619/gcc/../include" MAYBE_USE_COLLECT2="" \
CONFIG_H="" MACHMODE_H="machmode.h machmode.def" \
LIB1ASMSRC='arm/lib1funcs.asm' \
-f libgcc.mk all
make[2]: Entering directory `/omitted/build-gcc/gcc'
for d in libgcc interwork libgcc/interwork; do \
if [ -d $d ]; then true; else mkdir $d; fi \
done
if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi
/omitted/build-gcc/gcc/xgcc -B/omitted/build-gcc/gcc/
-B/usr/local/arm-elf/bin/ -I/usr/local/arm-elf/include -O2 -DCROSS_COMPILE
-DIN_GCC -g -O2 -isystem ./include -Dinhibit_libc -fno-inline -g1
-DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I../../egcs-20000619/gcc
-I../../egcs-20000619/gc
c/config -I../../egcs-20000619/gcc/../include -mthumb-interwork -DL_udivsi3
-xassembler-with-cpp -c ../../egcs-20000619/gcc/config/arm/lib1funcs.asm -o
libgcc/interwork/_udivsi3.o
cpp: -lang-asm: linker input file unused since linking not done
rm -rf interwork/libgcc.a
[snip]
Note the lack of -mthumb! By the way. is this t-arm-elf incorrect?
CROSS_LIBGCC1 = libgcc1-asm.a
LIB1ASMSRC = arm/lib1funcs.asm
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func
_call_via_rX _interwork_call_via_rX
FPBIT = fp-bit.c
DPBIT = dp-bit.c
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
echo '#ifndef __ARMEB__' >> fp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
echo '#endif' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
dp-bit.c: $(srcdir)/config/fp-bit.c
echo '#ifndef __ARMEB__' > dp-bit.c
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
echo '#endif' >> dp-bit.c
cat $(srcdir)/config/fp-bit.c >> dp-bit.c
# these lines added
MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
MULTILIB_DIRNAMES += normal interwork
MULTILIB_EXCEPTIONS += *mapcs-26/*mthumb-interwork*
MULTILIB_MATCHES = mbig-endian=mbe mlittle-endian=mle
EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
> I hope that this help syou to track down your problem.
Well, I just need to work out what to do to get libgcc built with -mthumb.
Giuliano.
ps apologies for the long cc: list
>From rearnsha@arm.com Tue Aug 08 04:09:00 2000
From: Richard Earnshaw <rearnsha@arm.com>
To: Giuliano Procida <Giuliano.Procida@red-m.com>
Cc: rearnsha@arm.com
Subject: Re: ARM thumb-interwork libgcc asm functions have no bx
Date: Tue, 08 Aug 2000 04:09:00 -0000
Message-id: <200008081108.MAA08422@cam-mail2.cambridge.arm.com>
References: <531CE033A25BD3119E610000F6AF15FB01E37D30@ws-exch02.corp.ws.uk.madge.com>
X-SW-Source: 2000-08/msg00153.html
Content-length: 360
Giuliano,
Can you please try the following patch. You will need to rebuild the
compiler and (at the very least) the interworking versions of libgcc.a
Richard.
* arm.h (CPP_SPEC): Use sub-spec cpp_interwork.
(CPP_INTERWORK_SPEC, CPP_INTEWORK_DEFAULT_SPC): New sub-specs.
(EXTRA_SPECS): Add them.
* arm/lib1funcs.asm: Support builds for interworking.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-08-08 2:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200008042216.PAA16939@elmo.cygnus.com>
2000-08-07 2:58 ` ARM thumb-interwork libgcc asm functions have no bx Richard Earnshaw
2000-08-08 2:26 Giuliano Procida
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).