Skip to Content.
Sympa Menu

freetds - Re: [freetds] freetds on solaris 11: symbol scope specifies local binding (same problem)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] freetds on solaris 11: symbol scope specifies local binding (same problem)
  • Date: Thu, 3 Oct 2013 09:44:08 +0100

2013/10/3 James K. Lowden <jklowden AT freetds.org>:
> On Tue, 1 Oct 2013 09:02:47 -0700
> Justin T Pryzby <justinp AT norchemlab.com> wrote:
>
>> I ran gobjdump -t, and found that strlen had a "hidden" attribute; I
>> noticed that ctlib.h sets gcc attribute "hidden":
>> #pragma GCC visibility push(hidden)
>>
>> I was able to compile TDS by moving the include file outside of the
>> hidden "stack"; not sure if that's correct, but "works for me".
>>
>> $ diff -U1 freetds-0.91{.orig,}/include/ctlib.h
>> --- freetds-0.91.orig/include/ctlib.h Tue Oct 5 01:36:36 2010
>> +++ freetds-0.91/include/ctlib.h Tue Oct 1 08:58:01 2013
>> @@ -26,2 +26,4 @@
>>
>> +#include <tds.h>
>> +
>> #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
>> @@ -41,3 +43,2 @@
>>
>> -#include <tds.h>
>> /*
>
> I don't know what Frediano will say, but IMO that is the right fix.
> Well done!
>

Great! Yes, it's a mistake to include headers inside modified visibility!

> tds.h has its own visibility guard, and notably it appears after
> the line that includes stddef.h. It would seem that on Solaris the
> hidden attribute is applied to standard library functions, and on Linux
> it's not.
>
> I've never paid much attention to symbol visibility management; I've
> always felt that by taking some care with the choice of names, the
> probability of conflict was small. And I prefer to write strictly
> standard C, and not delve into proprietary GNU features.
>

I started using visibility after I read an article on C++ and dso
loading. It's not just a question of naming clashing. You end up with
faster load, smaller executables and every a bit faster! The reason is
that linker does not generate PLT but bind function directly. Also all
global symbols are stripped from final executable.

For C it does not reach the extreme 40% difference of some C++
libraries but at the end are just a couple of lines in header files.

> If we're going to employ the visibility attribute, though, it would
> seem a good idea to make sure it never appears above an #include
> statement. Thankfully,
>
> $ for F in include/*.h src/*/*.[ch]; do sed -ne '/GCC *visibility/,$p'
> $F | grep '^# *include' && echo $F ; done
> #include <freetds/tds.h>
> include/ctlib.h
>
> you found the single case where that didn't hold.
>
> Mystery solved and we learned something. A good day.
>
> --jkl

Wonderful!

Frediano




Archive powered by MHonArc 2.6.24.

Top of Page