microsoft / llvm-mctoll

llvm-mctoll
Other
818 stars 125 forks source link

Windows binaries support #38

Open Trass3r opened 5 years ago

Trass3r commented 5 years ago

Did some quick-and-dirty tests with Windows x64 executables: https://github.com/Trass3r/llvm-mctoll/commits/coff It does reach the MachineInst level but after that all the assertions kick in. Biggest changes are required in X86MachineInstructionRaiserUtils and the hard-coded calling convention registers in X86RegisterUtils.

Also requires SSE etc support for the startup code, standard C runtime etc. Use cl -nologo -MT -GS- -GR- -EHs-c- test.cpp -link /opt:ref /ENTRY:main /NODEFAULTLIB with some simple code (no runtime) to generate a tiny executable for testing.

__declspec(noinline)
int sum(int *arr, int n)
{
  int sum = 0;
  for (int i = 0; i < n; ++i)
    sum += arr[i];
  return sum;
}

int main()
{
  int arr[] = {0, 1, 2, 3};
  return sum(arr, 4);
}

SSE2 support is also sort of required to use -O1 or -O2 as that's used by msvc even for trivial memcpy or init code.

mitp0sh commented 4 years ago

Are there any updates? Any info's on the roadmap? Estimated time?

bharadwajy commented 4 years ago

I started adding support to abstract SSE2 registers (7487a7a88dfb074543a10e8147c210ad3dfb7eeb). It is one of the higher priority tasks. Unfortunately, it is difficult to provide a roadmap or timeline.

As always, any/all help, if it can be offered, is highly appreciated.