The key to omit this stupid linking is simpy - just recode these several functions:
function __malloc(Size: Integer): Pointer; cdecl;
begin Result := GetMem(size);end;
procedure __free(P: Pointer); cdecl;
begin Free(P); end;
function __realloc(P: Pointer; Size: Integer): Pointer; cdecl;
begin Result := Realloc(P, size); end;
........
only the keyword: cdecl, must be preserved, because 'c' functions work in different way than in pas.
And even a compiler don't have the 'cdecl' directive, then you still can redefine this - using asm.
function __realloc(P: Pointer; Size: Integer): Pointer; assembler;
asm
... the c-calls leave parameters on the stack, then you must leave its - for the c-code callers.
end;
the double underlines: __ is also compiler dependent, because the c functions have only one underline _,
but some very programmers try to complicate even more this stuff, so, they all are masters, hence they add additional: _.