Last active
August 29, 2015 14:02
-
-
Save 7shi/9a58e3796db8a7202ff6 to your computer and use it in GitHub Desktop.
[NetBSD]sbrk(0)
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
$ cat sbrk.c | |
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
printf("%p\n", sbrk(0)); | |
printf("%p\n", sbrk(0)); | |
return 0; | |
} | |
---- | |
$ uname -a | |
NetBSD 6.1 NetBSD 6.1 (GENERIC) amd64 | |
$ gcc -m64 sbrk.c | |
$ ./a.out | |
0x600dc8 | |
0x600dc8 | |
$ gcc -m32 sbrk.c | |
$ ./a.out | |
0x80499a4 | |
0x8100000 | |
---- | |
% uname -srm | |
FreeBSD 9.1-RELEASE i386 | |
% gcc sbrk.c | |
% ./a.out | |
0x8049674 | |
0x8400000 | |
---- | |
$ uname -srm | |
OpenBSD 5.3 i386 | |
$ gcc sbrk.c | |
$ ./a.out | |
0x3c003260 | |
0x3c003260 |
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
$ cat sbrk2.c | |
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
void *a, *b; | |
a = sbrk(0); | |
b = sbrk(0); | |
printf("%p\n", a); | |
printf("%p\n", b); | |
return 0; | |
} | |
---- | |
$ uname -a | |
NetBSD 6.1 NetBSD 6.1 (GENERIC) amd64 | |
$ gcc -m32 sbrk2.c | |
$ ./a.out | |
0x80499a4 | |
0x80499a4 | |
---- | |
% uname -srm | |
FreeBSD 9.1-RELEASE i386 | |
% gcc sbrk2.c | |
% ./a.out | |
0x8049678 | |
0x8049678 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment