[PATCH] increase stack and malloc alignment to 16 bytes

6 views
Skip to first unread message

J.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com]

unread,
Nov 25, 2021, 10:25:39 AM11/25/21
to dj...@delorie.com, J.W. Jagersma
The section alignment patch I posted here earlier has been accepted in binutils,
so that will be available in the next release.

Now in libc only these two lines need to be adjusted, and then all code, data,
stack and heap will be aligned to 16 byte boundaries.

Should be good for SSE, hopefully it will help resolve the gcc 11 Ada issue too.

---
src/libc/ansi/stdlib/nmalcdef.h | 2 +-
src/libc/crt0/crt0.S | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libc/ansi/stdlib/nmalcdef.h b/src/libc/ansi/stdlib/nmalcdef.h
index cb41f619..495c63a6 100644
--- a/src/libc/ansi/stdlib/nmalcdef.h
+++ b/src/libc/ansi/stdlib/nmalcdef.h
@@ -188,7 +188,7 @@ typedef struct memblock {
/* conversion and access macros */
#define MEMBLKp(p) (memblockp)((byte*)(p) - DATAOFFSET)
#define PTR(m) (void*)((byte*)(m) + DATAOFFSET)
-#define ALIGN 8
+#define ALIGN 16

#define ALIGNMASK (ALIGN-1)

diff --git a/src/libc/crt0/crt0.S b/src/libc/crt0/crt0.S
index 446a989b..226f0cb9 100644
--- a/src/libc/crt0/crt0.S
+++ b/src/libc/crt0/crt0.S
@@ -315,7 +315,7 @@ use_stubinfo_stack_size:
addl __stklen, %eax
movw %ds, %dx /* set stack */
movw %dx, %ss
- andb $0xf8, %al /* align to 8-byte boundary */
+ andb $0xf0, %al /* align to 16-byte boundary */
movl %eax, %esp
movl %eax, ___djgpp_stack_top /* Top of stack */
subl ___djgpp_stack_limit, %eax
--
2.33.0

Reply all
Reply to author
Forward
0 new messages