I wrote code and compiled it to exe, now the .text section need to be larger , If I have the code and I want to allocate more space in the .text section from code before compiling it , how to do so ? Allocate some buffers ?
I'm trying to alter the code or compiling option to result with a binary file with LARGER .TEXT section
my compiler VisualStudio2010 or cl.exe
Patching the binary file is more complicated
Assuming it's really what you want, you may use inline assembly. E.g. for gcc+gas: void unused_global() { __asm(".space 10000"); }
For Visual Studio's cl.exe, it seems to be more tricky: there is no directives in inline asm, even REPT is unavailable. I would compile a bunch of nops separately with masm; otherwise we have to do something like this:
#define NOP __asm { NOP } ;
#define NOP8 NOP NOP NOP NOP NOP NOP NOP NOP
#define NOP64 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8 NOP8
#define NOP512 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64 NOP64
#define NOP4096 NOP512 NOP512 NOP512 NOP512 NOP512 NOP512 NOP512 NOP512
#define NOP32768 NOP4096 NOP4096 NOP4096 NOP4096 NOP4096 NOP4096 NOP4096 NOP4096
void unused_global() { NOP32768 }