Closed m4b closed 6 years ago
Yeah; Cretonne isn't yet emitting the code to adjust the stack pointer. I've now filed https://github.com/stoklund/cretonne/issues/187 to track this issue.
This should be fixed now. 👍
Specifically, stoklund/cretonne#201 is now merged, and basic function prologues and epilogues work.
One caveat is that the original testcase probably doesn't work yet, because it calls printf
, which needs varargs ABI support, which Cretonne doesn't have yet (I've now filed https://github.com/stoklund/cretonne/issues/212 to track this).
Consider the following bitcode,
deadbeef.ll
:and (optionally) the following C to call it:
If I compile
deadbeef.ll
using llvm2cretonne ->deadbeef.txt
, and llc -> gcc ->lldeadbeef.txt
, we can see the following difference:You'll notice that
foo
does not have a function prelude, and if the function is large enough, it will spill onto the stack like0x4(rsp)
even though no stack local space has been allocated/adjusted.Even still, if you compile the above, via something like
gcc main.c deadbeef.o -o main
, the resulting binary will segfault inside of the functiondeadbeef
; I don't really know why, it doesn't deref any pointers, but my best guess is the stack isn't aligned somehow, or the rex instruction(s) are doing something funky?