Windows targets that use emutls add a "." character as a separator from the
_emutls_{t,v} and the true symbol name.  However, exporting these symbol names
from a DLL is problematic (i.e. a thread local data variable), because the "."
in the symbol name tells the Windows loader to treat the symbol as a forwarding
RVA to a second DLL (in this case, it will look for the symbol "varname" in
__emutls_v.dll, the symbol exported is __emutls_v.varname).  Note that this is
a runtime issue, not a compile/link issue.

This can be worked around by

#define TARGET_EMUTLS_VAR_PREFIX "__emutls_v_"
#define TARGET_EMUTLS_TMPL_PREFIX "__emutls_t_"

in the config header (e.g. config/i386/cygming.h or config/i386/mingw-w64.h,
etc).

However, this breaks backward compatibility with object files that were built
with previous versions of the compiler (e.g libold.a would have a global name
of __emutls_v.varname, while the patch would cause gcc to look for
__emutls_v_varname, which would cause linker errors).


-- 
           Summary: Exporting emutls symbols from a DLL broken on w32
                    targets
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dougsemler at gmail dot com
GCC target triplet: i686-pc-mingw32 x86_64-*-mingw32 i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44139

Reply via email to