[llvm-bugs] [Bug 37807] New: -fsplit-stack problems with split -> nosplit call
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 14 11:25:53 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37807
Bug ID: 37807
Summary: -fsplit-stack problems with split -> nosplit call
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: thanm at google.com
CC: llvm-bugs at lists.llvm.org
Created attachment 20429
--> https://bugs.llvm.org/attachment.cgi?id=20429&action=edit
tar file containing files to reproduce
Filing this bug on behalf of Cherry Zhang, who gets credit for discovering it.
This is a problem with -fsplit-stack support in LLVM, specifically in how calls
from split-stack code to non-split-stack code are handled. Let's say you have
sources a.c (containing function foo) and b.c (containing function bar), where
- a.c is compiled with -fsplit-stack, and
- b.c is compiled without -fsplit-stack, and
- foo calls bar
- a.o and b.o and linked together into the same load module
What is supposed to happen in this instance (as described in
https://gcc.gnu.org/wiki/SplitStacks) is that the linker picks up on the fact
that there is a "split to nonsplit" call from foo to bar, and during linking,
it fixes up the "check for more stack" sequence in foo to bump up the amount of
space (since 'bar' may use a lot of space).
What we're seeing with LLVM is that if "foo" has no stack frame at all, the
morestack check is omitted from the routine. This results in a linker assert
when linking a.o and b.o together.
I'm attaching a reproducer; unpack the tar file and do "make run" (uses clang
from $PATH):
$ make clean ; make run
rm -f *.o *.so main asm.txt
clang -c -O -fPIC -o main.o main.c
clang -c -fsplit-stack -O -fPIC -o m1.o m1.c
clang -c -O -fPIC -o m2.o m2.c
clang -O -fuse-ld=gold -fPIC -shared m1.o m2.o -o m1.so
/usr/bin/ld.gold: error: m1.o: failed to match split-stack sequence at section
2 offset 0
clang-7: error: linker command failed with exit code 1 (use -v to see
invocation)
makefile:19: recipe for target 'm1.so' failed
make: *** [m1.so] Error 1
Note that the linker error will not be triggered for older versions of clang
(prior to fix for https://bugs.llvm.org/show_bug.cgi?id=34670).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180614/6939ba77/attachment-0001.html>
More information about the llvm-bugs
mailing list