mirror of
https://github.com/lifting-bits/remill
synced 2026-06-21 13:56:07 +00:00
3a16ad4a82
* Append project name to the check_git target to fix compound builds (#446) * Change the way we get registers for __remill_basic_block so that it's the Arch class of the target that actually populates the function, and isn't based on reverse-engineering what's visible in the function as compiled by llvm * Renamed a cmake var to reduce likelihood of conflicts, and tries to make sure remill only links against static llvm libraries * Fix instruction dominance issues * Minor fix on the type of PC on x86 * Added new implementation (in Arch.cpp) of the AArch64 __remill_basic_block function Co-authored-by: Artem Dinaburg <artem@trailofbits.com> Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
286 lines
5.4 KiB
Batchfile
Executable File
286 lines
5.4 KiB
Batchfile
Executable File
@echo off
|
|
|
|
call :main
|
|
exit /B %ERRORLEVEL%
|
|
|
|
:main
|
|
setlocal
|
|
|
|
call :installCMake
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :installLLVM
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :installLLVMIntegration
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :installPython
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :installCxxcommon
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :initializeVisualStudioEnvironment
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to find a suitable Visual Studio installation when initializing
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :configureProject
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to find a suitable Visual Studio installation when configuring
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
call :buildProject
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Build has failed
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:configureProject
|
|
setlocal
|
|
|
|
mkdir build
|
|
cd build
|
|
|
|
pushd ..\tob_libraries
|
|
set tob_libraries=%CD%
|
|
popd
|
|
|
|
cmake -G "Visual Studio 16 2019" -T llvm -A x64 -DCMAKE_BUILD_TYPE=Release -DCXX_COMMON_REPOSITORY_ROOT=%tob_libraries% -DCMAKE_INSTALL_PREFIX=C:\ ..
|
|
if %ERRORLEVEL% equ 0 (
|
|
endlocal
|
|
exit /B 0
|
|
)
|
|
|
|
endlocal
|
|
exit /B 1
|
|
|
|
:buildProject
|
|
setlocal
|
|
|
|
cd build
|
|
|
|
echo Building
|
|
cmake --build . --config Release -- /maxcpucount:%NUMBER_OF_PROCESSORS%
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:installCMake
|
|
setlocal
|
|
|
|
where cmake > NUL 2>&1
|
|
if %ERRORLEVEL% equ 0 (
|
|
echo Found existing CMake installation
|
|
|
|
endlocal
|
|
exit /B 0
|
|
)
|
|
|
|
echo Attempting to install CMake with choco
|
|
choco install cmake
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to install CMake with choco
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
where cmake > NUL 2>&1
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to call CMake with choco
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:initializeVisualStudioEnvironment
|
|
echo Using Visual Studio 2019
|
|
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
|
)
|
|
if %ERRORLEVEL% equ 0 (
|
|
echo Initialized
|
|
exit /B 0
|
|
)
|
|
exit /B 1
|
|
|
|
:installLLVM
|
|
setlocal
|
|
|
|
if exist "%ProgramFiles%\LLVM\bin\clang.exe" (
|
|
echo Found existing LLVM installation
|
|
|
|
endlocal
|
|
exit /B 0
|
|
)
|
|
|
|
echo Downloading the LLVM installer
|
|
call :downloadFile http://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe, llvm-installer.exe
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
echo Installing LLVM
|
|
llvm-installer.exe /S /D
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:installLLVMIntegration
|
|
setlocal
|
|
|
|
for %%v in (2019 2017) do (
|
|
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\%%v\BuildTools\MSBuild\Microsoft\VC\v160\LLVM.Cpp.Common.targets" (
|
|
echo LLVM has already been integrated in Visual Studio %%v
|
|
exit /B 0
|
|
)
|
|
)
|
|
|
|
echo Downloading the Visual Studio LLVM integration
|
|
call :downloadFile https://llvmextensions.gallerycdn.vsassets.io/extensions/llvmextensions/llvm-toolchain/1.0.363769/1560930595399/llvm.vsix, llvm_vsix.zip
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
echo Installing the Visual Studio LLVM integration
|
|
call :extractArchive llvm_vsix.zip, llvm_integration
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
for %%v in (2019 2017) do (
|
|
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\%%v\BuildTools\MSBuild\Microsoft\VC\v160" (
|
|
echo Integrating LLVM with Visual Studio %%v
|
|
|
|
xcopy llvm_integration\$VCTargets\* "%ProgramFiles(x86)%\Microsoft Visual Studio\%%v\BuildTools\MSBuild\Microsoft\VC\v160" /e /y /h /r > NUL
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
)
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:extractArchive
|
|
setlocal
|
|
|
|
powershell -Command "Expand-Archive %~1 -DestinationPath %~2 -Force"
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to download the file
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
|
|
:installPython
|
|
setlocal
|
|
|
|
if exist "%SystemDrive%\Python27\python.exe" (
|
|
echo Found existing Python installation
|
|
|
|
endlocal
|
|
exit /B 0
|
|
)
|
|
|
|
echo Downloading the Python installer
|
|
call :downloadFile https://www.python.org/ftp/python/2.7.17/python-2.7.17.amd64.msi, python-installer.msi
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
echo Installing Python
|
|
msiexec /i python-installer.msi /quiet /qn /norestart
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:installCxxcommon
|
|
setlocal
|
|
|
|
if not exist cxxcommon.7z (
|
|
echo Downloading the cxxcommon archive
|
|
call :downloadFile https://s3.amazonaws.com/cxx-common/libraries-llvm50-windows10-amd64.7z, cxxcommon.7z
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
)
|
|
|
|
if not exist tob_libraries (
|
|
echo Extracting the cxxcommon archive
|
|
7z.exe x cxxcommon.7z
|
|
if %ERRORLEVEL% neq 0 (
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|
|
|
|
:downloadFile
|
|
setlocal
|
|
|
|
powershell -Command "Invoke-WebRequest %~1 -OutFile %~2"
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to download the file
|
|
|
|
endlocal
|
|
exit /B 1
|
|
)
|
|
|
|
endlocal
|
|
exit /B 0
|