public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* SunOS shared libs ?
@ 1998-06-09  7:48 Munagala V. S. Ramanath
  1998-06-10  4:39 ` Manfred Hollstein
  0 siblings, 1 reply; 14+ messages in thread
From: Munagala V. S. Ramanath @ 1998-06-09  7:48 UTC (permalink / raw)
  To: egcs

Hi,

I'm getting the following failure when trying to build a shared library
on SunOS 4.1.2 with egcs-1.0.2:

ld: /usr/tmp/cca08998.o: assert pure-text failed: reference to [offset] at e5c in /usr/tmp/cca08998.o

    ...[several more messages of the same type] ...

The command was something like this:
    gcc -g -shared -o libXX.so *.o
The .o files were all compiled like this:
    gcc -g -O2 -ansi -pedantic -fPIC -c xyz.c

Using -fpic instead of -fPIC or using both makes no difference.

This works fine with gcc-2.7.2.

I didn't see anything in the FAQ about this. This problem occurs when
building my own code as well as when trying to build the FreeType
library. Others have reported the same problem to the freetype mailing
lists, so the problem does not appear to be due to any local
peculiarities of my setup.

Is this a known bug in egcs or is there some other linker or compiler
option that is needed ?

Any help is appreciated.

Ram

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: SunOS shared libs ?
@ 1998-06-10  7:36 Munagala V. S. Ramanath
  1998-06-10 12:47 ` Manfred.Hollstein
  0 siblings, 1 reply; 14+ messages in thread
From: Munagala V. S. Ramanath @ 1998-06-10  7:36 UTC (permalink / raw)
  To: Manfred.Hollstein, manfred, ram; +Cc: egcs

> You need to add "-fPIC" to the linker command line  as well. If any of
> your  *.o files  contain  static CTOR/DTORs, a   small .c file will be
> generated by the  collect2 program which  in turn will be compiled and
> linked into  your shared lib.  Since you  didn't specify "-fPIC"  when
> linking, bloody  StunOS ld starts complaining...  Of course, using GNU
> ld (e.g. from  binutils-2.9.1) would cure  this; the current  mainline
> sources (the  snapshots)  address  this   differently, i.e.  you   can
> continue using SunOS ld.

    Ok, thanks that seems to have fixed the problem. I'd strongly
    suggest adding this to the FAQ.

    I still don't understand a couple of items:
    -- My files are all C (no C++) so there is CTOR/DTOR issue at all;
       how come I still need the -fPIC linker option ?
    -- How come I did not need -fPIC linker option with gcc-2.7.2 ?

    Anyway, thanks for the help.

    Ram

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: SunOS shared libs ?
@ 1998-07-08  7:59 Munagala V. S. Ramanath
  1998-06-11 11:04 ` Manfred Hollstein
  1998-07-08 22:15 ` Jeffrey A Law
  0 siblings, 2 replies; 14+ messages in thread
From: Munagala V. S. Ramanath @ 1998-07-08  7:59 UTC (permalink / raw)
  To: Manfred.Hollstein, law, manfred, ram; +Cc: egcs

