[LLVMbugs] [Bug 11089] New: sspreq broken with JIT

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Oct 8 05:13:18 PDT 2011


           Summary: sspreq broken with JIT
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=7421)
 --> (http://llvm.org/bugs/attachment.cgi?id=7421)

With ToT the stackprotect attribute is still broken when using the JIT.
(it works when using static compilation).

It was broken in 2.9 too, last time it worked was in 2.8.

When adding the sspreq required attribute to a function and running it with the
JIT it generates code like this:
   0x00007ffff7f41010 <+0>:     sub    $0x18,%rsp
=> 0x00007ffff7f41014 <+4>:     mov    0x28,%rax
   0x00007ffff7f4101c <+12>:    mov    %rax,0x10(%rsp)
   0x00007ffff7f41021 <+17>:    movl   $0x0,0xc(%rsp)

Obviously that mov crashes because it tries to read from address 0x28.

When compiling to a static .s file everything seems fine though, but the code
in question looks like this:
    movq    %fs:40, %rax
    movq    %rax, 16(%rsp)

So it looks like the %fs: segment register is lost when JITing.

To reproduce:
$ lli --debug-only=jit x.bc
JIT: Binary code:
JIT: 0: 2423613172 37413972 00040 366813772 
JIT: 16: 366819916 00012 4139720 004037 
JIT: 32: 6859720 133151636 00010 004184 
JIT: 48: 196131720 1847219524 13346154144 00053 
JIT: 64: 208255
0  lli             0x0000000000c7b03f
1  lli             0x0000000000c7b529
2  libpthread.so.0 0x0000003585e0f020
3  libpthread.so.0 0x00007f52cac86014
Stack dump:
0.    Program arguments:
/home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/lli --debug-only=jit
Segmentation fault (core dumped)

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list