commit 34174e2ca8cb61150d3d880400d8231a39d38307 Author: Alexandre Julliard julliard@winehq.org Date: Wed Feb 24 13:36:41 2016 +0900
libport: Mark internal functions and data tables as hidden.
This patch breaks the compilation on Solaris 11.11:
ld: fatal: relocation error: R_386_GOTOFF: file ../../libs/port/libwine_port.a(fold.o): symbol wine_digitmap: a GOT relative relocation must reference a local symbol ld: fatal: relocation error: R_386_GOTOFF: file ../../libs/port/libwine_port.a(fold.o): symbol wine_compatmap: a GOT relative relocation must reference a local symbol
Removing the DECLSPEC_HIDDEN on wine_digitmap(), wine_compatmap() but also wine_compose() and wine_decompose() fixes this. As far as I can tell the linker considers that hidden symbols are not visible outside the static library.
Francois Gouget fgouget@free.fr writes:
Removing the DECLSPEC_HIDDEN on wine_digitmap(), wine_compatmap() but also wine_compose() and wine_decompose() fixes this. As far as I can tell the linker considers that hidden symbols are not visible outside the static library.
Do you mean you have to remove it from all 4 symbols? Or only from the data tables? Or only from the extern declarations?
On Tue, 1 Mar 2016, Alexandre Julliard wrote:
Francois Gouget fgouget@free.fr writes:
Removing the DECLSPEC_HIDDEN on wine_digitmap(), wine_compatmap() but also wine_compose() and wine_decompose() fixes this. As far as I can tell the linker considers that hidden symbols are not visible outside the static library.
Do you mean you have to remove it from all 4 symbols? Or only from the data tables? Or only from the extern declarations?
I had not tried to remove it only from the externs. It seems to do the trick, except for wine_decompose() in libs/port/decompose.c where I get the following error if I don't remove the DECLSPEC_HIDDEN:
gcc -o libwine.so.1.0 casemap.o collation.o config.o debug.o ldt.o loader.o mmap.o port.o sortkey.o string.o \ wctype.o version.o -shared -Wl,-soname,libwine.so.1 ../../libs/port/libwine_port.a -lsocket -lnsl \
Text relocation remains referenced against symbol offset in file wine_decompose 0x76 ../../libs/port/libwine_port.a(decompose.o)
I've included what seems to be the minimal patch below:
diff --git a/libs/port/decompose.c b/libs/port/decompose.c index 34e83ec..3e4a28b 100644 --- a/libs/port/decompose.c +++ b/libs/port/decompose.c @@ -747,7 +747,7 @@ static const WCHAR table[4704] = 0x05d1, 0x05bf, 0x05db, 0x05bf, 0x05e4, 0x05bf, 0x0000, 0x0000 };
-unsigned int DECLSPEC_HIDDEN wine_decompose( WCHAR ch, WCHAR *dst, unsigned int dstlen ) +unsigned int wine_decompose( WCHAR ch, WCHAR *dst, unsigned int dstlen ) { const WCHAR *ptr = table + table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + 2 * (ch & 0xf); unsigned int res; diff --git a/libs/port/fold.c b/libs/port/fold.c index 738469c..87a4a41 100644 --- a/libs/port/fold.c +++ b/libs/port/fold.c @@ -22,13 +22,13 @@
static inline WCHAR to_unicode_digit( WCHAR ch ) { - extern const WCHAR wine_digitmap[] DECLSPEC_HIDDEN; + extern const WCHAR wine_digitmap[]; return ch + wine_digitmap[wine_digitmap[ch >> 8] + (ch & 0xff)]; }
static inline WCHAR to_unicode_native( WCHAR ch ) { - extern const WCHAR wine_compatmap[] DECLSPEC_HIDDEN; + extern const WCHAR wine_compatmap[]; return ch + wine_compatmap[wine_compatmap[ch >> 8] + (ch & 0xff)]; }
diff --git a/libs/port/mbtowc.c b/libs/port/mbtowc.c index fd7764e..9a4bc23 100644 --- a/libs/port/mbtowc.c +++ b/libs/port/mbtowc.c @@ -22,7 +22,7 @@
#include "wine/unicode.h"
-extern unsigned int wine_decompose( WCHAR ch, WCHAR *dst, unsigned int dstlen ) DECLSPEC_HIDDEN; +extern unsigned int wine_decompose( WCHAR ch, WCHAR *dst, unsigned int dstlen );
/* check the code whether it is in Unicode Private Use Area (PUA). */ /* MB_ERR_INVALID_CHARS raises an error converting from 1-byte character to PUA. */ diff --git a/libs/port/utf8.c b/libs/port/utf8.c index f47561e..5943dda 100644 --- a/libs/port/utf8.c +++ b/libs/port/utf8.c @@ -22,7 +22,7 @@
#include "wine/unicode.h"
-extern WCHAR wine_compose( const WCHAR *str ) DECLSPEC_HIDDEN; +extern WCHAR wine_compose( const WCHAR *str );
/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */ static const char utf8_length[128] = diff --git a/libs/port/wctomb.c b/libs/port/wctomb.c index 65e4aa0..e7f35e5 100644 --- a/libs/port/wctomb.c +++ b/libs/port/wctomb.c @@ -22,7 +22,7 @@
#include "wine/unicode.h"
-extern WCHAR wine_compose( const WCHAR *str ) DECLSPEC_HIDDEN; +extern WCHAR wine_compose( const WCHAR *str );
/****************************************************************/ /* sbcs support */
Francois Gouget fgouget@free.fr writes:
I had not tried to remove it only from the externs. It seems to do the trick, except for wine_decompose() in libs/port/decompose.c where I get the following error if I don't remove the DECLSPEC_HIDDEN:
gcc -o libwine.so.1.0 casemap.o collation.o config.o debug.o ldt.o loader.o mmap.o port.o sortkey.o string.o \ wctype.o version.o -shared -Wl,-soname,libwine.so.1 ../../libs/port/libwine_port.a -lsocket -lnsl \
Text relocation remains referenced against symbol offset in file wine_decompose 0x76 ../../libs/port/libwine_port.a(decompose.o)
I've included what seems to be the minimal patch below:
Is wine_compose also an issue, even though it's not called from libwine?
On Tue, 1 Mar 2016, Alexandre Julliard wrote:
Francois Gouget fgouget@free.fr writes:
I had not tried to remove it only from the externs. It seems to do the trick, except for wine_decompose() in libs/port/decompose.c where I get the following error if I don't remove the DECLSPEC_HIDDEN:
gcc -o libwine.so.1.0 casemap.o collation.o config.o debug.o ldt.o loader.o mmap.o port.o sortkey.o string.o \ wctype.o version.o -shared -Wl,-soname,libwine.so.1 ../../libs/port/libwine_port.a -lsocket -lnsl \
Text relocation remains referenced against symbol offset in file wine_decompose 0x76 ../../libs/port/libwine_port.a(decompose.o)
I've included what seems to be the minimal patch below:
Is wine_compose also an issue, even though it's not called from libwine?
Yes. It's strange. If I remove the wine_compose() parts of the patch I get:
gcc -o libwine.so.1.0 casemap.o collation.o config.o debug.o ldt.o loader.o mmap.o port.o sortkey.o string.o \ wctype.o version.o -shared -Wl,-soname,libwine.so.1 ../../libs/port/libwine_port.a -lsocket -lnsl \
Text relocation remains referenced against symbol offset in file wine_compose 0x7ce ../../libs/port/libwine_port.a(utf8.o) wine_compose 0x8df ../../libs/port/libwine_port.a(utf8.o) wine_compose 0x75f ../../libs/port/libwine_port.a(wctomb.o) wine_compose 0x8ec ../../libs/port/libwine_port.a(wctomb.o) wine_compose 0x9a9 ../../libs/port/libwine_port.a(wctomb.o) wine_compose 0xa89 ../../libs/port/libwine_port.a(wctomb.o) ld: fatal: relocations remain against allocatable but non-writable sections
I'm trying a Solaris upgrade to see if it makes a difference.
On Tue, 1 Mar 2016, Francois Gouget wrote: [...]
I'm trying a Solaris upgrade to see if it makes a difference.
The upgrade made no difference :-( gcc seems to be using the Solaris linker which had no update rather than GNU ld.
On Tue, 1 Mar 2016, Francois Gouget wrote:
On Tue, 1 Mar 2016, Francois Gouget wrote: [...]
I'm trying a Solaris upgrade to see if it makes a difference.
The upgrade made no difference :-( gcc seems to be using the Solaris linker which had no update rather than GNU ld.
So the problem is that on Solaris gcc does not really support the visibility attribute. This typically yields lots of harmless 'visibility attribute not supported in this configuration' warnings. But while there is no .hidden attribute in the assembly code, the attribute still impacts the assembly. For instance:
- movl wine_digitmap@GOT(%ebx), %eax + leal wine_digitmap@GOTOFF(%ebx), %eax and - call wine_decompose@PLT + call wine_decompose
This change is what causes these errors: * 'relocation error: R_386_GOTOFF' for the tables and 'read-only segment has dynamic relocations' with the Solaris linker (5.11-1.2458). * 'relocations remain against allocatable but non-writable sections' in both cases with the GNU linker (2.23.1, LD_ALTEXEC=/usr/sfw/bin/gld).
Given that the visibility attribute does not work it seems like the best would be to not use it.
* One could check for it with autoconf. But autoconf macros are not allowed in Wine's headers (for good reason). https://stackoverflow.com/questions/5987219/best-practices-for-probing-for-s...
* Or we could let the user decide whether he really wants to hide symbols by providing him with a NO_HIDDEN_SYMBOLS macro in winnt.h. This would sort of be the equivalent of the NONAMELESSSTRUCT macros. Then of course we would immediately turn around and use autoconf to decide whether to set it when compiling Wine so it's not all that different from the above option.
* Another option would be to check for __sun in winnt.h:
-#elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) +#elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
The drawback is it means we will never use the visibility attribute on Solaris, even if it is supported (one day or in some configuration). That's probably a very minor drawback and it seems like the simplest solution so maybe this would make sense.
Thoughts?
Francois Gouget fgouget@free.fr writes:
Another option would be to check for __sun in winnt.h:
-#elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) +#elif defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) && !defined(__sun)
The drawback is it means we will never use the visibility attribute on Solaris, even if it is supported (one day or in some configuration). That's probably a very minor drawback and it seems like the simplest solution so maybe this would make sense.
Yes, that would be fine.