>  >     I still don't understand a couple of items:
>  >     -- My files are all C (no C++) so there is CTOR/DTOR issue at all;
>  >        how come I still need the -fPIC linker option ?
>  >     -- How come I did not need -fPIC linker option with gcc-2.7.2 ?
> 
> Looks like your pulling in some C++ related stuff, e.g. via libgcc.a?
> 
> Try adding `-Wl,-debug' to your linker command; it'll tell you lots of
> information about which CTOR/DTORs have been found and the like.

Ok, here is the entirety of the output from the linker with the
"-Wl,-debug" option added; as you can see, it reports no CTOR/DTOR
found:

----------- CUT HERE --------------------------- CUT HERE -------------
gcc -g -fPIC -Wl,-debug -shared -o ../../../lib/libtype1.so dosubr.o enc.o objects.o newpath.o regions.o scanfont.o spaces.o t1api.o t1io.o token.o type1.o util.o
collect2 version egcs-2.90.27 980315 (egcs-1.0.2 release) (sparc)
ld_file_name        = /usr/bin/ld
c_file_name         = /d2a/exper/bin/gcc
nm_file_name        = /usr/bin/nm
strip_file_name     = /usr/bin/strip
c_file              = /usr/tmp/cca09472.c
o_file              = /usr/tmp/cca09472.o
COLLECT_NAMES       = /d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27/ld
COLLECT_GCC_OPTIONS = '-g' '-fPIC' '-shared' '-o' '../../../lib/libtype1.so'
COLLECT_GCC         = gcc
COMPILER_PATH       = /d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/:/usr/lib/gcc/sparc-sun-sunos4.1.2/egcs-2.90.27/:/usr/lib/gcc/sparc-sun-sunos4.1.2/:/d2a/exper/sparc-sun-sunos4.1.2/bin/sparc-sun-sunos4.1.2/egcs-2.90.27/:/d2a/exper/sparc-sun-sunos4.1.2/bin/
LIBRARY_PATH        = /d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/usr/lib/gcc/sparc-sun-sunos4.1.2/egcs-2.90.27/:/d2a/exper/sparc-sun-sunos4.1.2/lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/d2a/exper/sparc-sun-sunos4.1.2/lib/:/d2a/exper/lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/d2a/exper/lib/:/lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/lib/:/usr/lib/sparc-sun-sunos4.1.2/egcs-2.90.27/:/usr/lib/

/usr/bin/ld -assert pure-text -o ../../../lib/libtype1.so -L/d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27/ucpic -L/d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27 -L/d2a/exper/sparc-sun-sunos4.1.2/lib/ucpic -L/d2a/exper/sparc-sun-sunos4.1.2/lib -L/d2a/exper/lib/ucpic -L/d2a/exper/lib dosubr.o enc.o objects.o newpath.o regions.o scanfont.o spaces.o t1api.o t1io.o token.o type1.o util.o -lgcc -lgcc
 /usr/bin/nm -p ../../../lib/libtype1.so

nm output with constructors/destructors.

dynamic dependencies.

0 constructor(s) found
0 destructor(s)  found
[Leaving ../../../lib/libtype1.so]

write_c_file - output name is ../../../lib/libtype1.so, prefix is libtype1_so

========== output_file = ../../../lib/libtype1.so, c_file = /usr/tmp/cca09472.c
#ifdef __cplusplus
extern "C" {
#endif

write_c_file - output name is ../../../lib/libtype1.so, prefix is libtype1_so
static int count;
typedef void entry_pt();
void _GLOBAL__FI_libtype1_so() {
        ++count;
}
void _GLOBAL__FD_libtype1_so() {
}
void _GLOBAL__DI() {
        _GLOBAL__FI_libtype1_so();
}
void _GLOBAL__DD() {
        _GLOBAL__FD_libtype1_so();
}
#ifdef __cplusplus
}
#endif
========== end of c_file

/d2a/exper/bin/gcc -c -o /usr/tmp/cca09472.o -fPIC -fno-exceptions /usr/tmp/cca09472.c
/usr/bin/ld -assert pure-text -o ../../../lib/libtype1.so -L/d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27/ucpic -L/d2a/exper/lib/gcc-lib/sparc-sun-sunos4.1.2/egcs-2.90.27 -L/d2a/exper/sparc-sun-sunos4.1.2/lib/ucpic -L/d2a/exper/sparc-sun-sunos4.1.2/lib -L/d2a/exper/lib/ucpic -L/d2a/exper/lib dosubr.o /usr/tmp/cca09472.o enc.o objects.o newpath.o regions.o scanfont.o spaces.o t1api.o t1io.o token.o type1.o util.o -lgcc -lgcc
[Leaving /usr/tmp/cca09472.c]
[Leaving /usr/tmp/cca09472.o]
----------- CUT HERE --------------------------- CUT HERE -------------

Ram

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: SunOS shared libs ?
@ 1998-07-09  8:45 Munagala V. S. Ramanath
  1998-07-09 10:46 ` Jeffrey A Law
  0 siblings, 1 reply; 14+ messages in thread
From: Munagala V. S. Ramanath @ 1998-07-09  8:45 UTC (permalink / raw)
  To: law, ram; +Cc: Manfred.Hollstein, egcs, manfred

    Jeffrey A Law <law@hurl.cygnus.com> writes:

>   In message < 199806101546.IAA05334@netcom13.netcom.com >you write:
>   > write_c_file - output name is ../../../lib/libtype1.so, prefix is libtype1_
>   > so
>   > static int count;
>   > typedef void entry_pt();
>   > void _GLOBAL__FI_libtype1_so() {
>   >         ++count;
>   > }
> Here's the reason why you still need the -fPIC option when building
> a shared library out of just pure C code.  The reference to "count"
> must be PIC.  I don't know why we need to increment that counter.
> Someone familiar with C++ and collect2 would have to comment.
> 
> jeff

    Thanks for the response but my message was several weeks old and
    had already been answered by Manfred; it somehow got recirculated
    to the list; I have no idea how that happened (I did not resend it).

    Ram

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1998-07-10  7:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-09  7:48 SunOS shared libs ? Munagala V. S. Ramanath
1998-06-10  4:39 ` Manfred Hollstein
1998-06-10  7:36 Munagala V. S. Ramanath
1998-06-10 12:47 ` Manfred.Hollstein
1998-06-10  9:23   ` Jeffrey A Law
1998-06-11 11:04     ` Manfred Hollstein
1998-07-08  7:59 Munagala V. S. Ramanath
1998-06-11 11:04 ` Manfred Hollstein
1998-07-08 22:15 ` Jeffrey A Law
1998-07-09  9:13   ` Manfred Hollstein
1998-07-09 22:16     ` Jeffrey A Law
1998-07-10  7:01       ` Manfred Hollstein
1998-07-09  8:45 Munagala V. S. Ramanath
1998-07-09 10:46 ` Jeffrey A Law

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).