Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.