Re: freetds on solaris 11: symbol scope specifies local binding (same problem)
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <CAHt6W4cSE5=NboRZUT4Xed92GkCY1Vq4JoLsQouYJbC15VM2EA@mail.gmail.com> |
2013/10/3 James K. Lowden <[email protected]>: > On Tue, 1 Oct 2013 09:02:47 -0700 > Justin T Pryzby <[email protected]> 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