Hi I try to use pellesC function in FASM using static linking. Every thing work well except when I going to use memory related function like malloc(), my exe created has error.
PellesC can actually compile to object code. The linking between FASM code (main) and PellesC (function) also work. But the resulting code has error. This error only happen when I use this memory related function. Using other function work well.
Please help me to resolve this matter. Thanks.
This is my FASM code (main). Compile MS COFF format
include 'header.asm' ;Compile MS COFF format in this header
extrn '__imp__ExitProcess@0' as ExitProcess:dword
extrn _DebugA@4:DWORD
section '.data' data readable writeable
_a dd 0
section '.code' code readable executable
public start
start:
MOV [_a],6
PUSH DWORD 3
CALL _DebugA@4
invoke ExitProcess, 0
And this is my PellesC code (function). Compile with -Tx86-coff -MT -Ot -W1 -Gz -Ze
#include <windows.h>
#include <math.h>
#include <fenv.h>
#include <stdio.h>
#include <stdlib.h>
int DebugA(int a)
{
void *temp=malloc(10); //without this two function the exe work
free(temp);
MessageBoxA(0,"test","Debug",0);
return 0;
}
I link the above object code using polink /SUBSYSTEM:WINDOWS /ENTRY:start asm.obj PellesC.obj crtmt.lib.....and all other file (no problem on this because its work)
Just when I added the above memory function the exe has error. Look like the memory region corrupted.