> [Argh, you made a multiposting to comp.unix.solaris!]
> > I'm using g++ 2.95.3 on Solaris 8. I need to build a shared library
> > that pulls in some non-PIC objects from an archive library.
> > The problem is g++ -shared passes -z text to ld and that makes the
> > link fail.
> > [...]
> > Why is it passing -z text on Solaris by default anyway
> > since Solaris allows non-PIC shared libraries?
> Unfortunately "-Wl,-z,textoff" is incompatible with "-z text".
> "-z text" is taken from the "specs" file.
> I haven't found anything about how to override specs-settings
> from the command line. Am i overlooking the obvious?
> gcc has the original specs file also "compiled in".
> So you could move it away and edit a copy of the binary
> for special purposes, both version would work, but different.
This "specs" file led me to a few solutions.
1. There is a g++ global link_spec which contains the link command
options. There are other such variables in gcc.c. They can be patched
in the binary using gdb as you suggest. But ...
2. g++ -v displays the line:
Reading specs from etc./etc./specs
It turns out the specs are actually read in from a file! And what's more
g++ -specs=<file> will read specs from any file you want.
So all I had to do was remove the -z text option from the *link: line
in the specs file and I got what I wanted! Also ...
3. The original link line in the specs file indicated there is an option
that controls whether -z text is implicit with -shared or not. The option
is -mimpure-text and it seems to be undocumented. So I can use that
instead of providing my specs file. Of course since it is undocumented
it may change in the future.
> $ ./gcc -shared -o liblib1.so lib1.o
> $ gcc -shared -o liblib1.so lib1.o
> Text relocation remains [...]