Tweak to fit into the GumJS build system

This commit is contained in:
Ole André Vadla Ravnås 2019-09-07 02:24:30 +02:00
parent 7d4a71fc8b
commit 2f2aea459c
12 changed files with 423 additions and 4 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@
*.log
*.bz2
*.zip
*.user
.gdb_history
a.out
tcc_g

View File

@ -1 +0,0 @@
0.9.27

View File

@ -115,7 +115,7 @@ static void tcc_set_lib_path_w32(TCCState *s)
static void tcc_add_systemdir(TCCState *s)
{
char buf[1000];
GetSystemDirectory(buf, sizeof buf);
GetSystemDirectoryA(buf, sizeof buf);
tcc_add_library_path(s, normalize_slashes(buf));
}
#endif

86
meson.build Normal file
View File

@ -0,0 +1,86 @@
tcc_c_args = [
'-DONE_SOURCE=0',
]
tcc_c_args += cc.get_supported_arguments([
'-Wno-pointer-sign',
'-Wno-string-plus-int',
])
tcc_sources = [
'libtcc.c',
'tccpp.c',
'tccgen.c',
'tccelf.c',
'tccasm.c',
'tccrun.c',
]
if host_os_family == 'windows'
tcc_c_args += [
'-DTCC_TARGET_PE',
]
tcc_sources += [
'tccpe.c',
]
endif
if host_arch == 'x86'
tcc_c_args += [
'-DTCC_TARGET_I386',
]
tcc_sources += [
'i386-gen.c',
'i386-link.c',
'i386-asm.c',
]
endif
if host_arch == 'x86_64'
tcc_c_args += [
'-DTCC_TARGET_X86_64',
]
tcc_sources += [
'x86_64-gen.c',
'x86_64-link.c',
'i386-asm.c',
]
if host_os_family != 'windows'
tcc_sources += [
'lib/va_list.c',
]
endif
endif
if host_arch == 'arm'
tcc_c_args += [
'-DTCC_TARGET_ARM',
'-DTCC_ARM_EABI',
'-DTCC_ARM_HARDFLOAT',
'-DTCC_ARM_VFP',
]
tcc_sources += [
'arm-gen.c',
'arm-link.c',
'arm-asm.c',
]
endif
if host_arch == 'arm64'
tcc_c_args += [
'-DTCC_TARGET_ARM64',
]
tcc_sources += [
'arm64-gen.c',
'arm64-link.c',
]
endif
tinycc = library('tinycc', tcc_sources,
c_args: frida_component_cflags + tcc_c_args,
include_directories: include_directories('./pregenerated'),
)
tinycc_dep = declare_dependency(
include_directories: include_directories('.'),
)

5
pregenerated/config.h Normal file
View File

@ -0,0 +1,5 @@
/* Automatically generated by configure - do not modify */
#ifndef CONFIG_TCCDIR
# define CONFIG_TCCDIR "/usr/local/lib/tcc"
#endif
#define TCC_VERSION "0.9.27"

4
tcc.h
View File

@ -21,7 +21,9 @@
#ifndef _TCC_H
#define _TCC_H
#define _GNU_SOURCE
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include "config.h"
#include <stdlib.h>

View File

