Re: libpq's pollution of application namespace

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: libpq's pollution of application namespace
Date: 2005-10-17 16:15:57
Message-ID: 20051017161557.GB26773@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-10-17 16:20:06 Re: libpq's pollution of application namespace
Previous Message Andrew Dunstan 2005-10-17 16:05:31 Re: Possible issue with win32 installer(8.1beta 3)...