capstone: bump version to 4.0.1 and add tests (#3560)

This commit is contained in:
Schrijvers Luc
2020-03-05 14:32:30 +01:00
committed by GitHub
parent 1b7a1f268d
commit 1d3d5114a9
3 changed files with 75 additions and 42 deletions

View File

@@ -14,11 +14,15 @@ Solaris confirmed).
* High performance & suitable for malware analysis (capable of handling \
various X86 malware tricks)."
HOMEPAGE="http://www.capstone-engine.org"
COPYRIGHT="2013-2015, COSEINC"
COPYRIGHT="2013-2019, COSEINC"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="https://github.com/aquynh/capstone/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="913dd695e7c5a2b972a6f427cb31f2e93677ec1c38f39dda37d18a91c70b6df1"
CHECKSUM_SHA256="79bbea8dbe466bd7d051e037db5961fdb34f67c9fac5c3471dd105cfb1e05dc7"
srcGitRev="b01a30bf595c23081d0acfbcbe36fc8c6d829a71"
SOURCE_URI_2="https://github.com/groundx/capstonefuzz/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256_2="837be0138cb44384bf1266e76d67947a5be30a1dbd8d8ea532491677c1609b78"
SOURCE_FILENAME="capstone-$portVersion.tar.gz"
PATCHES="capstone-$portVersion.patchset"
ARCHITECTURES="!x86_gcc2 ?x86 x86_64"
@@ -26,7 +30,8 @@ SECONDARY_ARCHITECTURES="x86"
PROVIDES="
capstone$secondaryArchSuffix = $portVersion
lib:libcapstone$secondaryArchSuffix = 3
cmd:cstool$secondaryArchSuffix = $portVersion
lib:libcapstone$secondaryArchSuffix = 4
"
REQUIRES="
haiku$secondaryArchSuffix
@@ -34,7 +39,7 @@ REQUIRES="
PROVIDES_devel="
capstone${secondaryArchSuffix}_devel = $portVersion
devel:libcapstone$secondaryArchSuffix = 3
devel:libcapstone$secondaryArchSuffix = 4
"
REQUIRES_devel="
capstone$secondaryArchSuffix == $portVersion base
@@ -45,12 +50,18 @@ BUILD_REQUIRES="
"
BUILD_PREREQUIRES="
cmd:awk
cmd:find
cmd:gcc$secondaryArchSuffix
cmd:make
"
TEST_REQUIRES="
cmd:unzip
"
BUILD()
{
export INCDIR=$includeDir
export LIBDIRARCH=$relativeLibDir
export MAKE_JOBS=$jobArgs
./make.sh default
@@ -58,6 +69,7 @@ BUILD()
INSTALL()
{
export INCDIR=$includeDir
export PREFIX=$prefix
export LIBDIRARCH=$relativeLibDir
./make.sh install
@@ -65,3 +77,15 @@ INSTALL()
fixPkgconfig
packageEntries devel $developDir
}
TEST()
{
export filename="corpus-libFuzzer-capstone_fuzz_disasmnext-latest"
if [ -d "./suite/fuzz/$filename" ]; then
true
else
unzip -o -q $sourceDir2/capstonefuzz-$srcGitRev/corpus/$filename.zip -d suite/fuzz
fi
make check
}

View File

@@ -1,38 +0,0 @@
From c5005870684d589868ab5e5710320e1286bb5572 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Sun, 9 Aug 2015 22:31:25 +0200
Subject: Hack in Haiku support.
* Could not get LIBDIRARCH to work, so override it
* Add a prefix variable to the pkg-config file so it can be fixed by
* haikuporter
diff --git a/Makefile b/Makefile
index 52ae2a9..c787759 100644
--- a/Makefile
+++ b/Makefile
@@ -59,11 +59,11 @@ else
BLDIR = $(abspath $(BUILDDIR))
OBJDIR = $(BLDIR)/obj
endif
-INCDIR = $(DESTDIR)$(PREFIX)/include
+INCDIR = $(DESTDIR)$(PREFIX)/develop/headers
UNAME_S := $(shell uname -s)
-LIBDIRARCH ?= lib
+LIBDIRARCH ?= lib/x86
# Uncomment the below line to installs x86_64 libs to lib64/ directory.
# Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'.
#LIBDIRARCH ?= lib64
@@ -457,6 +457,7 @@ define generate-pkgcfg
echo 'Name: capstone' > $(PKGCFGF)
echo 'Description: Capstone disassembly engine' >> $(PKGCFGF)
echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF)
+ echo 'prefix=$(PREFIX)' >> $(PKGCFGF)
echo 'libdir=$(LIBDIR)' >> $(PKGCFGF)
echo 'includedir=$(INCDIR)/capstone' >> $(PKGCFGF)
echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF)
--
2.2.2

View File

@@ -0,0 +1,47 @@
From 12215d491664fab5e11d359edc70dcda513cc1f2 Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Sun, 13 Jan 2019 00:39:39 +0000
Subject: Fix build of fuzztests.
diff --git a/suite/fuzz/driverbin.c b/suite/fuzz/driverbin.c
index 57eea2c..280a7a0 100644
--- a/suite/fuzz/driverbin.c
+++ b/suite/fuzz/driverbin.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
+#include <sys/stat.h>
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
@@ -13,6 +14,8 @@ int main(int argc, char** argv)
size_t Size;
DIR *d;
struct dirent *dir;
+ struct stat s;
+
int r = 0;
if (argc != 2) {
@@ -32,9 +35,16 @@ int main(int argc, char** argv)
while((dir = readdir(d)) != NULL) {
//opens the file, get its size, and reads it into a buffer
+ #ifndef __HAIKU__
if (dir->d_type != DT_REG) {
continue;
}
+ else
+ stat(dir->d_name, &s);
+ if(!S_ISREG(s.st_mode)){
+ continue;
+ }
+ #endif
//printf("Running %s\n", dir->d_name);
fp = fopen(dir->d_name, "rb");
if (fp == NULL) {
--
2.19.1