Compare commits

..
Author SHA1 Message Date
Romain Thomas 1623cdd47e WIP 2021-05-22 09:38:39 +02:00
1077 changed files with 35383 additions and 47122 deletions
+139
View File
@@ -0,0 +1,139 @@
version: 0.7.{build}
image: Visual Studio 2019
clone_folder: c:\projects\lief
configuration: Release
services:
- docker
platform:
- x86
- x64
environment:
LIEF_AUTOMATIC_BUILDS_KEY:
secure: TT7SXISIifq2/tf02n2ATgPj+Ky4Cjl3Fg44BAfyI4yRa4i87UAQIx5EFeV63+Xv2rhcU7JcMgl+An7QBrV6ofuQ9jxbuw+Gd1GqcCrAIyY=
LIEF_AUTOMATIC_BUILDS_IV:
secure: /S6Vbt3vEisoC81siFbkqOXQeVnwxLZZPMYp1r79G7h+HFjLlWUZSidxxpsAgHNE
SCCACHE_CACHE_SIZE: "750M"
SCCACHE_DIR: C:\Users\appveyor\AppData\Local\Mozilla\sccache
SCCACHE_ERROR_LOG: C:\projects\sccache.log
matrix:
# Python 3.6
- PYTHON_VERSION: "3.6"
PYTHON32_PATH: "C:\\Python36"
PYTHON32_INCLUDE: "C:\\Python36\\include"
PYTHON32_BINARY: "C:\\Python36\\python.exe"
PYTHON32_LIBRARY: "C:\\Python36\\libs\\python36.lib"
PYTHON64_PATH: "C:\\Python36-x64"
PYTHON64_INCLUDE: "C:\\Python36-x64\\include"
PYTHON64_BINARY: "C:\\Python36-x64\\python.exe"
PYTHON64_LIBRARY: "C:\\Python36-x64\\libs\\python36.lib"
# Python 3.7
- PYTHON_VERSION: "3.7"
PYTHON32_PATH: "C:\\Python37"
PYTHON32_INCLUDE: "C:\\Python37\\include"
PYTHON32_BINARY: "C:\\Python37\\python.exe"
PYTHON32_LIBRARY: "C:\\Python37\\libs\\python37.lib"
PYTHON64_PATH: "C:\\Python37-x64"
PYTHON64_INCLUDE: "C:\\Python37-x64\\include"
PYTHON64_BINARY: "C:\\Python37-x64\\python.exe"
PYTHON64_LIBRARY: "C:\\Python37-x64\\libs\\python37.lib"
# Python 3.8
- PYTHON_VERSION: "3.8"
PYTHON32_PATH: "C:\\Python38"
PYTHON32_INCLUDE: "C:\\Python38\\include"
PYTHON32_BINARY: "C:\\Python38\\python.exe"
PYTHON32_LIBRARY: "C:\\Python38\\libs\\python38.lib"
PYTHON64_PATH: "C:\\Python38-x64"
PYTHON64_INCLUDE: "C:\\Python38-x64\\include"
PYTHON64_BINARY: "C:\\Python38-x64\\python.exe"
PYTHON64_LIBRARY: "C:\\Python38-x64\\libs\\python38.lib"
# Python 3.9
- PYTHON_VERSION: "3.9"
PYTHON32_PATH: "C:\\Python39"
PYTHON32_INCLUDE: "C:\\Python39\\include"
PYTHON32_BINARY: "C:\\Python39\\python.exe"
PYTHON32_LIBRARY: "C:\\Python39\\libs\\python39.lib"
PYTHON64_PATH: "C:\\Python39-x64"
PYTHON64_INCLUDE: "C:\\Python39-x64\\include"
PYTHON64_BINARY: "C:\\Python39-x64\\python.exe"
PYTHON64_LIBRARY: "C:\\Python39-x64\\libs\\python39.lib"
cache:
- '%SCCACHE_DIR%'
install:
- cmd: choco install sccache
- cmd: sccache.exe --start-server
- ps: if ($env:PLATFORM -eq "x64") { $env:CMAKE_ARCH = "x64" }
- ps: if ($env:PLATFORM -eq "x64") { $env:PYTHON_PATH = $env:PYTHON64_PATH }
- ps: if ($env:PLATFORM -eq "x64") { $env:PYTHON_INCLUDE = $env:PYTHON64_INCLUDE }
- ps: if ($env:PLATFORM -eq "x64") { $env:PYTHON_BINARY = $env:PYTHON64_BINARY }
- ps: if ($env:PLATFORM -eq "x64") { $env:PYTHON_LIBRARY = $env:PYTHON64_LIBRARY }
- ps: if ($env:PLATFORM -eq "x86") { $env:PYTHON_PATH = $env:PYTHON32_PATH }
- ps: if ($env:PLATFORM -eq "x86") { $env:PYTHON_INCLUDE = $env:PYTHON32_INCLUDE }
- ps: if ($env:PLATFORM -eq "x86") { $env:PYTHON_BINARY = $env:PYTHON32_BINARY }
- ps: if ($env:PLATFORM -eq "x86") { $env:PYTHON_LIBRARY = $env:PYTHON32_LIBRARY }
- set PATH=%PYTHON_PATH%;%PATH%
# Upgrade pip
- python.exe -m pip install --disable-pip-version-check --user --upgrade pip
- python.exe -m pip install --user wheel mako
- python.exe -m pip install --upgrade setuptools
build_script:
- cd %APPVEYOR_BUILD_FOLDER%
- python.exe .\setup.py --ninja --lief-test build bdist_wheel --skip-build && exit 0 # Ignore warnings...
- ps: if ($env:PYTHON_VERSION -eq "3.9") { python.exe .\scripts\windows\package_sdk.py }
after_build:
- ps: Get-Service -Name 'ssh-agent' | Set-Service -StartupType Manual
- ps: Start-Service -Name 'ssh-agent'
- cd %APPVEYOR_BUILD_FOLDER%
- ps: docker pull liefproject/deploy:latest
- ps: |
docker run `
-v ${PWD}:/src `
-e APPVEYOR="true" `
-e APPVEYOR_PULL_REQUEST_NUMBER="$env:APPVEYOR_PULL_REQUEST_NUMBER" `
-e APPVEYOR_REPO_NAME="$env:APPVEYOR_REPO_NAME" `
-e APPVEYOR_REPO_TAG_NAME="$env:APPVEYOR_REPO_TAG_NAME" `
-e APPVEYOR_REPO_BRANCH="$env:APPVEYOR_REPO_BRANCH" `
-e APPVEYOR_BUILD_FOLDER="$env:APPVEYOR_BUILD_FOLDER" `
-e LIEF_AUTOMATIC_BUILDS_KEY="$env:LIEF_AUTOMATIC_BUILDS_KEY" `
-e LIEF_AUTOMATIC_BUILDS_IV="$env:LIEF_AUTOMATIC_BUILDS_IV" `
--rm `
liefproject/deploy python3 /src/.github/deploy.py
$host.SetShouldExit(0)
on_finish:
- cmd: sccache.exe --stop-server
artifacts:
- path: 'dist\*.whl'
name: python-wheel
- path: 'build\*.zip'
name: sdk
#deploy:
# description: "LIEF version $(APPVEYOR_REPO_TAG_NAME)"
# provider: GitHub
# auth_token:
# secure: FU9CGrZ1lm0VDHUZg6zvTL4tidluDvRegVUTehCRo2xgiOv6NZePi7TdSy5CsOdG
# artifact: sdk;python-wheel
# draft: false
# prerelease: false
# force_update: true
# on:
# appveyor_repo_tag: true # deploy on tag push only
-35
View File
@@ -1,35 +0,0 @@
Checks: >
-*,
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
cppcoreguidelines-*,
-bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions,
-google-readability-namespace-comments,
-google-readability-todo,
-google-runtime-int,
-google-default-arguments
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-modernize-use-trailing-return-type,
-performance-noexcept-move-constructor,
-readability-function-cognitive-complexity,
-readability-inconsistent-declaration-parameter-name,
-readability-magic-numbers,
-readability-named-parameter,
-readability-redundant-string-cstr
-readability-uppercase-literal-suffix,
# Turn all the warnings from the checks above into errors.
#WarningsAsErrors: "*"
UseColor: false
CheckOptions:
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
+238 -113
View File
@@ -7,14 +7,9 @@ import pathlib
import subprocess
import shutil
import json
import itertools
from collections import defaultdict
from datetime import datetime
from mako.template import Template
from enum import Enum, auto
import tempfile
import boto3
from botocore.exceptions import ClientError
class CI(Enum):
UNKNOWN = auto()
@@ -101,7 +96,7 @@ def get_tag(ci):
logger.critical("Unsupported CI to resolve working directory")
sys.exit(1)
LOG_LEVEL = logging.INFO
LOG_LEVEL = logging.DEBUG
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
logging.getLogger().setLevel(LOG_LEVEL)
@@ -124,6 +119,7 @@ elif os.getenv("CI_LOCAL", "") == "true":
else:
logger.error("Can't detect CI!")
sys.exit(1)
# TODO(romain): Azure
CI_PRETTY_NAME = pretty_ci_name(CURRENT_CI)
logger.info("CI: %s", CI_PRETTY_NAME)
@@ -132,13 +128,9 @@ ALLOWED_BRANCHES = {"master", "deploy", "devel"}
BRANCH_NAME = get_branch(CURRENT_CI)
TAG_NAME = get_tag(CURRENT_CI)
IS_TAGGED = TAG_NAME is not None and len(TAG_NAME) > 0
logger.info("Branch: %s", BRANCH_NAME)
logger.info("Tag: %s", TAG_NAME)
if BRANCH_NAME.startswith("release-"):
logger.info("Branch release")
elif BRANCH_NAME not in ALLOWED_BRANCHES and not IS_TAGGED:
if BRANCH_NAME not in ALLOWED_BRANCHES and not IS_TAGGED:
logger.info("Skip deployment for branch '%s'", BRANCH_NAME)
sys.exit(0)
@@ -149,134 +141,267 @@ if is_pr(CURRENT_CI):
CURRENTDIR = pathlib.Path(__file__).resolve().parent
REPODIR = CURRENTDIR.parent
# According to Scaleway S3 documentation, the endpoint
# should starts with '<bucket>'.s3.<region>.scw.cloud
# Nevertheless boto3 uses /{Bucket} endpoints suffix
# which create issues (see: https://stackoverflow.com/a/70383653)
LIEF_S3_REGION = "fr-par"
LIEF_S3_ENDPOINT = "https://s3.{region}.scw.cloud".format(region=LIEF_S3_REGION)
LIEF_S3_BUCKET = "lief"
LIEF_S3_KEY = os.getenv("LIEF_S3_KEY", None)
LIEF_S3_SECRET = os.getenv("LIEF_S3_SECRET", None)
DEPLOY_KEY = os.getenv("LIEF_AUTOMATIC_BUILDS_KEY", None)
DEPLOY_IV = os.getenv("LIEF_AUTOMATIC_BUILDS_IV", None)
if LIEF_S3_KEY is None or len(LIEF_S3_KEY) == 0:
logger.error("LIEF_S3_KEY is not set!")
if DEPLOY_KEY is None or len(DEPLOY_KEY) == 0:
logger.error("Deploy key is not set!")
sys.exit(1)
if LIEF_S3_SECRET is None or len(LIEF_S3_SECRET) == 0:
logger.error("LIEF_S3_SECRET is not set!")
if DEPLOY_IV is None or len(DEPLOY_IV) == 0:
logger.error("Deploy IV is not set!")
sys.exit(1)
GIT_USER = "lief-{}-ci".format(CI_PRETTY_NAME)
GIT_EMAIL = "lief@quarkslab.com"
CI_CWD = pathlib.Path(get_ci_workdir(CURRENT_CI))
if CI_CWD is None:
logger.error("Can't resolve CI working dir")
logger.debug("Can't resolve CI working dir")
sys.exit(1)
DIST_DIR = REPODIR / "dist"
BUILD_DIR = REPODIR / "build"
LIEF_PACKAGE_REPO = "https://github.com/lief-project/packages.git"
LIEF_PACKAGE_DIR = REPODIR / "deploy-packages"
LIEF_PACKAGE_SSH_REPO = "git@github.com:lief-project/packages.git"
SDK_PACKAGE_DIR = LIEF_PACKAGE_DIR / "sdk"
PYPI_PACKAGE_DIR = LIEF_PACKAGE_DIR / "lief"
JSON_PACKAGE = LIEF_PACKAGE_DIR / "packages.json"
DIST_DIR = REPODIR / "dist"
BUILD_DIR = REPODIR / "build"
logger.info("Working directory: %s", CI_CWD)
logger.debug("Working directory: %s", CI_CWD)
SSH_DIR = pathlib.Path("~/.ssh").expanduser().resolve()
PYTHON = shutil.which("python")
GIT = shutil.which("git")
TAR = shutil.which("tar")
OPENSSL = shutil.which("openssl")
MV = shutil.which("mv")
RM = shutil.which("rm")
SSH_AGENT = shutil.which("ssh-agent")
SSH_ADD = shutil.which("ssh-add")
SSH_KEYSCAN = shutil.which("ssh-keyscan")
if DEPLOY_KEY is None:
logger.error("Deploy key is not set!")
sys.exit(1)
if DEPLOY_IV is None:
logger.error("Deploy IV is not set!")
sys.exit(1)
#####################
# Clone package repo
#####################
target_branch = "gh-pages"
if BRANCH_NAME != "master":
target_branch = "packages-{}".format(BRANCH_NAME.replace("/", "-").replace("_", "-"))
if IS_TAGGED:
target_branch = str(TAG_NAME)
new_branch = False
if not LIEF_PACKAGE_DIR.is_dir():
cmd = "{} clone --branch={} -j8 --single-branch {} {}".format(GIT, target_branch, LIEF_PACKAGE_REPO, LIEF_PACKAGE_DIR)
p = subprocess.Popen(cmd, shell=True, cwd=REPODIR, stderr=subprocess.STDOUT)
p.wait()
if p.returncode:
cmd = "{} clone --branch=master -j8 --single-branch {} {}".format(GIT, LIEF_PACKAGE_REPO, LIEF_PACKAGE_DIR)
pmaster = subprocess.Popen(cmd, shell=True, cwd=REPODIR, stderr=subprocess.STDOUT)
pmaster.wait()
if pmaster.returncode:
sys.exit(1)
new_branch = True
cmd = "{} checkout --orphan {}".format(GIT, target_branch)
pmaster = subprocess.Popen(cmd, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
pmaster.wait()
if pmaster.returncode:
sys.exit(1)
cmd = "{} reset --hard".format(GIT)
pmaster = subprocess.Popen(cmd, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
pmaster.wait()
SDK_PACKAGE_DIR.mkdir(exist_ok=True)
PYPI_PACKAGE_DIR.mkdir(exist_ok=True)
packages_info = {}
new_packages_info = {}
if JSON_PACKAGE.is_file():
try:
packages_info = json.loads(JSON_PACKAGE.read_bytes())
except json.decoder.JSONDecodeError as e:
logger.error(e)
else:
JSON_PACKAGE.touch()
logger.info("CI: %s - %s", GIT_USER, GIT_EMAIL)
cmds = [
"{} config user.name '{}'".format(GIT, GIT_USER),
"{} config user.email '{}'".format(GIT, GIT_EMAIL),
"{} reset --soft root".format(GIT),
"{} ls-files -v".format(GIT),
]
for cmd in cmds:
p = subprocess.Popen(cmd, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
p.wait()
if p.returncode:
sys.exit(1)
for file in DIST_DIR.glob("*.whl"):
logger.debug("Copying '%s' to '%s'", file.as_posix(), PYPI_PACKAGE_DIR.as_posix())
new_packages_info[file.name] = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
shutil.copy(file.as_posix(), PYPI_PACKAGE_DIR.as_posix())
for file in BUILD_DIR.glob("*.zip"):
logger.debug("Copying '%s' to '%s'", file.as_posix(), SDK_PACKAGE_DIR.as_posix())
new_packages_info[file.name] = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
shutil.copy(file.as_posix(), SDK_PACKAGE_DIR.as_posix())
for file in BUILD_DIR.glob("*.tar.gz"):
logger.debug("Copying '%s' to '%s'", file.as_posix(), SDK_PACKAGE_DIR.as_posix())
new_packages_info[file.name] = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
shutil.copy(file.as_posix(), SDK_PACKAGE_DIR.as_posix())
for k, v in new_packages_info.items():
logger.info("{:<30}: {}".format(k, v))
try:
packages_info.update(new_packages_info)
JSON_PACKAGE.write_text(json.dumps(packages_info))
except Exception as e:
logger.error(e)
INDEX_TEMPLATE = r"""
<!DOCTYPE html>
<html>
<title>Links for lief</title>
<body>
<h1>Links for lief</h1>
% for path, filename in files:
<a href="/${path}">${filename}</a><br />
% for name in names:
<a href="${base_url}/${base}/${name}">${name}</a><br />
% endfor
</body>
</html>
"""
SKIP_LIST = ["index.html"]
EXCLUDED = ['index.html', '.gitkeep']
BASE_URL = "https://lief-project.github.io"
s3 = boto3.resource(
's3',
region_name=LIEF_S3_REGION,
use_ssl=True,
endpoint_url=LIEF_S3_ENDPOINT,
aws_access_key_id=LIEF_S3_KEY,
aws_secret_access_key=LIEF_S3_SECRET
)
fnames = [fname for fname in sorted(f.name for f in PYPI_PACKAGE_DIR.iterdir() if f.is_file() and f.name not in EXCLUDED)]
html = Template(INDEX_TEMPLATE).render(names=fnames, base_url=BASE_URL, base="packages/lief")
with open((PYPI_PACKAGE_DIR / "index.html").as_posix(), "w") as f:
f.write(html)
def push_wheel(file: str, dir_name: str):
wheel_file = pathlib.Path(file)
dst = f"{dir_name}/lief/{wheel_file.name}"
logger.info("Uploading %s to %s", file, dst)
try:
obj = s3.Object(LIEF_S3_BUCKET, dst)
obj.put(Body=wheel_file.read_bytes())
return 0
except ClientError as e:
logger.error("S3 push failed: %s", e)
return 1
fnames = [fname for fname in sorted(f.name for f in SDK_PACKAGE_DIR.iterdir() if f.is_file() and f.name not in EXCLUDED)]
html = Template(INDEX_TEMPLATE).render(names=fnames, base_url=BASE_URL, base="packages/sdk")
with open((SDK_PACKAGE_DIR / "index.html").as_posix(), "w") as f:
f.write(html)
if not SSH_DIR.is_dir():
SSH_DIR.mkdir(mode=0o700)
#fix_ssh_perms()
deploy_key_path = (REPODIR / ".github" / "deploy-key.enc").as_posix()
output_key_path = (REPODIR / ".git" / "deploy-key")
cmd = "{} aes-256-cbc -K {} -iv {} -in {} -out {} -d".format(
OPENSSL, DEPLOY_KEY, DEPLOY_IV, deploy_key_path, output_key_path.as_posix())
kwargs = {
'shell': True,
'cwd': REPODIR,
'stdout': subprocess.DEVNULL,
'stderr': subprocess.DEVNULL,
}
p = subprocess.Popen(cmd, **kwargs)
p.wait()
if p.returncode:
sys.exit(1)
output_key_path.chmod(0o600)
logger.info(output_key_path)
process = subprocess.run(SSH_AGENT, stdout=subprocess.PIPE, universal_newlines=True, stderr=subprocess.STDOUT)
OUTPUT_PATTERN = re.compile(r'SSH_AUTH_SOCK=(?P<socket>[^;]+).*SSH_AGENT_PID=(?P<pid>\d+)', re.MULTILINE | re.DOTALL)
match = OUTPUT_PATTERN.search(process.stdout)
if match is None:
logger.error("Can't start ssh-agent")
sys.exit(1)
agent_data = match.groupdict()
logger.info(f'ssh agent data: {agent_data!s}')
logger.info('Exporting ssh agent environment variables' )
os.environ['SSH_AUTH_SOCK'] = agent_data['socket']
os.environ['SSH_AGENT_PID'] = agent_data['pid']
process = subprocess.run([SSH_ADD, output_key_path], stderr=subprocess.STDOUT)
if process.returncode != 0:
raise Exception(f'Failed to add the key: {output_key_path}')
known_hosts = (SSH_DIR / "known_hosts").as_posix()
cmd = "{} -H github.com >> {}".format(SSH_KEYSCAN, known_hosts)
kwargs = {
'shell': True,
'cwd': REPODIR,
'stderr': subprocess.STDOUT,
}
p = subprocess.Popen(cmd, **kwargs)
p.wait()
if p.returncode:
sys.exit(1)
commit_msg = 'Automatic deployment by {}'.format(CI_PRETTY_NAME)
cmds = [
"{} add .".format(GIT),
"{} commit -m '{}'".format(GIT, commit_msg),
"{} ls-files -v".format(GIT),
]
for cmd in cmds:
logger.info("Running %s", cmd)
p = subprocess.Popen(cmd, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
p.wait()
if p.returncode:
logger.error("Error while running %s", cmd)
sys.exit(1)
for i in range(10):
p = subprocess.Popen("{} push --force {} {}".format(GIT, LIEF_PACKAGE_SSH_REPO, target_branch),
shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
p.wait()
if p.returncode == 0:
break
cmds = [
"{} branch -a -v".format(GIT),
"{} fetch -v origin {}".format(GIT, target_branch),
"{} branch -a -v".format(GIT),
"{} rebase -s recursive -X theirs FETCH_HEAD".format(GIT),
"{} branch -a -v".format(GIT),
]
for c in cmds:
p = subprocess.Popen(c, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
p.wait()
else:
logger.critical("Can't push file on %s -> %s", LIEF_PACKAGE_SSH_REPO, target_branch)
sys.exit(1)
def push_sdk(file: str, dir_name: str):
sdk_file = pathlib.Path(file)
dst = f"{dir_name}/sdk/{sdk_file.name}"
logger.info("Uploading %s to %s", file, dst)
try:
obj = s3.Object(LIEF_S3_BUCKET, dst)
obj.put(Body=sdk_file.read_bytes())
return 0
except ClientError as e:
logger.error("S3 push failed: %s", e)
return 1
def filename(object):
return pathlib.Path(object.key).name
def generate_sdk_index(dir_name: str):
files = s3.Bucket(LIEF_S3_BUCKET).objects.filter(Prefix=f'{dir_name}/sdk')
tmpl_info = [(object.key, filename(object)) for object in files if filename(object) not in SKIP_LIST]
html = Template(INDEX_TEMPLATE).render(files=tmpl_info)
return html
def generate_pypi_index(dir_name: str):
files = s3.Bucket(LIEF_S3_BUCKET).objects.filter(Prefix=f'{dir_name}/lief')
tmpl_info = [(object.key, filename(object)) for object in files if filename(object) not in SKIP_LIST]
html = Template(INDEX_TEMPLATE).render(files=tmpl_info)
return html
dir_name = "latest"
if BRANCH_NAME != "master":
dir_name = "{}".format(BRANCH_NAME.replace("/", "-").replace("_", "-"))
if BRANCH_NAME.startswith("release-"):
_, dir_name = BRANCH_NAME.split("release-")
if IS_TAGGED:
dir_name = str(TAG_NAME)
logger.info("Destination directory: %s", dir_name)
for file in DIST_DIR.glob("*.whl"):
logger.info("[WHEEL] Uploading '%s'", file.as_posix())
push_wheel(file.as_posix(), dir_name)
for file in itertools.chain(BUILD_DIR.glob("*.zip"), BUILD_DIR.glob("*.tar.gz")):
logger.info("[SDK ] Uploading '%s'", file.as_posix())
push_sdk(file.as_posix(), dir_name)
sdk_index = generate_sdk_index(dir_name)
with tempfile.TemporaryDirectory() as tmp:
tmp = pathlib.Path(tmp)
index = (tmp / "index.html")
index.write_text(sdk_index)
push_sdk(index.as_posix(), dir_name)
pypi_index = generate_pypi_index(dir_name)
with tempfile.TemporaryDirectory() as tmp:
tmp = pathlib.Path(tmp)
index = (tmp / "index.html")
index.write_text(pypi_index)
push_wheel(index.as_posix(), dir_name)
output_key_path.unlink()
logger.info("Done!")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

+4 -10
View File
@@ -42,16 +42,10 @@ jobs:
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/android-arm64 bash /work/scripts/docker/android-aarch64.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: android-sdk
path: build/*.tar.gz
retention-days: 3
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
shell: bash
run: |
docker run \
@@ -60,8 +54,8 @@ jobs:
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py
+3 -9
View File
@@ -41,19 +41,13 @@ jobs:
CCACHE_COMPRESS: 1
run: |
bash scripts/osx/package_ios.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: ios-sdk
path: build/*.tar.gz
retention-days: 3
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
shell: bash
run: |
python -m pip install --upgrade requests mako boto3
python -m pip install --upgrade requests mako
python .github/deploy.py
+4 -17
View File
@@ -50,23 +50,10 @@ jobs:
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.sh
- name: 'Upload SDK Artifact'
if: matrix.python-version == '3.9'
uses: actions/upload-artifact@v3
with:
name: linux-aarch64-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload Python Wheel Artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
with:
name: linux-aarch64-wheel-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
shell: bash
run: |
docker run \
@@ -75,8 +62,8 @@ jobs:
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py
+9 -53
View File
@@ -20,22 +20,6 @@ jobs:
key: linux-x86-64-${{ runner.os }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-
- name: Build Python 3.6 wheel
shell: bash
if: startsWith(github.ref, 'refs/tags/')
env:
PYTHON_VERSION: 36
run: |
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp36-cp36m/bin/python3.6 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
- name: Build Python 3.7 wheel
shell: bash
env:
@@ -50,7 +34,7 @@ jobs:
-e PYTHON_BINARY=/opt/python/cp37-cp37m/bin/python3.7 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build Python 3.8 wheel
shell: bash
env:
@@ -65,7 +49,7 @@ jobs:
-e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build Python 3.9 wheel
shell: bash
env:
@@ -80,22 +64,7 @@ jobs:
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
- name: Build Python 3.10 wheel
shell: bash
env:
PYTHON_VERSION: 310
run: |
docker run --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp310-cp310/bin/python3.10 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build SDK
shell: bash
run: |
@@ -106,23 +75,11 @@ jobs:
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux_sdk.sh
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-x86-64-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-x86-64-python-wheel
path: dist/*.whl
retention-days: 3
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux-sdk.sh
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
shell: bash
run: |
docker run \
@@ -131,19 +88,18 @@ jobs:
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-e LIEF_S3_KEY=$LIEF_S3_KEY \
-e LIEF_S3_SECRET=$LIEF_S3_SECRET \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py
- name: Trigger documentation
if: github.ref == 'refs/heads/master'
env:
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
shell: bash
run: |
docker run --rm \
-e CIRCLE_CI_TOKEN=$CIRCLE_CI_TOKEN \
liefproject/manylinux_2_24_x86_64 \
liefproject/manylinux1_x86_64 \
bash -c "curl --request POST --url https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline --header 'Circle-Token: ${CIRCLE_CI_TOKEN}' --header 'content-type: application/json'";
+6 -30
View File
@@ -6,7 +6,7 @@ jobs:
runs-on: macos-11.0
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
with:
@@ -32,23 +32,12 @@ jobs:
uses: actions/cache@v1.1.0
with:
path: ~/.ccache
key: osx-${{ runner.os }}-${{ steps.get-date.outputs.date }}
key: osx-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
osx-${{ runner.os }}-${{ matrix.python-version }}-
osx-${{ runner.os }}-
- name: Build Python ${{ matrix.python-version }} wheel and Test
shell: bash
if: matrix.python-version == '3.6'
env:
MACOSX_DEPLOYMENT_TARGET: "10.14"
CCACHE_DIR: ~/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
run: |
python ./setup.py --ninja build bdist_wheel --skip-build --plat-name=macosx_${MACOSX_DEPLOYMENT_TARGET}_x86_64
- name: Build Python ${{ matrix.python-version }} wheel
shell: bash
if: matrix.python-version != '3.6'
env:
MACOSX_DEPLOYMENT_TARGET: "10.14"
CCACHE_DIR: ~/.ccache
@@ -68,26 +57,13 @@ jobs:
CCACHE_COMPRESS: 1
run: |
bash scripts/osx/package_sdk.sh
- name: 'Upload SDK Artifact'
if: matrix.python-version == '3.9' # Build the SDk only with Python 3.9
uses: actions/upload-artifact@v3
with:
name: osx-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload Python Wheel Artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
with:
name: osx-wheel-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
shell: bash
run: |
python -m pip install --upgrade requests mako boto3
python -m pip install --upgrade requests mako
python .github/deploy.py
-50
View File
@@ -1,50 +0,0 @@
name: 'sanitize'
on:
push:
tags:
- '**'
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-e BUILD_DIR=/tmp/build_gcc \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/gcc.sh
clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-e BUILD_DIR=/tmp/build_clang \
-e SRC_DIR=/src \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/clang.sh
asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: compile
shell: bash
run: |
docker run --rm \
-v $GITHUB_WORKSPACE:/src \
liefproject/sanity:latest bash /src/scripts/docker/asan_check.sh
-116
View File
@@ -1,116 +0,0 @@
name: LIEF Windows x64
on:
push:
branches:
- 'master'
- 'release-**'
tags:
- '**'
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools
python -m pip install wheel mako
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
key: ${{ runner.os }}-x64-sccache-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-x64-sccache-
- name: Start sccache server
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
if: matrix.python-version == 3.6
run: |
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: ❱ Build Python ${{ matrix.python-version }}
if: matrix.python-version != 3.6
run: |
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: ❱ Build SDK
if: matrix.python-version == 3.9
run: |
python ./scripts/windows/package_sdk.py
- name: 'Upload SDK Artifact'
if: matrix.python-version == 3.9
uses: actions/upload-artifact@v3
with:
name: windows-x64-sdk
path: build/*.zip
retention-days: 3
- name: 'Upload Python Wheel Artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
with:
name: windows-x64-wheel-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
- name: 📊 Print sccache stats
run: sccache --show-stats
- name: 🛑 Stop sccache server
run: sccache --stop-server || true
- name: Setup WSL
uses: Vampire/setup-wsl@v1
with:
distribution: Debian
use-cache: 'true'
wsl-shell-user: root
set-as-default: 'true'
wsl-conf: |
[automount]
options = "metadata"
additional-packages:
ca-certificates
curl
locales
python3 python3-pip
git
openssl
ssh
- shell: wsl-bash {0}
name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
GITHUB_ACTIONS: "true"
GITHUB_WORKSPACE: ${{ env.GITHUB_WORKSPACE }}
GITHUB_REF: ${{ env.GITHUB_REF }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }}
WSLENV: LIEF_S3_KEY:LIEF_S3_SECRET:GITHUB_ACTIONS:GITHUB_WORKSPACE:GITHUB_REF:GITHUB_REPOSITORY
run: |
python3 -m pip install --no-cache-dir --upgrade pip setuptools requests mako wheel boto3
python3 .github/deploy.py
-62
View File
@@ -1,62 +0,0 @@
name: LIEF Windows x64 Quick
on:
push:
branches:
- '**'
- '!master'
- '!release-**'
tags-ignore:
- "**"
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
python-version: [3.9]
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools
python -m pip install wheel mako
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
key: ${{ runner.os }}-x64-sccache-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-x64-sccache-
- name: Start sccache server
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
run: |
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: 📊 Print sccache stats
run: sccache --show-stats
- name: 🛑 Stop sccache server
run: sccache --stop-server || true
-116
View File
@@ -1,116 +0,0 @@
name: LIEF Windows x86
on:
push:
branches:
- 'master'
- 'release-**'
tags:
- '**'
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
architecture: x86
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools
python -m pip install wheel mako
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
key: ${{ runner.os }}-x86-sccache-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-x86-sccache-
- name: Start sccache server
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
if: matrix.python-version == 3.6
run: |
python ./setup.py --ninja bdist_wheel --plat-name=win32
shell: cmd
- name: ❱ Build Python ${{ matrix.python-version }}
if: matrix.python-version != 3.6
run: |
python ./setup.py --ninja bdist_wheel --plat-name=win32
shell: cmd
- name: ❱ Build SDK
if: matrix.python-version == 3.9
run: |
python ./scripts/windows/package_sdk.py
- name: 'Upload SDK Artifact'
if: matrix.python-version == 3.9
uses: actions/upload-artifact@v3
with:
name: windows-x86-sdk
path: build/*.zip
retention-days: 3
- name: 'Upload Python Wheel Artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
with:
name: windows-x86-wheel-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
- name: 📊 Print sccache stats
run: sccache --show-stats
- name: 🛑 Stop sccache server
run: sccache --stop-server || true
- name: Setup WSL
uses: Vampire/setup-wsl@v1
with:
distribution: Debian
use-cache: 'true'
wsl-shell-user: root
set-as-default: 'true'
wsl-conf: |
[automount]
options = "metadata"
additional-packages:
ca-certificates
curl
locales
python3 python3-pip
git
openssl
ssh
- shell: wsl-bash {0}
name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
GITHUB_ACTIONS: "true"
GITHUB_WORKSPACE: ${{ env.GITHUB_WORKSPACE }}
GITHUB_REF: ${{ env.GITHUB_REF }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY }}
WSLENV: LIEF_S3_KEY:LIEF_S3_SECRET:GITHUB_ACTIONS:GITHUB_WORKSPACE:GITHUB_REF:GITHUB_REPOSITORY
run: |
python3 -m pip install --no-cache-dir --upgrade pip setuptools requests mako wheel boto3
python3 .github/deploy.py
-62
View File
@@ -1,62 +0,0 @@
name: LIEF Windows x86 Quick
on:
push:
branches:
- '**'
- '!master'
- '!release-**'
tags-ignore:
- "**"
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
python-version: [3.9]
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x86
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools
python -m pip install wheel mako
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Save sccache
uses: actions/cache@v2
continue-on-error: false
with:
path: "C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache"
key: ${{ runner.os }}-x86-sccache-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-x86-sccache-
- name: Start sccache server
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
run: |
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: 📊 Print sccache stats
run: sccache --show-stats
- name: 🛑 Stop sccache server
run: sccache --stop-server || true
@@ -1,4 +1,4 @@
name: LIEF PR Windows Tests
name: LIEF Windows Tests
on: [pull_request]
+322
View File
@@ -0,0 +1,322 @@
language: cpp
git:
depth: false
jobs:
include:
- if: branch = master AND tag IS present
services: docker
name: "Linux Python 3.5"
script:
- >
docker run --name lief_35
-e PYTHON_BINARY=/opt/python/cp35-cp35m/bin/python3.5
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux.sh
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
docker run \
-v $TRAVIS_BUILD_DIR:/src \
-e TRAVIS="true" \
-e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py;
fi
- if: branch = master AND tag IS present
services: docker
name: "Linux Python 3.6"
script:
- >
docker run --name lief_36
-e PYTHON_BINARY=/opt/python/cp36-cp36m/bin/python3.6
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux.sh
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
docker run \
-v $TRAVIS_BUILD_DIR:/src \
-e TRAVIS="true" \
-e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py;
fi
- services: docker
name: "Linux Python 3.7 | SDK | Doc Trigger"
script:
- >
docker run --name lief_37
-e PYTHON_BINARY=/opt/python/cp37-cp37m/bin/python3.7
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux.sh
- >
docker run --name lief_sdk
-e PYTHON_BINARY=$PYTHON_BINARY
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux-sdk.sh
- >
sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
docker run \
-v $TRAVIS_BUILD_DIR:/src \
-e TRAVIS="true" \
-e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py;
fi
after_success:
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]];
then
docker run --rm
-e CIRCLE_CI_TOKEN=$CIRCLE_CI_TOKEN
liefproject/manylinux1_x86_64
bash -c "curl --request POST --url https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline --header 'Circle-Token: ${CIRCLE_CI_TOKEN}' --header 'content-type: application/json'";
fi
- services: docker
name: "Linux Python 3.8"
script:
- >
docker run --name lief_38
-e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux.sh
- >
sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
docker run \
-v $TRAVIS_BUILD_DIR:/src \
-e TRAVIS="true" \
-e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py;
fi
- services: docker
name: "Linux Python 3.9"
script:
- >
docker run --name lief_39
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9
-e CCACHE_DIR=/ccache
-v $HOME/.ccache:/ccache
-v $TRAVIS_BUILD_DIR:/src
liefproject/manylinux1_x86_64
bash /src/scripts/docker/travis-linux.sh
- >
sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
- >
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
docker run \
-v $TRAVIS_BUILD_DIR:/src \
-e TRAVIS="true" \
-e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
-e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
-e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
--rm \
liefproject/deploy python3 /src/.github/deploy.py;
fi
## macOS 10.14.6 - xcode 11 - Python 3.5
#- if: branch = master AND tag IS present AND type = push
# os: osx
# osx_image: xcode11
# compiler: clang
# script:
# - pyenv install --skip-existing 3.5.0
# - >
# export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
# $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
# after_success:
# - >
# if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
# export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
# cd $TRAVIS_BUILD_DIR &&
# bash ./.github/deploy.sh;
# fi
## macOS 10.14.6 - xcode 11 - Python 3.6
#- if: branch = master AND tag IS present AND type = push
# os: osx
# osx_image: xcode11
# compiler: clang
# script:
# - pyenv install --skip-existing 3.6.0
# - >
# export PYTHON_BINARY=$(pyenv root)/versions/3.6.0/bin/python3.6 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
# $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
# after_success:
# - >
# if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
# export PYTHON_BINARY=$(pyenv root)/versions/3.6.0/bin/python3.6 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
# cd $TRAVIS_BUILD_DIR &&
# bash ./.github/deploy.sh;
# fi
## macOS 10.14.6 - xcode 11 - Python 3.7
#- os: osx
# osx_image: xcode11
# compiler: clang
# script:
# - pyenv install --skip-existing 3.7.0
# - >
# export PYTHON_BINARY=$(pyenv root)/versions/3.7.0/bin/python3.7 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
# $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
# after_success:
# - >
# if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
# export PYTHON_BINARY=$(pyenv root)/versions/3.7.0/bin/python3.7 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
# cd $TRAVIS_BUILD_DIR &&
# bash ./.github/deploy.sh;
# fi
# macOS 10.14.6 - xcode 11 - Python 3.8
#- os: osx
# osx_image: xcode11
# compiler: clang
# name: "OSX Python 3.8"
# script:
# - pyenv install --skip-existing 3.8.0
# - >
# export PYTHON_BINARY=$(pyenv root)/versions/3.8.0/bin/python3.8 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
# $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
# after_success:
# - >
# if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
# export PYTHON_BINARY=$(pyenv root)/versions/3.8.0/bin/python3.8 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
# cd $TRAVIS_BUILD_DIR &&
# bash ./.github/deploy.sh;
# fi
## macOS 10.14.6 - xcode 11 - Python 3.9
#- os: osx
# osx_image: xcode11
# compiler: clang
# name: "OSX Python 3.9 | SDK"
# script:
# - pyenv install --skip-existing 3.9.0
# - >
# export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
# $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
# - bash scripts/osx/package_sdk.sh
# after_success:
# - >
# if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
# export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9 &&
# sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
# cd $TRAVIS_BUILD_DIR &&
# bash ./.github/deploy.sh;
# fi
#branches:
# only:
# - master
notifications:
email:
on_success: never
on_failure: always
cache:
- ccache: true
- directories:
- $HOME/.pyenv
- $HOME/.ccache
env:
global:
- USE_CCACHE=1
- CCACHE_COMPRESS=1
- CCACHE_MAXSIZE=10.0G
- CCACHE_CPP2=1
addons:
homebrew:
packages:
- pyenv
- ccache
- ninja
update: true
before_install:
- ccache --set-config=max_size=10.0G
- ccache --zero-stats --version
- ccache --set-config=compiler_check=content
- ccache -p
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then docker pull liefproject/manylinux1_x86_64:latest; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PREFIX="/usr/local"; fi
#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PYTHON_CONFIGURE_OPTS="--enable-shared --enable-unicode=ucs2"; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then pyenv root; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then pyenv install --list ;fi
after_script:
- ccache --show-stats
#deploy:
# provider: releases
# token:
# - secure: LTJMZp9kJ9/tmv73YGktP3Bdhh3moettDNooiRlQfUEgUemRlp9K+ybbufN0ya0Md0bouOJ/7nWqFToWl1G5/kcRr4MjV/P2c+iH8W7mvWcFupLGdwm1+aqpin3hiGsdYz0a1TK37y6DANspFwHILjq1SPf5L8kGEHnYSIfyUFHaETbv7GHL+4gf1XG/55KVuyFa3vZ2BPa3sIXr4bRypdNsqssFOZ7qeoJawtcI3TbjmLqx+sOGR2aiG+9lX+/vcYVGECHOE4KdV5BbTFitDLkJ0toAQrgN4XuB6XMXEnijU0RGtpkvsUAYJUuYaNcV2ea4bwLPCKz0IJvzTw3gtyB/pioP4OUx0xY2csuNuGfppZ0Fb+BWhPx9wOg209lrPjtoWszK8vo4PywKlEUviNG+3hEYx9x382IbtbXvIxp+c2iYdRicudFIdjjSZt7fy1MwBvHhWoBRl1hVw5fpFvRIC6Q1/B6MV55Jc3LVYCs+QHPAXq2KJ1KWK/Q7mmlriG3O+dvswcE1l0/AmeqKuXLsgUMuzScYa4fMFvXL3l/B8bKw205ynMzKvbb61P3sGrJJ+AFDEoHDk8yNtSaTowoUveu75DbL1s1p02QjYeVt7AJS8AsqUm7QPcUU5iXW1gSgt50jD/46/uvK7NZCFj2LzkiVzM5JIbiUANx8pKA=
# file_glob: true
# file:
# - ${TRAVIS_BUILD_DIR}/dist/*.whl
# - ${TRAVIS_BUILD_DIR}/build/*.tar.gz
# on:
# tags: true
+1 -1
View File
@@ -1,3 +1,3 @@
Authors:
Romain Thomas <me@romainthomas.fr> - Quarkslab
Romain Thomas <rthomas@quarkslab.com>
+1
View File
@@ -1,5 +1,6 @@
Changelog
=========
see doc/sphinx/changelog.rst
+119 -230
View File
@@ -4,14 +4,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
set(IS_WIN_CROSS_COMPILE 0)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_CROSSCOMPILING)
set(IS_WIN_CROSS_COMPILE 1)
endif()
if(WIN32 OR ${IS_WIN_CROSS_COMPILE})
if(WIN32)
include(ChooseMSVCCRT)
endif()
include(CheckCXXCompilerFlag)
@@ -29,7 +22,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
else()
set(LIEF_VERSION_MAJOR "0")
set(LIEF_VERSION_MINOR "12")
set(LIEF_VERSION_PATCH "2")
set(LIEF_VERSION_PATCH "0")
endif()
# LIEF Project
@@ -57,7 +50,7 @@ if(LIEF_USE_CCACHE)
message(STATUS "Found ccache: ${CCACHE_FOUND}")
else()
find_program(SCCACHE_FOUND sccache)
if(SCCACHE_FOUND)
if (SCCACHE_FOUND)
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_FOUND})
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_FOUND})
message(STATUS "Found sccache: ${SCCACHE_FOUND}")
@@ -97,6 +90,9 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
# LIEF Source definition
# ======================
set_source_files_properties(${mbedtls_src_crypto} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_x509} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_tls} PROPERTIES GENERATED TRUE)
set(LIEF_PRIVATE_INCLUDE_DIR)
set(LIEF_PUBLIC_INCLUDE_DIR)
@@ -105,21 +101,22 @@ set(LIEF_PUBLIC_INCLUDE_FILES)
set(LIEF_PRIVATE_INCLUDE_FILES)
set(LIBLIEF_SOURCE_FILES
"${mbedtls_src_crypto}"
"${mbedtls_src_x509}"
"${mbedtls_src_tls}"
"${LIBFUZZER_SRC_FILES}"
"${CMAKE_CURRENT_SOURCE_DIR}/src/errors.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/exception.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/iostream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.tcc"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Visitor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/BinaryStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/VectorStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/FileStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/MemoryStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/SpanStream.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/Convert.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/hash.cpp")
@@ -127,7 +124,6 @@ set(LIBLIEF_SOURCE_FILES
# ===============================
set(LIEF_INC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/errors.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/span.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/exception.hpp"
@@ -145,14 +141,10 @@ set(LIEF_INC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visitor_macros.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/BinaryStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/VectorStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/FileStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/MemoryStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/SpanStream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/Convert.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/frozen.hpp"
)
"${CMAKE_CURRENT_SOURCE_DIR}/src/frozen.hpp")
set(LIEF_VISITOR_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/hash.hpp")
@@ -160,14 +152,12 @@ set(LIEF_VISITOR_INCLUDE_FILES
set(LIEF_INCLUDE_FILES ${LIEF_INC_FILES} ${LIEF_VISITOR_INCLUDE_FILES})
set(LIEF_JSON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/json.cpp")
set(LIEF_JSON_HDR "${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp")
list(APPEND LIEF_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/json.hpp")
list(APPEND LIBLIEF_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/json_api.cpp")
set(LIEF_JSON_HDR "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/json.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp")
if(LIEF_ENABLE_JSON)
list(APPEND LIBLIEF_SOURCE_FILES "${LIEF_JSON_SRC}")
list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}")
list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}")
endif()
source_group("Header Files" FILES ${LIEF_INC_FILES})
@@ -176,40 +166,12 @@ source_group("Source Files" FILES ${LIBLIEF_SOURCE_FILES})
source_group("Header Files\\visitors" FILES ${LIEF_VISITOR_INCLUDE_FILES})
add_library(LIB_LIEF ${LIBLIEF_SOURCE_FILES} ${LIEF_INCLUDE_FILES})
add_library(LIEF::LIEF ALIAS LIB_LIEF)
if(NOT LIEF_OPT_MBEDTLS_EXTERNAL)
set_source_files_properties(${mbedtls_src_crypto} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_x509} PROPERTIES GENERATED TRUE)
set_source_files_properties(${mbedtls_src_tls} PROPERTIES GENERATED TRUE)
target_sources(LIB_LIEF PRIVATE
"${mbedtls_src_crypto}"
"${mbedtls_src_x509}"
"${mbedtls_src_tls}")
source_group("mbedtls\\crypto" FILES ${mbedtls_src_crypto})
source_group("mbedtls\\x509" FILES ${mbedtls_src_x509})
source_group("mbedtls\\tls" FILES ${mbedtls_src_tls})
target_include_directories(
LIB_LIEF SYSTEM PRIVATE
"${MBEDTLS_INCLUDE_DIRS}"
"${MBEDTLS_SOURCE_DIR}/library"
)
add_dependencies(LIB_LIEF lief_mbed_tls)
else()
find_package(MbedTLS REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE
MbedTLS::mbedcrypto
MbedTLS::mbedx509)
endif()
if(WINDOWS AND BUILD_SHARED_LIBS)
target_link_libraries(LIB_LIEF ws2_32)
endif()
if(MSVC OR ${IS_WIN_CROSS_COMPILE})
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
@@ -275,6 +237,7 @@ endif()
# Frozen Configuration
# ====================
if(LIEF_FROZEN_ENABLED)
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${FROZEN_INCLUDE_DIR}")
endif()
# OAT part
@@ -325,8 +288,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/config.h" @ONLY)
list(APPEND LIEF_PUBLIC_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
list(APPEND LIEF_PUBLIC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/"
"${CMAKE_CURRENT_BINARY_DIR}/include/")
@@ -336,110 +298,63 @@ list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}"
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LIEF.pc.in ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
@ONLY)
target_include_directories(LIB_LIEF
PUBLIC "$<BUILD_INTERFACE:${LIEF_PUBLIC_INCLUDE_DIR}>"
# Grouping external projects
# ==========================
source_group("mbedtls\\crypto" FILES ${mbedtls_src_crypto})
source_group("mbedtls\\x509" FILES ${mbedtls_src_x509})
source_group("mbedtls\\tls" FILES ${mbedtls_src_tls})
# Library definition
# ==================
target_include_directories(
LIB_LIEF SYSTEM PRIVATE "${MBEDTLS_INCLUDE_DIRS}")
target_include_directories(
LIB_LIEF
PUBLIC "${LIEF_PUBLIC_INCLUDE_DIR}"
PRIVATE "${LIEF_PRIVATE_INCLUDE_DIR}")
if(LIEF_ENABLE_JSON)
if(LIEF_OPT_NLOHMANN_JSON_EXTERNAL)
find_package(nlohmann_json REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE nlohmann_json::nlohmann_json)
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/internal/nlohmann/json.hpp
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/internal/nlohmann
COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBJSON_SOURCE_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/internal/nlohmann/
DEPENDS lief_libjson)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp
COMMAND
${CMAKE_COMMAND} -E copy_directory ${LIBJSON_SOURCE_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/
DEPENDS lief_libjson)
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/internal/nlohmann/json.hpp)
target_include_directories(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/)
endif()
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp)
endif()
if(LIEF_FROZEN_ENABLED)
if(LIEF_OPT_FROZEN_EXTERNAL)
find_package(frozen REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE frozen::frozen)
else()
add_dependencies(LIB_LIEF lief_frozen)
target_include_directories(LIB_LIEF
PRIVATE "${FROZEN_INCLUDE_DIR}")
endif()
add_dependencies(LIB_LIEF lief_frozen)
endif()
# =======================================
# Leaf
# =======================================
if(LIEF_EXTERNAL_LEAF)
message(STATUS "Using external LEAF version")
if(LIEF_EXTERNAL_LEAF_DIR)
message(STATUS "External LEAF include dir: ${LIEF_EXTERNAL_LEAF_DIR}")
target_include_directories(LIB_LIEF SYSTEM PUBLIC
"$<BUILD_INTERFACE:${LIEF_EXTERNAL_LEAF_DIR}>")
endif()
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/leaf.hpp
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
COMMAND
${CMAKE_COMMAND} -E copy_directory ${LEAF_SRC_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
DEPENDS lief_leaf)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/boost/leaf/all.hpp
COMMAND
${CMAKE_COMMAND} -E copy_directory ${LEAF_INCLUDE_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/
DEPENDS lief_leaf)
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/leaf.hpp)
endif()
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/boost/leaf/all.hpp)
# =======================================
# utfcpp
# =======================================
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/utfcpp/utf8.h
COMMAND
${CMAKE_COMMAND} -E copy_directory ${UTFCPP_INCLUDE_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/utfcpp
DEPENDS lief_utfcpp)
if(LIEF_OPT_UTFCPP_EXTERNAL)
find_package(utf8cpp REQUIRED)
target_link_libraries(LIB_LIEF PRIVATE utf8cpp)
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/internal/utfcpp/utf8.h
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/internal/
COMMAND
${CMAKE_COMMAND} -E copy_directory ${UTFCPP_INCLUDE_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/internal/utfcpp
DEPENDS lief_utfcpp)
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/internal/utfcpp/utf8.h)
endif()
# =======================================
# tcb/span
# =======================================
if(LIEF_EXTERNAL_SPAN)
message(STATUS "Using external tcb/span version")
if(LIEF_EXTERNAL_SPAN_DIR)
message(STATUS "External span include dir: ${LIEF_EXTERNAL_SPAN_DIR}")
target_include_directories(LIB_LIEF SYSTEM PUBLIC
"$<BUILD_INTERFACE:${LIEF_EXTERNAL_SPAN_DIR}>")
endif()
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
COMMAND
${CMAKE_COMMAND} -E copy_directory ${TCB_SPAN_SRC_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
DEPENDS lief_span)
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp)
endif()
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/utfcpp/utf8.h)
add_dependencies(LIB_LIEF lief_mbed_tls)
target_link_libraries(LIB_LIEF PRIVATE lief_spdlog)
# Flags definition
@@ -469,19 +384,22 @@ target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
# SpcSpAgencyInfo Critical Extension, which mbed TLS doesn't support, so set
# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION to have it skip this
# extension.
add_definitions(-DMBEDTLS_FS_IO -DMBEDTLS_PEM_PARSE_C -DMBEDTLS_BIGNUM_C
add_definitions(-DMBEDTLS_MD2_C -DMBEDTLS_MD4_C -DMBEDTLS_PEM_PARSE_C
-DMBEDTLS_X509_CRT_PARSE_C -DMBEDTLS_PEM_WRITE_C
-DMBEDTLS_PKCS1_V15 -DMBEDTLS_PKCS1_V21)
-DMBEDTLS_PKCS1_V15 -DMBEDTLS_PKCS1_V21
-DMBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION)
# LIEF Sanitizer options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ASAN - LSAN - TSAN - USAN
# ~~~
set(SANITIZER_FLAGS -fno-omit-frame-pointer -g -O1)
if(LIEF_ASAN)
message(STATUS "Address sanitizer enabled")
list(APPEND SANITIZER_FLAGS -fsanitize=address)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS -fsanitize=address)
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS -fsanitize=address)
target_link_libraries(LIB_LIEF INTERFACE asan)
endif()
@@ -489,8 +407,10 @@ if(LIEF_LSAN)
message(STATUS "Leak sanitizer enabled")
list(APPEND SANITIZER_FLAGS -fsanitize=leak)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS -fsanitize=leak)
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS -fsanitize=leak)
target_link_libraries(LIB_LIEF INTERFACE lsan)
endif()
@@ -499,46 +419,46 @@ if(LIEF_TSAN)
message(STATUS "Thread sanitizer enabled")
list(APPEND SANITIZER_FLAGS -fsanitize=thread)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS -fsanitize=thread)
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS -fsanitize=thread)
target_link_libraries(LIB_LIEF INTERFACE tsan)
endif()
if(LIEF_USAN)
message(STATUS "Undefined sanitizer enabled")
list(APPEND SANITIZER_FLAGS -fsanitize=undefined,null,alignment)
list(APPEND SANITIZER_FLAGS -fsanitize=undefined)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS -fsanitize=undefined,null,alignment)
target_link_options(LIB_LIEF PUBLIC -fsanitize=undefined,null,alignment)
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS -fsanitize=undefined)
target_link_libraries(LIB_LIEF PUBLIC ubsan -fsanitize=undefined,null,alignment)
target_link_libraries(LIB_LIEF INTERFACE ubsan)
endif()
set(LIEF_SANITIZER OFF)
if(LIEF_ASAN OR LIEF_LSAN OR LIEF_TSAN OR LIEF_USAN)
set(LIEF_SANITIZER ON)
if(LIEF_ASAN
OR LIEF_LSAN
OR LIEF_TSAN
OR LIEF_USAN)
target_compile_options(LIB_LIEF PRIVATE ${SANITIZER_FLAGS})
endif()
if(LIEF_SANITIZER)
message("LIEF Sanitizer enabled: ${SANITIZER_FLAGS}")
target_compile_options(LIB_LIEF PUBLIC ${SANITIZER_FLAGS})
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/sanitizer")
endif()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Fuzzing options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Fuzzing
# ~~~
if(LIEF_FUZZING)
set(FUZZING_FLAGS -fno-omit-frame-pointer -g -O2 -fsanitize=address,fuzzer-no-link)
set(FUZZING_LINKER_FLAGS -fsanitize=address,fuzzer-no-link)
set_property(TARGET LIB_LIEF
APPEND PROPERTY LINK_FLAGS ${FUZZING_LINKER_FLAGS})
set_property(
TARGET LIB_LIEF
APPEND
PROPERTY LINK_FLAGS ${FUZZING_LINKER_FLAGS})
target_compile_options(LIB_LIEF PRIVATE ${FUZZING_FLAGS})
target_link_libraries(LIB_LIEF PUBLIC asan pthread)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/fuzzing")
target_link_libraries(LIB_LIEF asan pthread)
add_dependencies(LIB_LIEF lief_libfuzzer)
endif()
# Compile Flags
@@ -556,10 +476,6 @@ if(LIEF_PROFILING)
add_executable(elf_profiler profiling/elf_profiler.cpp)
target_compile_options(elf_profiler PUBLIC ${PROFILING_FLAGS})
target_link_libraries(elf_profiler PRIVATE LIB_LIEF)
add_executable(macho_profiler profiling/macho_profiler.cpp)
target_compile_options(macho_profiler PUBLIC ${PROFILING_FLAGS})
target_link_libraries(macho_profiler PRIVATE LIB_LIEF)
endif()
# Coverage flags
@@ -570,7 +486,7 @@ if(LIEF_COVERAGE)
target_link_libraries(LIB_LIEF gcov)
endif()
set_target_properties(LIB_LIEF PROPERTIES OUTPUT_NAME LIEF EXPORT_NAME LIEF CLEAN_DIRECT_OUTPUT 1)
set_target_properties(LIB_LIEF PROPERTIES OUTPUT_NAME LIEF CLEAN_DIRECT_OUTPUT 1)
# Set a default build type if none was specified
@@ -581,14 +497,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
"MinSizeRel" "RelWithDebInfo")
endif()
message(STATUS "Configuration Types: ${CMAKE_CONFIGURATION_TYPES}")
message(STATUS "Build Types: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build Types: ${CMAKE_BUILD_TYPE}")
if(APPLE)
set_target_properties(LIB_LIEF PROPERTIES MACOSX_RPATH ON)
set_target_properties(LIB_LIEF PROPERTIES
MACOSX_RPATH ON
)
endif()
# API
@@ -617,10 +535,10 @@ endif()
# Find Package Config
# ======================
configure_file(
configure_package_config_file(
LIEFConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
@ONLY)
INSTALL_DESTINATION share/LIEF/cmake)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
@@ -629,8 +547,8 @@ write_basic_package_version_file(
# Post-build operations
# ======================
if(BUILD_SHARED_LIBS AND CMAKE_BUILD_TYPE MATCHES "Release")
if(UNIX AND NOT APPLE)
if (BUILD_SHARED_LIBS AND CMAKE_BUILD_TYPE MATCHES "Release")
if (UNIX AND NOT APPLE)
add_custom_command(
TARGET LIB_LIEF
COMMENT "Strip LIEF shared library"
@@ -639,7 +557,7 @@ if(BUILD_SHARED_LIBS AND CMAKE_BUILD_TYPE MATCHES "Release")
)
endif()
if(APPLE)
if (APPLE)
add_custom_command(
TARGET LIB_LIEF
COMMENT "Strip LIEF shared library"
@@ -667,65 +585,36 @@ endif()
# Installation
# ======================
if(UNIX)
include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR "lib")
else()
if(WIN32)
set(CMAKE_INSTALL_LIBDIR "lib")
set(CMAKE_INSTALL_DATADIR "share")
set(CMAKE_INSTALL_INCLUDEDIR "include")
set(CMAKE_INSTALL_BINDIR "bin")
set(CMAKE_INSTALL_DATAROOTDIR "share")
message(STATUS "Setting installation destination on Windows to: ${CMAKE_INSTALL_PREFIX}")
else()
message(FATAL_ERROR "System not UNIX nor WIN32 - not implemented yet")
endif()
endif()
install(
TARGETS LIB_LIEF lief_spdlog
EXPORT LIEFExport
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
TARGETS LIB_LIEF
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib COMPONENT libraries)
install(
DIRECTORY ${LIEF_PUBLIC_INCLUDE_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION include
COMPONENT headers
FILES_MATCHING
REGEX "(.*).(hpp|h|def|inc)$")
REGEX "(.*).(hpp|h|def)$")
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/FindLIEF.cmake
DESTINATION share/LIEF/cmake
COMPONENT CMakeScripts)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
DESTINATION share/LIEF/cmake
COMPONENT config)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT libraries)
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
DESTINATION lib/pkgconfig
COMPONENT libraries)
if(BUILD_SHARED_LIBS)
set(lib_type shared)
else()
set(lib_type static)
endif()
install(
EXPORT LIEFExport
NAMESPACE LIEF::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
FILE LIEFExport-${lib_type}.cmake
COMPONENT config)
export(
EXPORT LIEFExport
NAMESPACE LIEF::
FILE LIEFExport-${lib_type}.cmake)
export(TARGETS LIB_LIEF lief_spdlog FILE LIEFExport.cmake)
# Package
# ======================
+2 -2
View File
@@ -186,8 +186,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2017 - 2022 R. Thomas
Copyright 2017 - 2022 Quarkslab
Copyright 2017 - 2021 R. Thomas
Copyright 2017 - 2021 Quarkslab
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+3 -178
View File
@@ -1,179 +1,4 @@
#.rst:
# LIEFConfig
# --------
#
# Populate the native LIEF targets.
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``LIEF::LIEF``
#
# Hints
# ^^^^^
#
# A user may set ``LIEF_DIR`` to the directory where ``LIEFConfig.cmake`` file
# resides to tell CMake where to find this file.
#
# To choose between STATIC and SHARED version of LIEF library, one can use
# ``COMPONENTS STATIC`` of ``COMPONENTS SHARED``. If no components are
# specified, then a user may set ``LIEF_SHARED_LIBS`` to a true value to
# request shared libraries. By default, if no variables or components are set,
# the static library is preferred if present, else shared library will be used.
#
# .. code-block:: cmake
#
# find_package(LIEF 0.11.0 REQUIRED COMPONENTS STATIC)
@PACKAGE_INIT@
# CMake component support for static and shared libraries based on
# https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html
# Process known components
set(LIEF_known_comps STATIC SHARED)
set(LIEF_comp_STATIC NO)
set(LIEF_comp_SHARED NO)
foreach(_comp ${LIEF_FIND_COMPONENTS})
if(";${LIEF_known_comps};" MATCHES ";${_comp};")
set(LIEF_comp_${_comp} YES)
else()
set(LIEF_NOT_FOUND_MESSAGE
"LIEF does not recognize component `${_comp}`.")
set(LIEF_FOUND FALSE)
return()
endif()
endforeach()
# Validate component selection makes sense
if(LIEF_comp_STATIC AND LIEF_comp_SHARED)
set(LIEF_NOT_FOUND_MESSAGE
"LIEF `STATIC` and `SHARED` components are mutually exclusive.")
set(LIEF_FOUND FALSE)
return()
endif()
# These files are generated by CMake and hold the LIEF library target(s).
set(LIEF_static_export "${CMAKE_CURRENT_LIST_DIR}/LIEFExport-static.cmake")
set(LIEF_shared_export "${CMAKE_CURRENT_LIST_DIR}/LIEFExport-shared.cmake")
# Helper macro to load the requested targets, where `lib_type` is `static` or
# `shared`
macro(LIEF_load_targets lib_type)
if(NOT EXISTS "${LIEF_${lib_type}_export}")
set(LIEF_NOT_FOUND_MESSAGE
"LIEF `${lib_type}` libraries were requested but not found.")
set(LIEF_FOUND FALSE)
return()
endif ()
if("${lib_type}" STREQUAL "static")
# Need to find all dependencies even if they're private when LIEF is
# compiled statically
include(CMakeFindDependencyMacro)
if(@LIEF_EXTERNAL_MBEDTLS@)
find_dependency(MbedTLS)
endif()
if(@LIEF_EXTERNAL_UTF8CPP@)
find_dependency(utf8cpp)
endif()
if(@LIEF_EXTERNAL_SPDLOG@)
find_dependency(spdlog)
endif()
if(@LIEF_ENABLE_JSON@ AND @LIEF_NLOHMANN_JSON_EXTERNAL@)
find_dependency(nlohmann_json)
endif()
if(NOT @LIEF_DISABLE_FROZEN@ AND @LIEF_OPT_FROZEN_EXTERNAL@)
find_dependency(frozen)
endif()
endif()
# Include the respective targets file
include("${LIEF_${lib_type}_export}")
endmacro()
# Run the logic to choose static or shared libraries
# 1. Check components
if(LIEF_comp_STATIC)
LIEF_load_targets("static")
elseif(LIEF_comp_SHARED)
LIEF_load_targets("shared")
# 2. Check LIEF-only library selection
elseif(DEFINED LIEF_SHARED_LIBS AND LIEF_SHARED_LIBS)
LIEF_load_targets("shared")
elseif(DEFINED LIEF_SHARED_LIBS AND NOT LIEF_SHARED_LIBS)
LIEF_load_targets("static")
# 3. Check CMake build type and choose what's available
elseif(BUILD_SHARED_LIBS)
if(EXISTS "${LIEF_shared_export}")
LIEF_load_targets("shared")
else()
LIEF_load_targets("static")
endif()
else()
if(EXISTS "${LIEF_static_export}")
LIEF_load_targets("static")
else()
LIEF_load_targets("shared")
endif()
endif()
# Attach location of public interface libraries that don't have
# their own CMake config that would otherwise be found using `find_dependency`
# Header-only library can be found relatively easily
if(@LIEF_EXTERNAL_LEAF@)
find_path(BOOST_LEAF_INCLUDE_DIR boost/leaf.hpp)
if(NOT BOOST_LEAF_INCLUDE_DIR)
set(LIEF_NOT_FOUND_MESSAGE "Could not find include directory with 'boost/leaf.hpp'. Consider setting `BOOST_LEAF_INCLUDE_DIR` during CMake configuration")
set(LIEF_FOUND FALSE)
return()
endif()
set_property(TARGET LIEF::LIEF APPEND PROPERTY
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${BOOST_LEAF_INCLUDE_DIR}"
)
endif()
# Header-only library can be found relatively easily
if(@LIEF_EXTERNAL_SPAN@)
find_path(TCB_SPAN_INCLUDE_DIR tcb/span.hpp)
if(NOT TCB_SPAN_INCLUDE_DIR)
set(LIEF_NOT_FOUND_MESSAGE "Could not find include directory with 'tcb/span.hpp'. Consider setting `TCB_SPAN_INCLUDE_DIR` during CMake configuration")
set(LIEF_FOUND FALSE)
return()
endif()
set_property(TARGET LIEF::LIEF APPEND PROPERTY
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${TCB_SPAN_INCLUDE_DIR}"
)
endif()
# Set this for backwards compatibility. This isn't quite the path to the
# actual library file, but using the target is strictly better because it
# includes all other information needed to correctly link and use LIEF
set(LIEF_LIBRARIES LIEF::LIEF)
# Set this for backwards compatibility
get_target_property(LIEF_INCLUDE_DIRS LIEF::LIEF INTERFACE_INCLUDE_DIRECTORIES)
# Set the following for backwards compatibility
if(LIEF_INCLUDE_DIR AND EXISTS "${LIEF_INCLUDE_DIR}/LIEF/version.h")
file(STRINGS "${LIEF_INCLUDE_DIR}/LIEF/version.h" LIEF_H REGEX "^#define LIEF_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*LIEF_VERSION \"([0-9]+).*$" "\\1" LIEF_VERSION_MAJOR "${LIEF_H}")
string(REGEX REPLACE "^.*LIEF_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIEF_VERSION_MINOR "${LIEF_H}")
string(REGEX REPLACE "^.*LIEF_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIEF_VERSION_PATCH "${LIEF_H}")
set(LIEF_VERSION_STRING "${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH}")
set(LIEF_MAJOR_VERSION "${LIEF_VERSION_MAJOR}")
set(LIEF_MINOR_VERSION "${LIEF_VERSION_MINOR}")
set(LIEF_PATCH_VERSION "${LIEF_VERSION_PATCH}")
endif()
set(LIEF_DIR "${PACKAGE_PREFIX_DIR}")
include("${CMAKE_CURRENT_LIST_DIR}/FindLIEF.cmake")
+32 -42
View File
@@ -7,8 +7,8 @@
<img src="https://img.shields.io/gitter/room/gitterHQ/gitter.svg?style=flat-square">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3A%22Linux+x86-64%22">
<img alt="Linux x86-64 CI status" src="https://img.shields.io/github/workflow/status/lief-project/LIEF/Linux%20x86-64/master?label=Linux%20x86-64&logo=github">
<a href="https://travis-ci.com/lief-project/LIEF">
<img alt="Linux CI status" src="https://img.shields.io/travis/com/lief-project/LIEF/master?label=Linux%20x86-64&logo=travis">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3A%22Linux+AArch64%22">
@@ -38,20 +38,12 @@
<a href="https://twitter.com/LIEF_project">
<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/lief_project?color=1da1f2&label=Follow&logo=twitter&logoColor=white&style=flat-square">
</a>
</p>
<br />
<p align="center">
<a href="https://lief-project.github.io/blog/"><b>Blog</b></a> •
<a href="https://lief-project.github.io/doc/latest/index.html"><b>Documentation</b></a> •
<a href="#about-A"><b>About</b></a>
</p>
<br />
# About
The purpose of this project is to provide a cross platform library which can parse,
modify and abstract ELF, PE and MachO formats.
The purpose of this project is to provide a cross platform library which can parse, modify and abstract ELF, PE and MachO formats.
Main features:
@@ -66,22 +58,22 @@ Main features:
- [Download / Install](#downloads--install)
- [Getting started](#getting-started)
- [Documentation](#documentation)
- [Sphinx](https://lief-project.github.io/doc/stable/index.html)
- [Doxygen](https://lief-project.github.io/doc/latest/doxygen/index.html)
- [Sphinx](https://lief.quarkslab.com/doc/stable/index.html)
- [Doxygen](https://lief.quarkslab.com/doc/latest/doxygen/index.html)
- Tutorials:
- [Parse and manipulate formats](https://lief-project.github.io/doc/latest/tutorials/01_play_with_formats.html)
- [Create a PE from scratch](https://lief-project.github.io/doc/latest/tutorials/02_pe_from_scratch.html)
- [Play with ELF symbols](https://lief-project.github.io/doc/latest/tutorials/03_elf_change_symbols.html)
- [ELF Hooking](https://lief-project.github.io/doc/latest/tutorials/04_elf_hooking.html)
- [Infecting the plt/got](https://lief-project.github.io/doc/latest/tutorials/05_elf_infect_plt_got.html)
- [PE Hooking](https://lief-project.github.io/doc/latest/tutorials/06_pe_hooking.html)
- [PE Resources](https://lief-project.github.io/doc/latest/tutorials/07_pe_resource.html)
- [Transforming an ELF executable into a library](https://lief-project.github.io/doc/latest/tutorials/08_elf_bin2lib.html)
- [How to use frida on a non-rooted device](https://lief-project.github.io/doc/latest/tutorials/09_frida_lief.html)
- [Android formats](https://lief-project.github.io/doc/latest/tutorials/10_android_formats.html)
- [Mach-O modification](https://lief-project.github.io/doc/latest/tutorials/11_macho_modification.html)
- [ELF Coredump](https://lief-project.github.io/doc/latest/tutorials/12_elf_coredump.html)
- [PE Authenticode](https://lief-project.github.io/doc/latest/tutorials/13_pe_authenticode.html)
- [Parse and manipulate formats](https://lief.quarkslab.com/doc/latest/tutorials/01_play_with_formats.html)
- [Create a PE from scratch](https://lief.quarkslab.com/doc/latest/tutorials/02_pe_from_scratch.html)
- [Play with ELF symbols](https://lief.quarkslab.com/doc/latest/tutorials/03_elf_change_symbols.html)
- [ELF Hooking](https://lief.quarkslab.com/doc/latest/tutorials/04_elf_hooking.html)
- [Infecting the plt/got](https://lief.quarkslab.com/doc/latest/tutorials/05_elf_infect_plt_got.html)
- [PE Hooking](https://lief.quarkslab.com/doc/latest/tutorials/06_pe_hooking.html)
- [PE Resources](https://lief.quarkslab.com/doc/latest/tutorials/07_pe_resource.html)
- [Transforming an ELF executable into a library](https://lief.quarkslab.com/doc/latest/tutorials/08_elf_bin2lib.html)
- [How to use frida on a non-rooted device](https://lief.quarkslab.com/doc/latest/tutorials/09_frida_lief.html)
- [Android formats](https://lief.quarkslab.com/doc/latest/tutorials/10_android_formats.html)
- [Mach-O modification](https://lief.quarkslab.com/doc/latest/tutorials/11_macho_modification.html)
- [ELF Coredump](https://lief.quarkslab.com/doc/latest/tutorials/12_elf_coredump.html)
- [PE Authenticode](https://lief.quarkslab.com/doc/latest/tutorials/13_pe_authenticode.html)
- [Contact](#contact)
- [About](#about)
- [Authors](#authors)
@@ -102,25 +94,23 @@ To install the latest **version** (release):
pip install lief
```
To install nightly build:
To install nightlty build:
```console
pip install [--user] --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==0.13.0.dev0
pip install [--user] --index-url https://lief.quarkslab.com/packages lief==0.12.0.dev0
```
### Packages
- **Nightly**:
* SDK: https://lief.s3-website.fr-par.scw.cloud/latest/sdk
* Python Wheels: https://lief.s3-website.fr-par.scw.cloud/latest/lief
- **v0.12.0**: https://github.com/lief-project/LIEF/releases/tag/0.12.0
* **Nightly**: https://github.com/lief-project/packages/tree/gh-pages
* **v0.11.4**: https://github.com/lief-project/LIEF/releases/tag/0.11.4
Here are guides to install or integrate LIEF:
* [Python](https://lief-project.github.io/doc/latest/installation.html#python)
* [VisualStudio](https://lief-project.github.io/doc/latest/installation.html#visual-studio-integration)
* [XCode](https://lief-project.github.io/doc/latest/installation.html#xcode-integration)
* [CMake](https://lief-project.github.io/doc/latest/installation.html#cmake-integration)
* [Python](https://lief.quarkslab.com/doc/latest/installation.html#python)
* [VisualStudio](https://lief.quarkslab.com/doc/latest/installation.html#visual-studio-integration)
* [XCode](https://lief.quarkslab.com/doc/latest/installation.html#xcode-integration)
* [CMake](https://lief.quarkslab.com/doc/latest/installation.html#cmake-integration)
## Getting started
@@ -198,14 +188,14 @@ int main(int argc, char** argv) {
## Documentation
* [Main documentation](https://lief-project.github.io/doc/latest/index.html)
* [Tutorial](https://lief-project.github.io/doc/latest/tutorials/index.html)
* [API](https://lief-project.github.io/doc/latest/api/index.html)
* [Doxygen](https://lief-project.github.io/doc/latest/doxygen/index.html)
* [Main documentation](https://lief.quarkslab.com/doc/latest/index.html)
* [Tutorial](https://lief.quarkslab.com/doc/latest/tutorials/index.html)
* [API](https://lief.quarkslab.com/doc/latest/api/index.html)
* [Doxygen](https://lief.quarkslab.com/doc/latest/doxygen/index.html)
## Contact
* **Mail**: contact at lief re
* **Mail**: lief at quarkslab com
* **Gitter**: [lief-project](https://gitter.im/lief-project)
## About
@@ -216,7 +206,7 @@ Romain Thomas ([@rh0main](https://twitter.com/rh0main)) - [Quarkslab](https://ww
### License
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.12.0/LICENSE).
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.11.2/LICENSE).
### Bibtex
+5 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->type = static_cast<enum LIEF_ELF_ELF_CLASS>(binary->type());
c_binary->interpreter = nullptr;
if (binary->has_interpreter()) {
const std::string& interp = binary->interpreter();
std::string interp = binary->interpreter();
c_binary->interpreter = static_cast<char*>(malloc((interp.size() + 1) * sizeof(char)));
std::memcpy(
reinterpret_cast<void*>(const_cast<char*>(c_binary->interpreter)),
@@ -65,7 +65,7 @@ void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
Elf_Binary_t* elf_parse(const char *file) {
Binary* binary = Parser::parse(file).release();
auto* c_binary = static_cast<Elf_Binary_t*>(malloc(sizeof(Elf_Binary_t)));
Elf_Binary_t* c_binary = static_cast<Elf_Binary_t*>(malloc(sizeof(Elf_Binary_t)));
memset(c_binary, 0, sizeof(Elf_Binary_t));
init_c_binary(c_binary, binary);
return c_binary;
@@ -92,7 +92,7 @@ int elf_binary_save_header(Elf_Binary_t* binary) {
hdr.entrypoint(binary->header.entrypoint);
//TODO: identity
return 1;
return true;
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -1
View File
@@ -32,7 +32,8 @@ set(LIEF_API_C_ELF_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Section.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Segment.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Symbol.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/enums.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/ELF/structures.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/ELF/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/utils.h"
)
+20 -20
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ namespace ELF {
void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_dynamic_entries dyn_entries = binary->dynamic_entries();
it_dynamic_entries dyn_entries = binary->dynamic_entries();
c_binary->dynamic_entries = static_cast<Elf_DynamicEntry_t**>(
malloc((dyn_entries.size() + 1) * sizeof(Elf_DynamicEntry_t**)));
@@ -37,12 +37,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_NEEDED:
{
auto* e = static_cast<Elf_DynamicEntry_Library_t*>(
Elf_DynamicEntry_Library_t* e = static_cast<Elf_DynamicEntry_Library_t*>(
malloc(sizeof(Elf_DynamicEntry_Library_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
e->name = reinterpret_cast<DynamicEntryLibrary*>(&entry)->name().c_str();
e->name = dynamic_cast<DynamicEntryLibrary*>(&entry)->name().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
@@ -50,12 +50,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_SONAME:
{
auto* e = static_cast<Elf_DynamicEntry_SharedObject_t*>(
Elf_DynamicEntry_SharedObject_t* e = static_cast<Elf_DynamicEntry_SharedObject_t*>(
malloc(sizeof(Elf_DynamicEntry_SharedObject_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
e->name = reinterpret_cast<DynamicSharedObject*>(&entry)->name().c_str();
e->name = dynamic_cast<DynamicSharedObject*>(&entry)->name().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
break;
@@ -63,12 +63,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_RPATH:
{
auto* e = static_cast<Elf_DynamicEntry_Rpath_t*>(
Elf_DynamicEntry_Rpath_t* e = static_cast<Elf_DynamicEntry_Rpath_t*>(
malloc(sizeof(Elf_DynamicEntry_Rpath_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
e->rpath = reinterpret_cast<DynamicEntryRpath*>(&entry)->name().c_str();
e->rpath = dynamic_cast<DynamicEntryRpath*>(&entry)->name().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
@@ -77,12 +77,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_RUNPATH:
{
auto* e = static_cast<Elf_DynamicEntry_RunPath_t*>(
Elf_DynamicEntry_RunPath_t* e = static_cast<Elf_DynamicEntry_RunPath_t*>(
malloc(sizeof(Elf_DynamicEntry_RunPath_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
e->runpath = reinterpret_cast<DynamicEntryRunPath*>(&entry)->name().c_str();
e->runpath = dynamic_cast<DynamicEntryRunPath*>(&entry)->name().c_str();
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
@@ -93,12 +93,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_FINI_ARRAY:
case DYNAMIC_TAGS::DT_PREINIT_ARRAY:
{
auto* e = static_cast<Elf_DynamicEntry_Array_t*>(
Elf_DynamicEntry_Array_t* e = static_cast<Elf_DynamicEntry_Array_t*>(
malloc(sizeof(Elf_DynamicEntry_Array_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
const std::vector<uint64_t>& array = reinterpret_cast<DynamicEntryArray*>(&entry)->array();
const std::vector<uint64_t>& array = dynamic_cast<DynamicEntryArray*>(&entry)->array();
e->array = static_cast<uint64_t*>(malloc((array.size() + 1) * sizeof(uint64_t)));
for (size_t i = 0; i < array.size(); ++i) {
e->array[i] = array[i];
@@ -111,16 +111,16 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_FLAGS:
{
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
Elf_DynamicEntry_Flags_t* e = static_cast<Elf_DynamicEntry_Flags_t*>(
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast<DynamicEntryFlags*>(&entry)->flags();
const DynamicEntryFlags::flags_list_t& flags = dynamic_cast<DynamicEntryFlags*>(&entry)->flags();
e->flags = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS*>(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS)));
e->flags_1 = nullptr;
auto it = std::begin(flags);
auto&& it = std::begin(flags);
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
e->flags[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS>(*it);
@@ -134,16 +134,16 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
case DYNAMIC_TAGS::DT_FLAGS_1:
{
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
Elf_DynamicEntry_Flags_t* e = static_cast<Elf_DynamicEntry_Flags_t*>(
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
e->value = entry.value();
const DynamicEntryFlags::flags_list_t& flags = reinterpret_cast<DynamicEntryFlags*>(&entry)->flags();
const DynamicEntryFlags::flags_list_t& flags = dynamic_cast<DynamicEntryFlags*>(&entry)->flags();
e->flags_1 = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1*>(malloc((flags.size() + 1) * sizeof(enum LIEF_ELF_DYNAMIC_FLAGS_1)));
e->flags = nullptr;
auto it = std::begin(flags);
auto&& it = std::begin(flags);
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
e->flags_1[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1>(*it);
@@ -178,7 +178,7 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
Elf_DynamicEntry_t **dynamic_entries = c_binary->dynamic_entries;
for (size_t idx = 0; dynamic_entries[idx] != nullptr; ++idx) {
for (size_t idx = 0; dynamic_entries[idx] != NULL; ++idx) {
switch(static_cast<DYNAMIC_TAGS>(dynamic_entries[idx]->tag)) {
case DYNAMIC_TAGS::DT_NEEDED:
{
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+5 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,9 @@
#include "LIEF/ELF/EnumToString.h"
#include "LIEF/ELF/EnumToString.hpp"
#include "LIEF/ELF/enums.h"
#include "LIEF/ELF/enums.hpp"
#include "LIEF/ELF/Structures.hpp"
#include "LIEF/ELF/structures.h"
extern "C"
{
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+10 -8
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ namespace LIEF {
namespace ELF {
void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_sections sections = binary->sections();
it_sections sections = binary->sections();
c_binary->sections = static_cast<Elf_Section_t**>(
malloc((sections.size() + 1) * sizeof(Elf_Section_t**)));
@@ -27,12 +27,14 @@ void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {
for (size_t i = 0; i < sections.size(); ++i) {
Section& b_section = sections[i];
c_binary->sections[i] = static_cast<Elf_Section_t*>(malloc(sizeof(Elf_Section_t)));
span<const uint8_t> section_content = b_section.content();
auto* content = static_cast<uint8_t*>(malloc(section_content.size() * sizeof(uint8_t)));
std::copy(std::begin(section_content), std::end(section_content),
content);
const std::vector<uint8_t>& section_content = b_section.content();
uint8_t* content = static_cast<uint8_t*>(malloc(section_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(section_content),
std::end(section_content),
content);
c_binary->sections[i]->name = b_section.fullname().c_str();
c_binary->sections[i]->name = b_section.name().c_str();
c_binary->sections[i]->flags = b_section.flags();
c_binary->sections[i]->type = static_cast<enum LIEF_ELF_ELF_SECTION_TYPES>(b_section.type());
c_binary->sections[i]->virtual_address = b_section.virtual_address();
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+5 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ namespace ELF {
void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_segments segments = binary->segments();
it_segments segments = binary->segments();
c_binary->segments = static_cast<Elf_Segment_t**>(
malloc((segments.size() + 1) * sizeof(Elf_Segment_t**)));
for (size_t i = 0; i < segments.size(); ++i) {
Segment& segment = segments[i];
span<const uint8_t> segment_content = segment.content();
auto* content = static_cast<uint8_t*>(malloc(segment_content.size() * sizeof(uint8_t)));
const std::vector<uint8_t>& segment_content = segment.content();
uint8_t* content = static_cast<uint8_t*>(malloc(segment_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(segment_content),
std::end(segment_content),
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ namespace LIEF {
namespace ELF {
void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_dynamic_symbols dyn_symb = binary->dynamic_symbols();
it_symbols dyn_symb = binary->dynamic_symbols();
c_binary->dynamic_symbols = static_cast<Elf_Symbol_t**>(
malloc((dyn_symb.size() + 1) * sizeof(Elf_Symbol_t**)));
@@ -46,7 +46,7 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary) {
Binary::it_static_symbols static_symb = binary->static_symbols();
it_symbols static_symb = binary->static_symbols();
c_binary->static_symbols = static_cast<Elf_Symbol_t**>(
malloc((static_symb.size() + 1) * sizeof(Elf_Symbol_t**)));
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -1
View File
@@ -26,7 +26,8 @@ set(LIEF_API_C_MACHO_INCLUDE_FILES_CPP
set(LIEF_API_C_MACHO_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/enums.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/MachO/structures.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/MachO/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/EnumToString.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Header.h"
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
namespace LIEF {
namespace MachO {
void init_c_commands(Macho_Binary_t* c_binary, Binary* binary) {
Binary::it_commands commands = binary->commands();
it_commands commands = binary->commands();
c_binary->commands = static_cast<Macho_Command_t**>(
malloc((commands.size() + 1) * sizeof(Macho_Command_t**)));
@@ -28,7 +28,7 @@ void init_c_commands(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->commands[i] = static_cast<Macho_Command_t*>(malloc(sizeof(Macho_Command_t)));
const std::vector<uint8_t>& cmd_content = cmd.data();
auto* content = static_cast<uint8_t*>(malloc(cmd_content.size() * sizeof(uint8_t)));
uint8_t* content = static_cast<uint8_t*>(malloc(cmd_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(cmd_content),
std::end(cmd_content),
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+10 -12
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,20 +24,18 @@
using namespace LIEF::MachO;
Macho_Binary_t** macho_parse(const char *file) {
FatBinary* fat = Parser::parse(file).release();
FatBinary* macho_binaries = Parser::parse(file).release();
auto** c_macho_binaries = static_cast<Macho_Binary_t**>(
malloc((fat->size() + 1) * sizeof(Macho_Binary_t**)));
Macho_Binary_t** c_macho_binaries = static_cast<Macho_Binary_t**>(
malloc((macho_binaries->size() + 1) * sizeof(Macho_Binary_t**)));
for (size_t i = 0; i < fat->size(); ++i) {
Binary* binary = fat->at(i);
if (binary != nullptr) {
c_macho_binaries[i] = static_cast<Macho_Binary_t*>(malloc(sizeof(Macho_Binary_t)));
init_c_binary(c_macho_binaries[i], binary);
}
for (size_t i = 0; i < macho_binaries->size(); ++i) {
Binary& binary = (*macho_binaries)[i];
c_macho_binaries[i] = static_cast<Macho_Binary_t*>(malloc(sizeof(Macho_Binary_t)));
init_c_binary(c_macho_binaries[i], &binary);
}
c_macho_binaries[fat->size()] = nullptr;
c_macho_binaries[macho_binaries->size()] = nullptr;
return c_macho_binaries;
}
+12 -10
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,21 +18,23 @@
namespace LIEF {
namespace MachO {
void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
Binary::it_sections sections = binary->sections();
it_sections sections = binary->sections();
c_binary->sections = static_cast<Macho_Section_t**>(
malloc((sections.size() + 1) * sizeof(Macho_Section_t**)));
for (size_t i = 0; i < sections.size(); ++i) {
const Section& section = sections[i];
Section& section = sections[i];
c_binary->sections[i] = static_cast<Macho_Section_t*>(malloc(sizeof(Macho_Section_t)));
span<const uint8_t> section_content = section.content();
auto* content = static_cast<uint8_t*>(malloc(section_content.size() * sizeof(uint8_t)));
std::copy(std::begin(section_content), std::end(section_content),
content);
const std::vector<uint8_t>& section_content = section.content();
uint8_t* content = static_cast<uint8_t*>(malloc(section_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(section_content),
std::end(section_content),
content);
c_binary->sections[i]->name = section.fullname().c_str();
c_binary->sections[i]->name = section.name().c_str();
c_binary->sections[i]->alignment = section.alignment();
c_binary->sections[i]->relocation_offset = section.relocation_offset();
c_binary->sections[i]->numberof_relocations = section.numberof_relocations();
@@ -43,7 +45,7 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->sections[i]->reserved3 = section.reserved3();
c_binary->sections[i]->virtual_address = section.virtual_address();
c_binary->sections[i]->offset = section.offset();
c_binary->sections[i]->size = section_content.size();
c_binary->sections[i]->size = section.size();
c_binary->sections[i]->content = content;
c_binary->sections[i]->entropy = section.entropy();
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+5 -5
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
namespace LIEF {
namespace MachO {
void init_c_segments(Macho_Binary_t* c_binary, Binary* binary) {
Binary::it_segments segments = binary->segments();
it_segments segments = binary->segments();
c_binary->segments = static_cast<Macho_Segment_t**>(
malloc((segments.size() + 1) * sizeof(Macho_Segment_t**)));
@@ -27,8 +27,8 @@ void init_c_segments(Macho_Binary_t* c_binary, Binary* binary) {
SegmentCommand& segment = segments[i];
c_binary->segments[i] = static_cast<Macho_Segment_t*>(malloc(sizeof(Macho_Segment_t)));
span<const uint8_t> segment_content = segment.content();
auto* content = static_cast<uint8_t*>(malloc(segment_content.size() * sizeof(uint8_t)));
const std::vector<uint8_t>& segment_content = segment.content();
uint8_t* content = static_cast<uint8_t*>(malloc(segment_content.size() * sizeof(uint8_t)));
std::copy(
std::begin(segment_content),
std::end(segment_content),
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,13 +18,13 @@
namespace LIEF {
namespace MachO {
void init_c_symbols(Macho_Binary_t* c_binary, Binary* binary) {
Binary::it_symbols symbols = binary->symbols();
it_symbols symbols = binary->symbols();
c_binary->symbols = static_cast<Macho_Symbol_t**>(
malloc((symbols.size() + 1) * sizeof(Macho_Symbol_t**)));
for (size_t i = 0; i < symbols.size(); ++i) {
const Symbol& symbol = symbols[i];
Symbol& symbol = symbols[i];
c_binary->symbols[i] = static_cast<Macho_Symbol_t*>(malloc(sizeof(Macho_Symbol_t)));
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ void init_c_binary(Pe_Binary_t* c_binary, Binary* binary) {
Pe_Binary_t* pe_parse(const char *file) {
Binary* binary = Parser::parse(file).release();
auto* c_binary = static_cast<Pe_Binary_t*>(malloc(sizeof(Pe_Binary_t)));
Pe_Binary_t* c_binary = static_cast<Pe_Binary_t*>(malloc(sizeof(Pe_Binary_t)));
std::memset(c_binary, 0, sizeof(Pe_Binary_t));
init_c_binary(c_binary, binary);
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -1
View File
@@ -27,7 +27,8 @@ set(LIEF_API_C_PE_INCLUDE_FILES_CPP
)
set(LIEF_API_C_PE_INCLUDE_FILES_C
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/enums.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/PE/structures.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/PE/enums.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Binary.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DataDirectory.h"
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/DosHeader.h"
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ namespace LIEF {
namespace PE {
void init_c_data_directories(Pe_Binary_t* c_binary, Binary* binary) {
Binary::it_data_directories data_directories = binary->data_directories();
it_data_directories data_directories = binary->data_directories();
c_binary->data_directories = static_cast<Pe_DataDirectory_t**>(
malloc((data_directories.size() + 1) * sizeof(Pe_DataDirectory_t**)));
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+4 -4
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@ namespace PE {
void init_c_imports(Pe_Binary_t* c_binary, Binary* binary) {
if (!binary->has_imports()) {
if (not binary->has_imports()) {
c_binary->imports = nullptr;
}
Binary::it_imports imports = binary->imports();
it_imports imports = binary->imports();
c_binary->imports = static_cast<Pe_Import_t**>(
malloc((imports.size() + 1) * sizeof(Pe_Import_t**)));
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+3 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ namespace PE {
void init_c_import_entries(Pe_Import_t* c_import, Import& imp) {
Import::it_entries entries = imp.entries();
it_import_entries entries = imp.entries();
c_import->entries = static_cast<Pe_ImportEntry_t**>(
malloc((entries.size() + 1) * sizeof(Pe_ImportEntry_t**)));
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+10 -8
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ namespace LIEF {
namespace PE {
void init_c_sections(Pe_Binary_t* c_binary, Binary* binary) {
Binary::it_sections sections = binary->sections();
it_sections sections = binary->sections();
c_binary->sections = static_cast<Pe_Section_t**>(
malloc((sections.size() + 1) * sizeof(Pe_Section_t**)));
@@ -27,16 +27,18 @@ void init_c_sections(Pe_Binary_t* c_binary, Binary* binary) {
for (size_t i = 0; i < sections.size(); ++i) {
Section& b_section = sections[i];
c_binary->sections[i] = static_cast<Pe_Section_t*>(malloc(sizeof(Pe_Section_t)));
span<const uint8_t> section_content = b_section.content();
std::vector<uint8_t> section_content = b_section.content();
uint8_t* content = nullptr;
if (!section_content.empty()) {
if (section_content.size() > 0) {
content = static_cast<uint8_t*>(malloc(section_content.size() * sizeof(uint8_t)));
std::copy(std::begin(section_content), std::end(section_content),
content);
std::move(
std::begin(section_content),
std::end(section_content),
content);
}
c_binary->sections[i]->name = b_section.fullname().c_str();
c_binary->sections[i]->name = b_section.name().c_str();
c_binary->sections[i]->virtual_address = b_section.virtual_address();
c_binary->sections[i]->size = b_section.size();
c_binary->sections[i]->offset = b_section.offset();
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -10,7 +10,7 @@ extern "C" {
#define _LIEF_EN_2(N, TYPE) LIEF_ELF_##N // enum LIEF_N {
#define _LIEF_EI(X) LIEF_ELF_##X // LIEF_X
#include "LIEF/ELF/enums.inc"
@LIEF_ELF_ENUMS@
#undef _LIEF_EN
#undef _LIEF_EN_2
+14
View File
@@ -0,0 +1,14 @@
#ifndef LIEF_ELF_C_STRUCTURES_H_
#define LIEF_ELF_C_STRUCTURES_H_
#ifdef __cplusplus
extern "C" {
#endif
@LIEF_ELF_STRUCTURES@
#ifdef __cplusplus
}
#endif
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ extern "C" {
#define _LIEF_EN_2(N, TYPE) LIEF_MACHO_##N // enum LIEF_N {
#define _LIEF_EI(X) LIEF_MACHO_##X // LIEF_X
#include "LIEF/MachO/enums.inc"
@LIEF_MACHO_ENUMS@
#undef _LIEF_EN
#undef _LIEF_EN_2
+14
View File
@@ -0,0 +1,14 @@
#ifndef LIEF_MACHO_C_STRUCTURES_H_
#define LIEF_MACHO_C_STRUCTURES_H_
#ifdef __cplusplus
extern "C" {
#endif
@LIEF_MACHO_STRUCTURES@
#ifdef __cplusplus
}
#endif
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2022 R. Thomas
* Copyright 2017 - 2022 Quarkslab
/* Copyright 2017 - 2021 R. Thomas
* Copyright 2017 - 2021 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

Some files were not shown because too many files have changed in this diff Show More