Created
May 31, 2018 07:14
-
-
Save KunYi/eb81a88da6039625df9dc597c805339a to your computer and use it in GitHub Desktop.
test stack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------- | |
; getSP functions | |
.text | |
.globl getSP | |
.type getSP, @function | |
getSP: | |
MOVQ %rsp, %rax | |
RET | |
------------------------------------------ | |
// test.c | |
#include <sys/time.h> | |
#include <sys/resource.h> | |
#include <stdio.h> | |
#include <alloca.h> | |
extern unsigned long long getSP(void); | |
long long i; | |
int main(int argc, char** argv) { | |
char t; | |
char a; | |
struct rlimit rlim; | |
for (;;) { | |
getrlimit(RLIMIT_STACK, &rlim); | |
printf("soft=%dK, hard=%dK\n", | |
(int)rlim.rlim_cur/1024, | |
(int)rlim.rlim_max/1024); | |
printf("t address: 0x%08llx\n", &t); | |
printf("pid = %d", getpid()); | |
a = getchar(); | |
if (a == 'e') break; | |
for (i=0; i< 8192*1024 ; i ++ ) { | |
alloca(1024); | |
printf("%8lld kb, sp: 0x%08llx\n",i, getSP()); | |
} | |
printf("sucess, i = %lld\n", i); | |
} | |
} | |
---------------------- | |
result | |
--------------------- | |
soft=8192K, hard=0K | |
t address: 0x7ffe30c6308e | |
pid = 12689 | |
0 kb, sp: 0x7ffe30c62c58 | |
1 kb, sp: 0x7ffe30c62848 | |
2 kb, sp: 0x7ffe30c62438 | |
3 kb, sp: 0x7ffe30c62028 | |
4 kb, sp: 0x7ffe30c61c18 | |
5 kb, sp: 0x7ffe30c61808 | |
6 kb, sp: 0x7ffe30c613f8 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment