lkml.org 
[lkml]   [2003]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[x86] Access off the bottom of stack causes a segfault?

My compiler is generating accesses off the bottom of the stack (address
below %esp). Is there some funny kernel interaction that I should be
aware of with this? I'm periodically getting segfaults.

Example:

int main() {
int test[4000];
...
return 0;
}

Generated code:
.intel_syntax
...
main:
mov DWORD PTR [%ESP - 16004], %EBP # Save EBP to stack
mov %EBP, %ESP # Set up EBP
sub %ESP, 16004 # Finally adjust ESP
lea %EAX, DWORD PTR [%EBP - 16000] # Get the address of the array
...
mov %EAX, 0 # Setup return value
mov %ESP, %EBP # restore ESP
mov %EBP, DWORD PTR [%ESP - 16004] # Restore EBP from stack
ret

This seems like perfectly valid X86 code (though unconventional), but it
is causing segfaults pretty consistently (on the first instruction).
Does the linux kernel assume that page faults will be above the stack
pointer if the stack needs to be expanded?

Thanks,

-Chris

--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:1.801 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site