asamy / ksm

A fast, hackable and simple x64 VT-x hypervisor for Windows and Linux. Builtin userspace sandbox and introspection engine.
https://asamy.github.io/ksm/
GNU General Public License v2.0
837 stars 182 forks source link

Error: Cross Compile on Linux for Windows #18

Closed rohaaan closed 7 years ago

rohaaan commented 7 years ago

Performed from following on Ubuntu 14.04 64bit in Virtual Box Cross under Linux

Install the following packages:
  • Debian/Ubuntu: [sudo] apt-get install gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64
  • ArchLinux: [sudo] pacman -S mingw-w64-gcc
  • Fedora: [sudo] yum install mingw64-gcc
Then `make -f Makefile.windows C=1 all`

Following Output Received:

ksm@ksm:~/ksm$ make -f Makefile.windows C=1 all
x86_64-w64-mingw32-gcc -shared -Wl,--subsystem,native -Wl,--dynamicbase -Wl,--stack=0x6000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--entry,DriverEntry -Wl,--nxcompat -Wl,--exclude-all-symbols -Wl,--enable-stdcall-fixup -nostartfiles -nostdlib -o bin/ksm.sys obj/exit.o obj/htable.o obj/hotplug.o obj/introspect.o obj/ksm.o obj/sandbox.o obj/mm.o obj/main_nt.o obj/epage.o obj/print.o obj/resubv.o obj/vcpu.o obj/vmx.o -L/usr/x86_64-w64-mingw32/lib -lntoskrnl -lhal -lmingwex
obj/exit.o:exit.c:(.text+0x4fc): undefined reference to `__writecr2'
obj/exit.o:exit.c:(.text+0x10c3): undefined reference to `__writecr2'
obj/exit.o:exit.c:(.text+0x1294): undefined reference to `__writecr2'
obj/exit.o:exit.c:(.text+0x28e4): undefined reference to `__writecr2'
obj/exit.o:exit.c:(.text+0x2934): undefined reference to `__writecr2'
obj/exit.o:exit.c:(.text+0x2b07): more undefined references to `__writecr2' follow
/usr/bin/x86_64-w64-mingw32-ld: obj/exit.o: bad reloc address 0x334 in section `.rdata'
collect2: error: ld returned 1 exit status
make: *** [bin/ksm.sys] Error 1

How to fix this issue?

asamy commented 7 years ago

Your version of MinGW doesn't specify __writecr2 as an intrinsic, so My latest commit should fix it, please confirm and if not, re-open.

rohaaan commented 7 years ago

downloaded latest and resolved!! Thank you!