Where's ".div" implemented?
Nick Patavalis
npat@inaccessnetworks.com
Tue Jun 3 13:08:00 GMT 2003
I'm compiling the following program using GCC-3.2.3 configured as a
cross-compiler targeting "sparc-linux" and hosted on ix86-linux.
int main (void) { int i; i = i / 3; return 0; }
My target system uses a sparc-v7 compliant processor without integet
multiplication and division instructions, so I'm compiling with:
sparc-linux-gcc -mcpu=v7 -fno-builtin -c tst.c -o tst.o
but when I try to link the generated object, like this:
sparc-linux-ld tst.o /path/to/gcc-lib/3.2.3/libgcc.a -o tst
I get an error about the linker not been able to find the ".div"
function. I was under the impression that the integer-math functions
called by code generated from C integer expressions were implemented
in "libgcc.a". Obviously they are not!
Looking arround I found a ".div" function in *libc*, but for several
reasons, I don't want to link my program with the glibc "monster". All
I want is a library that supports the *compiler generated* function
references. Isn't "libgcc" supposed to be exactly that???
I finaly managed to get my program (performing integer math) link,
using this round-about way:
mkdir libintm; cd libintm
ar x /path/to/glibc/libc.a \
addmul_1.o sub_n.o submul_1.o dotmul.o \
mul.o mul_1.o mul_n.o umul.o \
div.o udiv.o udiv_qrnnd.o sdiv.o ldiv.o lldiv.o \
divmod_1.o divrem.o rem.o urem.o
ar cr libintm.a *.o
ranlib libintm.a
and then link my program with "-lintm".
Are the above-mentioned functions *exactly* the ones required? That
is, does the compiler implicitly produce refences *only* to these
functions, and to *all* of these? Is there a nicer way to achieve the
same result?
/npat
P.S. Obviously my intention is to compile a program that will run at
"boot"-time without the services of an operation system, or of an
extensive standard library.
--
Don't ever think you know what's right for the other person.
He might start thinking he knows what's right for you.
-- Paul Williams, `Das Energi'
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list