Set the heap start address in C program?
问题 Is there a way to set the heap start address in GCC compiled C program in linux? In x86_64 system,my test program sets the heap address to 4 byte referenced address ( less than FFFFFFFF). I want to set this to 8 byte referenced address for some testing ( > FFFFFFFF). Does GCC provide any way to set the heap start address? 回答1: You can do this a bit indirectly using sbrk() : #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { sbrk(0xFFFFFFFF); printf("%p\n", malloc(1));