start moving malloc and friends in

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-08-11 00:00:00 +00:00
parent 975b15b814
commit d7a24ea200
25 changed files with 222 additions and 26 deletions

24
userland/glibc/brk.c Normal file
View File

@@ -0,0 +1,24 @@
/* https://cirosantilli.com/linux-kernel-module-cheat#brk */
#define _GNU_SOURCE
#include <assert.h>
#include <unistd.h>
int main(void) {
void *b = sbrk(0);
int *p = (int *)b;
/* Move it 2 ints forward */
brk(p + 2);
/* Use the ints. */
*p = 1;
*(p + 1) = 2;
assert(*p == 1);
assert(*(p + 1) == 2);
/* Deallocate back. */
brk(b);
return 0;
}