Il 05/03/2014 16:53, Rainer Orth ha scritto:
When using GNU as with Solaris ld, the TLS local dynamic tests
(gcc.dg/torture/tls/run-ld.c etc.) FAIL to execute before Solaris 11:
the programs crash with an illegal instruction: e.g. in the
gcc.dg/lto/20090210 test, we have

0x8050ce0 <main+48>: mov    %gs:0x0,%eax
0x8050ce6 <main+54>: call   0x8050ce7 <main+55>
0x8050ce7 <main+55>: cld
0x8050ce8 <main+56>: (bad)

The reason is that Solaris ld before Solaris 11 requires the use of the
@tlsldmplt relocation documented in the Solaris 10 Linker and Libraries
Guide:

http://docs.oracle.com/cd/E26505_01/html/E26506/chapter8-20.html#gentextid-23600

Unfortunately, gas doesn't support that relocation.  While adding the
gas side was easy, I completely failed for gld and didn't propose the
incomplete patch to binutils since it would (rightly) have been
rejected.

Old versions of ld mishandle the TLS LD code sequence emitted by gcc
when @tlsldmplt isn't available, causing the crashes observed.  So ld
cannot handle what gas emits and gas cannot emit what ld requires.  The
only solution seems to fall back to the GD model in that case, which is
ugly but certainly better than having perfectly valid programs crash.

The following patch does just that.  It carefully restricts its actions
to Solaris.  I'm falling back to using dis when objdump isn't available
to avoid enabling this fallback unnecessarily.

Bootstraps on i386-pc-solaris2.{9,10,11} (as/ld, gas/ld, gas/gld,
as/gld), amd64-pc-solaris2.{10,11} (as/ld, gas/ld),
x86_64-unknown-linux-gnu, and i686-unknown-linux-gnu either completed
successfully or still running.

Ok for mainline if those pass?

Thanks.
        Rainer


2014-03-04  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

        * configure.ac (TLS_SECTION_ASM_FLAG): Save as tls_section_flag.
        (LIB_TLS_SPEC): Save as ld_tls_libs.
        (HAVE_AS_IX86_TLSLDMPLT): Define as 1/0.
        (HAVE_AS_IX86_TLSLDM): New test.
        * configure, config.in: Regenerate.
        * config/i386/i386.c (legitimize_tls_address): Fall back to
        TLS_MODEL_GLOBAL_DYNAMIC on 32-bit Solaris/x86 if tool chain
        cannot support TLS_MODEL_LOCAL_DYNAMIC.
        * config/i386/i386.md (*tls_local_dynamic_base_32_gnu): Use if
        instead of #ifdef in HAVE_AS_IX86_TLSLDMPLT test.





Looks good.

Perhaps GCC would gain from having a separate maintainer for the gcc/ target-specific configuration (configure.ac/config.gcc/config/*/*.h basically)... guess who I would propose for such a role :)

Paolo

Reply via email to