Commit Graph

5 Commits

Author SHA1 Message Date
bacc40d844 GenASM: Make sure the stack is 16 byte aligned before calling malloc or free.
The GenASM visitor only uses quad mnemonics so each manipulation to the stack is done in 8 byte chunks. This means our stack is always 8 byte aligned which is fine when only calling KLang code. libc functions like 'malloc' or 'free' require the stack to be 16 byte aligned which isn't automatically guaranteed when being 8 byte aligned. This is why we need to be careful when manipulating the stack (e.g. pushq, popq, subq x, %rsp). By assuming that we are stack aligned at the beginning of execution and by tracking the number of pushq operations we can deduce whether we misaligned the stack and align it again by adding another 8 byte to the stack.

This re-alignment of the stack is done directly before entering a function body or calling malloc. Since there are no stack manipulations involved when generating the code to calling 'free' there is reason to check for alignment there.
2023-03-21 22:21:14 +01:00
14f80b46cc remove whitespace 2020-03-09 14:12:19 +01:00
4a9e5c30e1 implement test_expected functions for all types in use 2020-03-09 14:10:35 +01:00
1f8de66751 update the struct test so that field c of the test struct is of type double 2020-03-09 13:49:09 +01:00
9adc48da82 implement struct tests 2020-03-09 12:48:31 +01:00