Skip to content

Instantly share code, notes, and snippets.

@7shi
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/9a58e3796db8a7202ff6 to your computer and use it in GitHub Desktop.
Save 7shi/9a58e3796db8a7202ff6 to your computer and use it in GitHub Desktop.
[NetBSD]sbrk(0)
$ 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
$ 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