@ -844,7 +844,7 @@ static void pe_build_imports(struct pe_info *pe)
if (pe->type == PE_RUN) {
if (dllref) {
if ( !dllref->handle )
dllref->handle = LoadLibrary(dllref->name);
dllref->handle = LoadLibraryA(dllref->name);
v = (ADDR3264)GetProcAddress(dllref->handle, ordinal?(char*)0+ordinal:name);
}
if (!v)

86
tinycc-32.vcxproj Normal file
View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="i386-asm.c" />
<ClCompile Include="i386-gen.c" />
<ClCompile Include="i386-link.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="i386-asm.h" />
<ClInclude Include="i386-tok.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\releng\frida-builddeps.vcxproj">
<Project>{4afce7c4-6d9a-4663-b43c-d2e518486910}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E1212DF2-FBA5-4E95-821F-A6C89446767A}</ProjectGuid>
<RootNamespace>tinycc</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>tinycc-32</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)releng\frida-$(Configuration).props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)releng\frida-$(Configuration).props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)build\tmp-windows\$(Platform)-$(Configuration)\$(ProjectName)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)build\tmp-windows\$(Platform)-$(Configuration)\$(ProjectName)\</OutDir>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>TCC_TARGET_I386;$(FridaComponentDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>TCC_TARGET_I386;$(FridaComponentDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="tinycc-common.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

63
tinycc-32.vcxproj.filters Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="libtcc.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccpp.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccgen.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccelf.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccpe.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccasm.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccrun.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="i386-asm.c">
<Filter>arch</Filter>
</ClCompile>
<ClCompile Include="i386-gen.c">
<Filter>arch</Filter>
</ClCompile>
<ClCompile Include="i386-link.c">
<Filter>arch</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="tcc.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="libtcc.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="tcctok.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="pregenerated\config.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="i386-asm.h">
<Filter>arch</Filter>
</ClInclude>
<ClInclude Include="i386-tok.h">
<Filter>arch</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="common">
<UniqueIdentifier>{819747e8-2681-463d-930b-a080323ead71}</UniqueIdentifier>
</Filter>
<Filter Include="arch">
<UniqueIdentifier>{38bc7499-5546-4a77-a2a5-b0c5236b15bd}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

86
tinycc-64.vcxproj Normal file
View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="i386-asm.h" />
<ClInclude Include="x86_64-asm.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="i386-asm.c" />
<ClCompile Include="x86_64-gen.c" />
<ClCompile Include="x86_64-link.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\releng\frida-builddeps.vcxproj">
<Project>{4afce7c4-6d9a-4663-b43c-d2e518486910}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9CDF2D78-15B7-4BAE-B533-5F830FBD73E7}</ProjectGuid>
<RootNamespace>tinycc</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>tinycc-64</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)releng\frida-$(Configuration).props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)releng\frida-$(Configuration).props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)build\tmp-windows\$(Platform)-$(Configuration)\$(ProjectName)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)build\tmp-windows\$(Platform)-$(Configuration)\$(ProjectName)\</OutDir>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>TCC_TARGET_X86_64;$(FridaComponentDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>TCC_TARGET_X86_64;$(FridaComponentDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="tinycc-common.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

63
tinycc-64.vcxproj.filters Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="libtcc.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccpp.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccgen.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccelf.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccpe.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccasm.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="tccrun.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="x86_64-gen.c">
<Filter>arch</Filter>
</ClCompile>
<ClCompile Include="x86_64-link.c">
<Filter>arch</Filter>
</ClCompile>
<ClCompile Include="i386-asm.c">
<Filter>arch</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="tcc.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="libtcc.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="tcctok.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="pregenerated\config.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="x86_64-asm.h">
<Filter>arch</Filter>
</ClInclude>
<ClInclude Include="i386-asm.h">
<Filter>arch</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="common">
<UniqueIdentifier>{af9a3b4b-eea1-4eb0-9ec7-f290af91c0e8}</UniqueIdentifier>
</Filter>
<Filter Include="arch">
<UniqueIdentifier>{b337daa9-a177-46df-9a46-a2925a64a3e1}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

28
tinycc-common.props Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>ONE_SOURCE=0;TCC_TARGET_PE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)pregenerated;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4057;4152;4201;4214;4245;4324;4389;4456;4457;4459;4701;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="tcc.h" />
<ClInclude Include="libtcc.h" />
<ClInclude Include="tcctok.h" />
<ClInclude Include="pregenerated\config.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="libtcc.c" />
<ClCompile Include="tccpp.c" />
<ClCompile Include="tccgen.c" />
<ClCompile Include="tccelf.c" />
<ClCompile Include="tccpe.c" />
<ClCompile Include="tccasm.c" />
<ClCompile Include="tccrun.c" />
</ItemGroup>
</Project>