------- Comment #12 from ro at CeBiTec dot Uni-Bielefeld dot DE  2010-03-09 
19:14 -------
Subject: Re:  amd64 TLS IE code sequence on Solaris 2/x86 violates spec

> ------- Comment #11 from hjl dot tools at gmail dot com  2010-03-09 18:45 
> -------
> Sun linker changes
>
>    4:   64 48 8b 14 25 00 00 00 00      mov    %fs:0x0,%rdx
>    d:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 14 <main+0x14> 
>  
> 10: R_X86_64_GOTTPOFF   cnt-0x4
>
> to
>
>   400e0c:       64 48 8b 04 25 00 00 00 00      mov    %fs:0x0,%rax
>   400e15:       48 8d 80 f0 ff ff ff    lea    -0x10(%rax),%rax
>
> Nowhere in TLS spec allows the linker to change
>
>    d:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 14 <main+0x14> 
>  
> 10: R_X86_64_GOTTPOFF   cnt-0x4
>
> to
>
>  400e15:       48 8d 80 f0 ff ff ff    lea    -0x10(%rax),%rax
>
> It is Sun linker bug. Please report it to them.

True, this is a bug, but the input sequence isn't valid according to the
spec: 

    4:   64 48 8b 14 25 00 00 00 00      mov    %fs:0x0,%rdx
    d:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 14 <main+0x14>  

This should be

                                         mov    %fs:0x0,%rax

instead.  As I said, garbage in, garbage out.  If you disagree, point me
at where the spec allows this.  Even if so, we should either fix (if
allowing other registers is a GNU extension to the base spec) or work
around (if it is a misunderstanding on Sun's part) the problem if
targetting Solaris: there are linkers in the field that behave as
observed, and generating code that causes binaries to crash isn't a good
option.

        Rainer


-- 


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

Reply via email to