[uClibc] [run] Floating point exception

孙庆君 qingjun.sun at great-road.com
Fri Oct 17 01:41:02 UTC 2003


hello!

  I run uClibc and encountered a problem.
  file and message as follow,
  

File:c program and Makefile

//test_static.c     ---- a c file in static lib
#include <stdio.h>
void test_s1 ()
{
    printf ("test_s1 \n");
}
void test_s2 ()
{
    printf ("test_s2 \n");
}

//test_shared.c     ---- a c file in shared lib
#include <stdio.h>
void test_shared1()
{
    printf ("test_shared1\n");
    test_s1();
}
void test_shared2()
{
    printf ("test_shared2\n");
    test_s2();
}

//test.c            ---- first call test_shared1 which in libtest_shared.so (test_shared1 will call test_s1 which in libtest_static.a)
//                       and then main call test_shared2 which in libtest_shared.so (test_shared2 will call test_s2 which in libtest_static.a)
#include <stdio.h>
#include <dlfcn.h>
#include <unistd.h>
int main (int argc, char* argv[])
{
     char clibname[255];
     void *handle;
     void (*test)();
     /* get cwd */
     memset (clibname, 0x00, sizeof (clibname));
     getcwd(clibname, 255); 

     strcat(clibname,"/libtest_shared.so");

     handle = dlopen(clibname,  RTLD_LAZY);
     if (handle == NULL) {
         printf ("dlopen error \n");
         return -1;
     }
     test = dlsym (handle, "test_shared1");
     if (test != NULL)
         printf ("dlsym success \n");
     else {
         printf ("dlsym error \n");
         return -1;
     }
     /* test_shared1 call test_s1 which in libtest_static.a*/
     (*test)();
     dlclose (handle);

     handle = dlopen(clibname, RTLD_LAZY);
     if (handle == NULL) {
         printf ("dlopen error \n");
         return -1;
     }
     test = dlsym (handle, "test_shared2");
     if (test != NULL)
         printf ("dlsym success \n");
     else  {
         printf ("dlsym error \n");
         return -1;
     }
     /* test_shared2 call test_s2 which in libtest_static.a*/
     (*test)();
     dlclose (handle);
     return 0;
}


#Makefile:
C= gcc
CFLAGS= -Wstrict-prototypes -O0 -g 
all: run
test: test.c
 $(CC) $(CFLAGS) -o $@ $< -ldl
test_static.o: test_static.c
 $(CC) $(CFLAGS) -fPIC -c $< -o $@
test_shared.o: test_shared.c
 $(CC) $(CFLAGS) -fPIC -c $< -o $@
libtest_static.a: test_static.o
 ar -crv $@ $<
libtest_shared.so: test_shared.o libtest_static.a
 $(CC) $(CFLAGS) -fPIC -shared -o $@ -Wl,-soname,$@ $< -L. -ltest_static
run: libtest_shared.so test 
 @echo "----------running test--------------"
 -LD_LIBRARY_PATH=`pwd`:. ./test
clean:
 rm *.so *.o *.a test 



Compile and run:

using uClibc failed with follow message:
#make
 -O0 -g  -fPIC -c test_shared.c -o test_shared.o
 gcc -O0 -g  -fPIC -c test_static.c -o test_static.o
 ar -crv libtest_static.a test_static.o
 a - test_static.o
 gcc -O0 -g  -fPIC -shared -o libtest_shared.so -Wl,-soname,libtest_shared.so test_shared.o -L. -ltest_static
 gcc -O0 -g  -o test test.c -ldl
 ----------running test--------------
 LD_LIBRARY_PATH=`pwd`:. ./test
 dlsym success 
 test_shared1
 test_s1 
 dlsym success 
 test_shared2
 make: *** [run] Floating point exception
 
but using glibc do the same thing, all ok, why?
 
Best Regards,
 
    Qingjun sun
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20031017/0c376eb5/attachment.htm 


More information about the uClibc mailing list