Re: libpq's pollution of application namespace - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: libpq's pollution of application namespace
Date
Msg-id 20051017161557.GB26773@svana.org
Whole thread Raw
In response to libpq's pollution of application namespace  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: libpq's pollution of application namespace
Re: libpq's pollution of application namespace
List pgsql-hackers
On Sun, Oct 16, 2005 at 06:21:37PM -0400, Tom Lane wrote:
> I find that libpq.so exports the following symbols that have neither
> PQ, pq, pg, nor lo_ as a prefix:

<snip>

> It'd be nicer if we could filter out all exported symbols that don't
> appear in exports.txt, but I don't know any portable way to do that.

With GNU LD it is trivial, using the --version-script command. If you
use AWK to create the script from exports.txt like so:

awk 'BEGIN { print "{ global: " } { if( $1 != "#" ) {print $1,";"} } END { print "local: *; };" }' <exports.txt
>exports.version

And then add "-Wl,--version-script,exports.version" to the link
command, viola, stray symbols removed. Given we already have a
configure test for GNU ld, it wouldn't be too hard to make it work for
them. For windows it already uses exports.txt. What other linkers do we
need to support?

Another possibility would be to use strip like so:

strip -w -K PQ* -K pq* -K pg* -K lo_* -K *PQ* -o output.so

But then, that may be a GNU strip extention... And it doesn't follow
the exports file then.

Recent gcc versions support visibility directives in the source code but
that's a lot more work (although doing it in the code would produce a
more efficient library). And not portable to other compilers either...

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Possible issue with win32 installer(8.1beta 3)...
Next
From: Tom Lane
Date:
Subject: Re: libpq's pollution of application namespace