diff options
author | Robert Mustacchi <rm@joyent.com> | 2013-07-23 21:24:17 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2013-07-23 23:07:03 +0000 |
commit | b034663e3b02babe0051b61f6782e7bfb5b7b9b4 (patch) | |
tree | 33d57305758bbdc39e19faffe1f7330fe1843f79 | |
parent | e047f3e4740b452ddfb4f5764c60d3893a5caa2d (diff) | |
download | illumos-joyent-b034663e3b02babe0051b61f6782e7bfb5b7b9b4.tar.gz |
OS-2392 i386 ctri.s does not provide proper stack alignment
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Keith M Wesolowski <wesolows@foobazco.org>
-rw-r--r-- | usr/src/lib/common/i386/crti.s | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr/src/lib/common/i386/crti.s b/usr/src/lib/common/i386/crti.s index a79443315c..be73fb986c 100644 --- a/usr/src/lib/common/i386/crti.s +++ b/usr/src/lib/common/i386/crti.s @@ -23,6 +23,9 @@ * Copyright (c) 2001 by Sun Microsystems, Inc. * All rights reserved. */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ /* * These crt*.o modules are provided as the bare minimum required @@ -34,10 +37,19 @@ * For further details - see bug#4433015 */ - .ident "%Z%%M% %I% %E% SMI" .file "crti.s" /* + * Note that when _init and _fini are called we have 16-byte alignment per the + * ABI. We need to make sure that our asm leaves it such that subsequent calls + * will be aligned. Between the two pushls we do ourselves, that leaves us + * having pushed 8 bytes onto the stack. The call that will follow this prologue + * which have us push eip onto the stack. To make sure that when that function + * is called it is 16-byte aligned we must subtract another four bytes from the + * stack. + */ + +/* * _init function prologue */ .section .init,"ax" @@ -51,6 +63,7 @@ _init: call .L1 .L1: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-.L1], %ebx + subl $4, %esp / See above comments on alignment /* * _fini function prologue @@ -66,3 +79,4 @@ _fini: call .L2 .L2: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-.L2], %ebx + subl $4, %esp / See above comments on alignment |