bare_libc.c (427B)
1 #ifdef HAVE_LIBC 2 #include <string.h> 3 #include <stdlib.h> 4 #endif 5 6 extern unsigned char __heap_base; 7 extern void call_me_sometime(unsigned char *b); 8 9 void foo() { 10 11 #ifdef HAVE_LIBC 12 unsigned char *buf; 13 buf = malloc(9); 14 memcpy(buf+3, "bazbar", 6); 15 #else 16 unsigned char *buf = (unsigned char*)&__heap_base; 17 *(buf+3) = 'b'; 18 *(buf+4) = 'a'; 19 *(buf+5) = 'r'; 20 #endif 21 call_me_sometime(buf); 22 23 #ifdef HAVE_LIBC 24 free(buf); 25 #endif 26 27 }