tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] linux/unix shared libraries?


From: grischka
Subject: Re: [Tinycc-devel] linux/unix shared libraries?
Date: Tue, 22 Apr 2008 18:55:04 +0200

From: "Olaf Dietrich":
> grischka (2008-04-21T18:07:35+0200):
> > Works for me. (on ubuntu 6.02)
>
>
> That's good news - so what might go wrong here?
> Did I use the appropriate compiler/linker options?

I don't know why you used -r to TCC, but anyway it works 
both with and without.

> (Are you saying that you did exactly the same
> things that I did, or that you were (somehow) able
> to build a shared library?)

Yes, somehow exactly. Here:

  $ tcc mylib.c -o libmylib.so -shared
  $ tcc testlib.c -o testlib libmylib.so
  $ LD_LIBRARY_PATH=. ldd -r -d ./libmylib.so
      linux-gate.so.1 =>  (0xffffe000)
      libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dfb000)
      /lib/ld-linux.so.2 (0x80000000)
  $ LD_LIBRARY_PATH=. ldd -r -d ./testlib
      linux-gate.so.1 =>  (0xffffe000)
      libmylib.so => ./libmylib.so (0xb7ef0000)
      libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7db6000)
      /lib/ld-linux.so.2 (0xb7ef5000)
  $ LD_LIBRARY_PATH=. ./testlib
  12345
  $ uname -a
  Linux ubuntu 2.6.15-23-386 #1 PREEMPT Tue May 23 13:49:40 UTC 2006 i686 
GNU/Linux

Also I did other sligtly more advanced tests with .so and dlopen/dlsym 
in the past, and didn't see any problems so far.

> If I display the shared library dependencies of the files
> compiled/linked with tcc; I get:
>
> $ ldd libmylib.so
>         linux-gate.so.1 =>  (0xb7f01000)
>         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dc2000)
>         /lib/ld-linux.so.2 (0x80000000)
> $ ldd testlib
>         linux-gate.so.1 =>  (0xb7fb4000)
>         libmylib.so => /home/olaf/tcc_test/libmylib.so (0xb7fb0000)
>         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e75000)
>         /lib/ld-linux.so.2 (0xb7fb5000)
>
> which looks pretty similar to the results after
> building with gcc.
>
> However, with the additional -r or -d switch, the result is:
>
> $ ldd -d -r libmylib.so
> /usr/bin/ldd: line 117: 21091 Segmentation fault      
> LD_TRACE_LOADED_OBJECTS=1 LD_WARN=yes
LD_BIND_NOW=yes LD_LIBRARY_VERSION=$verify_out LD_VERBOSE= "$@"
>         linux-gate.so.1 =>  (0xb7f58000)
>         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e19000)
>         /lib/ld-linux.so.2 (0x80000000)
> $ ldd -d -r testlib
> /usr/bin/ldd: line 117: 21096 Segmentation fault      
> LD_TRACE_LOADED_OBJECTS=1 LD_WARN=yes
LD_BIND_NOW=yes LD_LIBRARY_VERSION=$verify_out LD_VERBOSE= "$@"
>         linux-gate.so.1 =>  (0xb7f1c000)
>         libmylib.so => /home/olaf/tcc_test/libmylib.so (0xb7f18000)
>         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ddd000)
>         /lib/ld-linux.so.2 (0xb7f1d000)
>
> (again some "segmentation faults").

> Any suggestions what to try?
> 
> (The system here is a Debian stable with
>  "/lib/libc.so.6 -> libc-2.3.6.so".)
> 

Can you run anything build with TCC at all?

--- grischka

> 
> Olaf
> 
> 
> 
> > From: "Olaf Dietrich":
> > > The simple question is: Is it or has it ever been possible to
> > > compile shared libraries with tcc under linux/unix?
> > >
> > > Here is a very simple test case:
> > >
> > >
> > > $ cat mylib.c
> > >
> > > int func(void)
> > > {
> > >         return 12345;
> > > }
> > >
> > >
> > > $ cat testlib.c
> > >
> > > #include <stdio.h>
> > >
> > > extern int func(void);
> > >
> > > int main(void) {
> > >         printf("%d\n", func());
> > >         return 0;
> > > }
> > >
> > >
> > > Using gcc, I can simply compile these files and
> > > obtain a working shared library:
> > >
> > > $ export LD_LIBRARY_PATH=`pwd`
> > > $ gcc -fPIC -shared mylib.c -o libmylib.so
> > > $ gcc testlib.c -L. -lmylib -o testlib
> > > $ ./testlib
> > > 12345
> > >
> > > How can I do the same thing with tcc? I tried:
> > >
> > > $ export LD_LIBRARY_PATH=`pwd`
> > > $ tcc -r -shared mylib.c -o libmylib.so
> > > $ tcc testlib.c -L. -lmylib -o testlib
> > > $ ./testlib
> > > Segmentation fault
>
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]