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: Olaf Dietrich
Subject: Re: [Tinycc-devel] linux/unix shared libraries?
Date: Wed, 23 Apr 2008 09:52:09 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

grischka (2008-04-22T18:55:04+0200):
> 
> I don't know why you used -r to TCC, but anyway it works 
> both with and without.

I don't see any difference either: "segmentation fault" also without -r.


Simple questions first:

> Can you run anything build with TCC at all?

Yes! No problem without shared libs:

$ tcc -c mylib.c -o mylib.o
$ tcc testlib.c mylib.o -o testlib
$ ./testlib 
12345


And the test after building tcc seems to be okay as well:

/tmp/tcc-0.9.24$ make test
Auto Test OK


I have not much experience with gdb, but perhaps the
following might give some hints:

-----------------------------------------------------------------------
$ tcc -g -shared mylib.c -o libmylib.so
$ tcc -g testlib.c -L. -lmylib -o testlib
$ gdb ./testlib
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...BFD: /home/olaf/tcc_test/testlib: 
no group info for section .text.__i686.get_pc_thunk.bx
BFD: /home/olaf/tcc_test/testlib: no group info for section 
.text.__i686.get_pc_thunk.bx
Dwarf Error: bad offset (0xac) in compilation unit header (offset 0x110 + 6) 
[in module /home/olaf/tcc_test/testlib]

(gdb) run
Starting program: /home/olaf/tcc_test/testlib 
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
0xb7f3fd60 in ?? ()
(gdb) quit
The program is running.  Exit anyway? (y or n) y
$ 
-----------------------------------------------------------------------


Anything else I might try?


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




reply via email to

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