zydis: build static lib

* for GCC2 build with a modern GCC as suggested by waddlesplash
* make the headers compatible with GCC2

Change-Id: Ice74eeddbe10bc8f9cf9ae90baa833a46bb3c676
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7848
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Jérôme Duval 2024-07-17 19:30:12 +02:00 committed by waddlesplash
parent cb130a72e8
commit 06b1eff6ec
5 changed files with 72 additions and 2 deletions

View File

@ -61,10 +61,12 @@ ZYAN_INLINE ZyanU64 ZyanAbsI64(ZyanI64 x)
// INT_MIN special case. Can't use the value directly because GCC thinks
// it's too big for an INT64 literal, however is perfectly happy to accept
// this expression. This is also hit INT64_MIN is defined in `stdint.h`.
#if defined(__GNUC__) && (__GNUC__ >= 4)
if (x == (-0x7fffffffffffffff - 1))
{
return 0x8000000000000000u;
}
#endif
return (ZyanU64)(x < 0 ? -x : x);
}

View File

@ -127,7 +127,9 @@ typedef ZyanU8 ZydisTokenType;
/* Token */
/* ---------------------------------------------------------------------------------------------- */
#if !defined(__HAIKU__) || (defined(__GNUC__) && (__GNUC__ >= 4))
#pragma pack(push, 1)
#endif
/**
* Defines the `ZydisFormatterToken` struct.
@ -147,7 +149,9 @@ typedef struct ZydisFormatterToken_
ZyanU8 next;
} ZydisFormatterToken;
#if !defined(__HAIKU__) || (defined(__GNUC__) && (__GNUC__ >= 4))
#pragma pack(pop)
#endif
/**
* Defines the `ZydisFormatterTokenConst` data-type.

View File

@ -44,7 +44,7 @@ extern "C" {
/* Enums and types */
/* ============================================================================================== */
#if !defined(ZYAN_APPLE)
#if !defined(ZYAN_APPLE) && (!defined(__HAIKU__) || (defined(__GNUC__) && (__GNUC__ >= 4)))
# pragma pack(push, 1)
#endif
@ -68,7 +68,7 @@ typedef struct ZydisShortString_
ZyanU8 size;
} ZydisShortString;
#if !defined(ZYAN_APPLE)
#if !defined(ZYAN_APPLE) && (!defined(__HAIKU__) || (defined(__GNUC__) && (__GNUC__ >= 4)))
# pragma pack(pop)
#endif

View File

@ -17,3 +17,4 @@ SubInclude HAIKU_TOP src libs stdc++ ;
SubInclude HAIKU_TOP src libs udis86 ;
SubInclude HAIKU_TOP src libs uuid ;
SubInclude HAIKU_TOP src libs util ;
SubInclude HAIKU_TOP src libs zydis ;

63
src/libs/zydis/Jamfile Normal file
View File

@ -0,0 +1,63 @@
SubDir HAIKU_TOP src libs zydis ;
local zydisSourceDirectory = [ FDirName $(HAIKU_TOP) src libs zydis ] ;
UseHeaders [ LibraryHeaders zydis ] : true ;
UseHeaders [ FDirName $(zydisSourceDirectory) Zydis ] : true ;
SubDirCcFlags -Wno-error=missing-prototypes ;
DEFINES += __posix ;
DEFINES += ZYDIS_DISABLE_ENCODER ;
local zydisSources =
Decoder.c
DecoderData.c
Disassembler.c
Formatter.c
FormatterBuffer.c
FormatterATT.c
FormatterBase.c
FormatterIntel.c
MetaInfo.c
Mnemonic.c
Register.c
SharedData.c
String.c
Utils.c
Zydis.c
;
local zycoreSources =
Zycore.c
Allocator.c
Bitset.c
Format.c
List.c
String.c
Vector.c
;
if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
# GCC 2 can't compile C11, so we use the modern GCC .
original_TARGET_CC_x86_gcc2 = $(TARGET_CC_x86_gcc2) ;
TARGET_CC_x86_gcc2 = $(TARGET_CC_x86) -Wa,-mrelax-relocations=no ;
}
SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) zydis ] ;
MakeLocate [ FGristFiles $(zydisSources:S=$(SUFOBJ)) ]
: [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) zydis ] ;
StaticLibrary libzydis.a : $(zydisSources) ;
LOCATE on [ FGristFiles $(zydisSources) ] = [ FDirName $(zydisSourceDirectory) Zydis ] ;
SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) zycore ] ;
MakeLocate [ FGristFiles $(zycoreSources:S=$(SUFOBJ)) ]
: [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) zycore ] ;
StaticLibrary libzydis.a : $(zycoreSources)
;
LOCATE on [ FGristFiles $(zycoreSources) ] = [ FDirName $(zydisSourceDirectory) Zycore ] ;
if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
TARGET_CC_x86_gcc2 = $(original_TARGET_CC_x86_gcc2) ;
}