<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - interrupt handler calls functions with misaligned stack"
href="https://llvm.org/bugs/show_bug.cgi?id=26477">26477</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>interrupt handler calls functions with misaligned stack
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hjl.tools@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>amjad.aboud@intel.com, david.l.kreitzer@intel.com, kevin.b.smith@intel.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Incoming stack of x86 interrupt handler is aligned at 4 bytes (8 bytes for
64-bit). When it calls extern functions, it needs to realign the stack
to 16-byte aligned if it is required:
[hjl@gnu-6 interrupt-1]$ cat xx.i
extern void bar (void);
extern int i;
void
__attribute__ ((interrupt))
foo (void *frame)
{
bar ();
i = 0;
}
[hjl@gnu-6 interrupt-1]$ /export/build/gnu/gcc-5/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-5/build-x86_64-linux/gcc/ -O2 xx.i -m32 -mno-sse -S
[hjl@gnu-6 interrupt-1]$ cat xx.s
.file "xx.i"
.section .text.unlikely,"ax",@progbits
.LCOLDB0:
.text
.LHOTB0:
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
pushl %ecx
pushl %edx
pushl %eax
andl $-16, %esp <<<<<<<<<<<< Align stack
cld
.cfi_offset 1, -12
.cfi_offset 2, -16
.cfi_offset 0, -20
call bar
movl $0, i
leal -12(%ebp), %esp
popl %eax
.cfi_restore 0
popl %edx
.cfi_restore 2
popl %ecx
.cfi_restore 1
popl %ebp
.cfi_restore 5
.cfi_def_cfa 4, 4
iret
.cfi_endproc
.LFE0:
.size foo, .-foo
.section .text.unlikely
.LCOLDE0:
.text
.LHOTE0:
.ident "GCC: (GNU) 5.3.1 20160201"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-6 interrupt-1]$
But clang doesn't align stack:
[hjl@gnu-6 interrupt-1]$
/net/gnu-mic-2//export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang -O2
xx.i -m32 -mno-sse -S
[hjl@gnu-6 interrupt-1]$ cat xx.s
.text
.file "xx.i"
.globl foo
.p2align 4, 0x90
.type foo,@function
foo: # @foo
# BB#0:
pushl %esp
pushl %edx
pushl %ecx
pushl %eax
subl $12, %esp
calll bar
movl $0, i
addl $12, %esp
popl %eax
popl %ecx
popl %edx
popl %esp
iretl
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.ident "clang version 3.9.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
bf1d31e84aa2722174da56b8aff311ae04f4d9e1) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
6cced9c3cd18f529420a03b100970d97512bb9a4)"
.section ".note.GNU-stack","",@progbits
[hjl@gnu-6 interrupt-1]$</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>