Compare commits

..
Author SHA1 Message Date
Romain Thomas 551ede538a Bump version 2021-05-22 10:18:10 +02:00
Romain Thomas 8bbcebe3af Update changelog 2021-05-22 10:15:13 +02:00
Adrien Guinet 7e28c276e2 Python bindings: export C++ LIEF symbols
This allows external libraries (like QBDL) to use the same C++ typeinfo
objects for LIEF, and hence having compatible "pybind11" LIEF objects
between the two libraries.
2021-05-22 10:13:48 +02:00
Romain Thomas e94d7a587a Add build script for Apple M1 2021-05-22 10:13:21 +02:00
Romain Thomas f953fb8005 Use the same output name as the other platforms 2021-05-22 10:13:12 +02:00
Romain Thomas b2a64c6587 Resolve #533 2021-05-22 10:12:11 +02:00
Romain Thomas 3f6e162e61 Update changelog 2021-05-22 10:10:54 +02:00
Romain Thomas f2d956d4e8 Fix missing info 2021-05-22 10:08:04 +02:00
Romain Thomas 92ae936e1d Fix #576 2021-05-22 10:07:31 +02:00
Yuki Mogi 0eb3c5d597 fix computing sizeof_headers
Adding 1 to the size of this->data_directories_ and this->sections_ seems to be unnecessary. In this commit, the two '+1' are removed.
2021-05-22 10:05:58 +02:00
Pemma Reiter 631bc53a64 resolution for LIEF issue #418
addresses boundary scenario for relocations whose
relative offsets abut segment_size
2021-05-22 10:02:31 +02:00
Adrien Guinet a8bedcdcb6 Remove usage of "not" in public headers
This unfortunately makes compilation of project using LIEF with
cl.exe-like compilers really painful. Including "iso646.h" seems like a
hack, and does not seem to work with recent VS2019 versions.
2021-05-22 10:00:40 +02:00
Romain Thomas dd1371105e Bump version 2021-03-09 19:02:52 +01:00
Romain Thomas d345ac73b1 Fix missing bound check 2021-03-09 18:52:23 +01:00
Romain Thomas e3ea0d510b Add changelog and bump version 2021-03-02 04:44:06 +01:00
Romain Thomas 91bfa9e952 Add check on the signature size 2021-03-02 04:40:02 +01:00
Romain Thomas 097b35511e Fix error 2021-02-24 08:02:51 +01:00
Romain Thomas 1dd7317a0c Fix error 2021-02-24 07:36:09 +01:00
Romain Thomas 0e12916531 Bump version 2021-02-24 07:04:38 +01:00
Romain Thomas 9fb11539da Resolve #551 2021-02-24 07:01:49 +01:00
Romain Thomas 980ed6b3fb Update changelog 2021-02-22 13:38:24 +01:00
Romain Thomas a6d9ea90a2 Add more information than just BAD_SIGNATURE 2021-02-21 18:03:51 +01:00
Romain Thomas 8d20b9ba65 Resolve #532 2021-02-21 18:02:39 +01:00
Romain Thomas eb24a317fa Fix appveyor tag 2021-02-21 15:38:35 +01:00
Romain Thomas c0fa4a6455 Fix missing env variable 2021-02-21 13:03:37 +01:00
Romain Thomas 3970c4d4e2 update auditwheel command 2021-02-21 13:03:31 +01:00
Romain Thomas 96c7e90231 Fix typo 2021-02-21 13:03:24 +01:00
Romain Thomas badfcf69a7 Update Linux CI 2021-02-21 13:03:10 +01:00
Romain Thomas d45e1946e3 Fix typo 2021-02-21 13:01:41 +01:00
Romain Thomas 62d4fb61ea Fix error on Appveyor 2021-02-21 13:00:40 +01:00
Romain Thomas 0c88cc740f Fix condition 2021-02-21 12:57:45 +01:00
Romain Thomas b2b7783ec0 Fix related to #540 2021-02-21 12:57:14 +01:00
Romain Thomas 9790ddfa82 The last data directory might not be null
See: bc203f2b6a928f1457e9ca99456747bcb7adbbfff789d1c47e9479aac11598af
2021-02-21 12:56:01 +01:00
Romain Thomas 986a30e014 Do not take account sections with empty content 2021-02-21 12:55:54 +01:00
Romain Thomas 03a18cb202 Do not trunc section's name on a null char
If the section's name contains bytes after the null char, they should
be considered while computing the authentihash.
2021-02-21 12:55:38 +01:00
Romain Thomas c37ee0742a Handle content between two sections that is not wrapped by a section 2021-02-21 12:55:24 +01:00
Romain Thomas 2ab604d36f Resolve #548 2021-02-21 12:55:18 +01:00
1573 changed files with 82109 additions and 110110 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
+62
View File
@@ -0,0 +1,62 @@
version: 2.1
jobs:
build:
macos:
xcode: 12.3.0
steps:
- checkout:
path: ~/LIEF
- restore_cache:
keys:
- ccache-{{ arch }}-{{ .Branch }}
- ccache-{{ arch }}-master
- ccache-{{ arch }}
- pyenv
- run:
name: Install pyenv
command: |
brew install pyenv
pyenv root
pyenv install --list
- run:
name: Install ccache
command: brew install ccache
- run:
name: Install ninja
command: brew install ninja
- run:
name: CCache initialization
command: |
ccache --show-stats
ccache --zero-stats
ccache --max-size=10.0G
ccache --set-config=compiler_check=content
- run:
name: LIEF build setup
command: |
export PYTHON_CONFIGURE_OPTS="--enable-shared --enable-unicode=ucs2"
pyenv install --skip-existing 3.9.0
export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9
$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
- run:
name: LIEF deploy
command: |
export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9
$PYTHON_BINARY -m pip install --upgrade requests mako
$PYTHON_BINARY .github/deploy.py
- run:
name: ccache stats
when: always
command: |
ccache --show-stats
- save_cache:
key: 'ccache-{{ arch }}-{{ .Branch }}'
paths: [ "/home/circleci/.ccache" ]
- save_cache:
key: 'pyenv'
paths: [ "/home/circleci/.pyenv" ]
+1
View File
@@ -0,0 +1 @@
build
-1
View File
@@ -1 +0,0 @@
github: [romainthomas]
@@ -1,6 +1,6 @@
---
name: Regular Issue
about: You identified a bug or a problem in LIEF
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: romainthomas
@@ -14,7 +14,7 @@ A clear and concise description of what the bug is.
Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen (if applicable)
A clear and concise description of what you expected to happen.
**Environment (please complete the following information):**
- System and Version : [e.g. Ubuntu 16.04]
-12
View File
@@ -1,12 +0,0 @@
---
name: Feature Request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
*Please describe what you would like to have in LIEF*.
**Note: If the feature is not precise or if you want to have feedback first, you can open a [discussion](https://github.com/lief-project/LIEF/discussions).**
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
-33
View File
@@ -1,33 +0,0 @@
---
name: Premium Issue
about: You need a fix for the issue with a high priority
title: ''
labels: Premium
assignees: romainthomas
---
*Premium issues can be used to get a higher priority resolution for users and companies.*
*In return, you need to contribute to the project with an action:*
- Writing a guest blog post here: https://lief-project.github.io/blog/
- Fixing another issue
- Sponsoring the issue
*Premium issues will be highlighted in the changelog and the release blog post with your name/logo*
----------------------------------
**Description**
*Please describe the issue/request that needs to be addressed*
**Context**
*Please provide the version of LIEF, the operating system as well as the binaries associated with the issue
(it can be sent by email as well)*
----------------------------------
**Reach out to `issue@lief.re` to discuss about the timeline/contribution.**
-10
View File
@@ -1,10 +0,0 @@
<!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 />
% endfor
</body>
</html>
-9
View File
@@ -1,9 +0,0 @@
[lief.s3]
region = "fr-par"
bucket = "lief"
endpoint = "https://s3.fr-par.scw.cloud"
[lief.deploy]
branches = ["master", "deploy", "devel"]
main-branches = ["master", "main"]
default-dir = "latest"
+367 -258
View File
@@ -1,298 +1,407 @@
#!/usr/bin/env python3
from botocore.exceptions import ClientError
from mako.template import Template
from pathlib import Path
from typing import Any, Optional
import argparse
import boto3
import functools
import logging
import os
import sys
import tempfile
import tomli
import os
import re
import logging
import pathlib
import subprocess
import shutil
import json
from datetime import datetime
from mako.template import Template
from enum import Enum, auto
LOG_LEVEL = logging.INFO
class CI(Enum):
UNKNOWN = auto()
TRAVIS = auto()
APPVEYOR = auto()
GITLAB_CI = auto()
CIRCLE_CI = auto()
GITHUB_ACTIONS = auto()
AZURE = auto()
LOCAL = auto()
CURRENTDIR = Path(__file__).resolve().parent
REPODIR = CURRENTDIR.parent
ASSET_DIR = CURRENTDIR / "assets"
CONFIG_DIR = CURRENTDIR / "config"
LIEF_S3_KEY = os.getenv("LIEF_S3_KEY", None)
LIEF_S3_SECRET = os.getenv("LIEF_S3_SECRET", None)
OWNED_ORGS = ["lief-project/", "romainthomas/"]
RELEASE_KEYWRD = "release-"
def pretty_ci_name(ci):
return str(ci).split(".")[-1].replace("_", "-").lower()
DEFAULT_CONFIG = CONFIG_DIR / "gh-ci.toml"
DEFAULT_TEMPLATE = (ASSET_DIR / "index.j2").read_text()
def is_pr(ci):
if ci == CI.TRAVIS:
cond1 = os.getenv("TRAVIS_EVENT_TYPE", "pull_request") == "pull_request"
cond2 = not (os.getenv("TRAVIS_REPO_SLUG", "").startswith("lief-project/") or os.getenv("TRAVIS_REPO_SLUG", "").startswith("romainthomas/LIEF"))
return cond1 or cond2
elif ci == CI.APPVEYOR:
logger.info("%s - %s", os.getenv("APPVEYOR_PULL_REQUEST_NUMBER", -1), os.getenv("APPVEYOR_REPO_NAME", ""))
pr_number = os.getenv("APPVEYOR_PULL_REQUEST_NUMBER", "")
cond1 = len(pr_number) != 0 and int(pr_number) >= 0
cond2 = not (os.getenv("APPVEYOR_REPO_NAME", "").startswith("lief-project/") or os.getenv("APPVEYOR_REPO_NAME", "").startswith("romainthomas/"))
return cond1 or cond2
elif ci == CI.CIRCLE_CI:
cond1 = int(os.getenv("CIRCLE_PR_NUMBER", -1)) >= 0
cond2 = os.getenv("CIRCLE_PROJECT_USERNAME", "") != "lief-project" and os.getenv("CIRCLE_PROJECT_USERNAME", "") != "romainthomas"
return cond1 or cond2
elif ci == CI.GITHUB_ACTIONS:
cond1 = os.getenv("GITHUB_HEAD_REF", "") != ""
cond2 = not (os.getenv("GITHUB_REPOSITORY", "").startswith("lief-project/") or os.getenv("GITHUB_REPOSITORY", "").startswith("romainthomas/LIEF"))
return cond1 or cond2
elif ci == CI.LOCAL:
return False
return True
def get_branch(ci):
if ci == CI.TRAVIS:
return os.getenv("TRAVIS_BRANCH")
elif ci == CI.APPVEYOR:
return os.getenv("APPVEYOR_REPO_BRANCH")
elif ci == CI.CIRCLE_CI:
return os.getenv("CIRCLE_BRANCH")
elif ci == CI.GITHUB_ACTIONS:
return os.getenv("GITHUB_REF").replace("refs/heads/", "")
elif ci == CI.LOCAL:
return os.getenv("CI_BRANCH")
return None
def get_ci_workdir(ci):
if ci == CI.CIRCLE_CI:
return os.getenv("CIRCLE_WORKING_DIRECTORY")
elif ci == CI.TRAVIS:
return os.getenv("TRAVIS_BUILD_DIR")
elif ci == CI.APPVEYOR:
return os.getenv("APPVEYOR_BUILD_FOLDER")
elif ci == CI.GITHUB_ACTIONS:
return os.getenv("GITHUB_WORKSPACE")
elif ci == CI.LOCAL:
return os.getenv("CI_WORKING_DIR")
else:
logger.critical("Unsupported CI to resolve working directory")
sys.exit(1)
def get_tag(ci):
if ci == CI.CIRCLE_CI:
return os.getenv("CIRCLE_TAG", "")
elif ci == CI.TRAVIS:
return os.getenv("TRAVIS_TAG", "")
elif ci == CI.APPVEYOR:
if "APPVEYOR_REPO_TAG_NAME" in os.environ:
return os.getenv("APPVEYOR_REPO_TAG_NAME", "")
return ""
elif ci == CI.GITHUB_ACTIONS:
ref = os.getenv("GITHUB_REF", "")
logger.info("Github Action tag: {}".format(ref))
if ref.startswith("refs/tags/"):
return ref.replace("refs/tags/", "")
return ""
elif ci == CI.LOCAL:
return os.getenv("CI_TAG")
else:
logger.critical("Unsupported CI to resolve working directory")
sys.exit(1)
LOG_LEVEL = logging.DEBUG
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
logging.getLogger().setLevel(LOG_LEVEL)
logger = logging.getLogger(__name__)
if LIEF_S3_KEY is None or len(LIEF_S3_KEY) == 0:
logger.error("LIEF_S3_KEY is not set!")
CURRENT_CI = CI.UNKNOWN
if LIEF_S3_SECRET is None or len(LIEF_S3_SECRET) == 0:
logger.error("LIEF_S3_SECRET is not set!")
# Detect CI
# ===========================================
if os.getenv("TRAVIS", None) is not None:
CURRENT_CI = CI.TRAVIS
elif os.getenv("APPVEYOR", None) is not None:
CURRENT_CI = CI.APPVEYOR
elif os.getenv("GITHUB_ACTIONS", None) is not None:
CURRENT_CI = CI.GITHUB_ACTIONS
elif os.getenv("GITLAB_CI", None) is not None:
CURRENT_CI = CI.GITLAB_CI
elif os.getenv("CI_LOCAL", "") == "true":
CURRENT_CI = CI.LOCAL
else:
logger.error("Can't detect CI!")
sys.exit(1)
# TODO(romain): Azure
class S3Manager:
def __init__(self, dirname: str, bucket: str,
region: str, endpoint: str,
dry_run: bool = False):
self._s3_dirname: str = dirname
self._s3_bucket: str = bucket
self._s3_region: str = region
self._s3_endpoint: str = endpoint
self._dry_run: bool = dry_run
CI_PRETTY_NAME = pretty_ci_name(CURRENT_CI)
logger.info("CI: %s", CI_PRETTY_NAME)
logger.info("[S3] Bucket : %s", self._s3_bucket)
logger.info("[S3] Region : %s", self._s3_region)
logger.info("[S3] Endpoint: %s", self._s3_endpoint)
logger.info("[S3] Dir : %s", self._s3_dirname)
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 not in ALLOWED_BRANCHES and not IS_TAGGED:
logger.info("Skip deployment for branch '%s'", BRANCH_NAME)
sys.exit(0)
def change_dir(self, dirname: str):
self._s3_dirname = dirname
if is_pr(CURRENT_CI):
logger.info("Skip pull request")
sys.exit(0)
@property
def s3_lief_sdk(self) -> str:
return f"{self._s3_dirname}/sdk"
CURRENTDIR = pathlib.Path(__file__).resolve().parent
REPODIR = CURRENTDIR.parent
@property
def s3_lief_wheel(self) -> str:
return f"{self._s3_dirname}/lief"
DEPLOY_KEY = os.getenv("LIEF_AUTOMATIC_BUILDS_KEY", None)
DEPLOY_IV = os.getenv("LIEF_AUTOMATIC_BUILDS_IV", None)
@property
def url(self):
return f"https://{self._s3_bucket}.s3-website.{self._s3_region}.scw.cloud/{self._s3_dirname}"
if DEPLOY_KEY is None or len(DEPLOY_KEY) == 0:
logger.error("Deploy key is not set!")
sys.exit(1)
@functools.lru_cache(maxsize=1)
def s3(self) -> boto3.Session:
s3_res = boto3.resource(
's3',
region_name=self._s3_region,
use_ssl=True,
endpoint_url=self._s3_endpoint,
aws_access_key_id=LIEF_S3_KEY,
aws_secret_access_key=LIEF_S3_SECRET
)
return s3_res
if DEPLOY_IV is None or len(DEPLOY_IV) == 0:
logger.error("Deploy IV is not set!")
sys.exit(1)
@classmethod
def from_config(cls, config):
pass
GIT_USER = "lief-{}-ci".format(CI_PRETTY_NAME)
GIT_EMAIL = "lief@quarkslab.com"
def _s3_push(self, file: Path, dst: str):
logger.info("Uploading %s to %s", file, dst)
try:
obj = self.s3().Object(self._s3_bucket, dst)
if not self._dry_run:
obj.put(Body=file.read_bytes())
else:
logger.info("[--] put: %s/%s - %s", self._s3_bucket, dst, file.as_posix())
return 0
except ClientError as e:
logger.error("S3 push failed: %s", e)
return 1
CI_CWD = pathlib.Path(get_ci_workdir(CURRENT_CI))
def push_wheel(self, file: str):
wheel_file = Path(file)
if not wheel_file.is_file():
logger.error("'%s' is not a valid file!", wheel_file)
return
if CI_CWD is None:
logger.debug("Can't resolve CI working dir")
sys.exit(1)
dst = f"{self.s3_lief_wheel}/{wheel_file.name}"
self._s3_push(wheel_file, dst)
def push_sdk(self, file: str):
sdk_path = Path(file)
if not sdk_path.is_file():
logger.error("'%s' is not a valid file!", sdk_path)
return
dst = f"{self.s3_lief_sdk}/{sdk_path.name}"
self._s3_push(sdk_path, dst)
def push_content(self, content: str, dst: str):
with tempfile.TemporaryDirectory() as tmp:
tmp_path = Path(tmp)
index = tmp_path / "index.html"
index.write_text(content)
self._s3_push(index, dst)
def process_sdk_wheels(self, directory: Path, maxdepth: int = 0,
depth: int = 0, recurse: bool = True):
logger.info("Processing directory: %s", directory)
for item in directory.iterdir():
if item.is_dir() and recurse:
if 0 < maxdepth < depth:
logger.debug("Maximum iteration depth reached")
else:
self.process_sdk_wheels(item, maxdepth, depth + 1, recurse)
elif item.is_file():
extension = item.suffix
if extension in (".zip", ".gz"):
logger.info("[SDK ] Uploading '%s'", item.as_posix())
self.push_sdk(item.as_posix())
elif extension in (".whl", ):
logger.info("[WHEEL] Uploading '%s'", item.as_posix())
self.push_wheel(item.as_posix())
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"
def upload_wheels_sdk(self, src_dir: Path, maxdepth: int):
logger.info("Looking for wheels and sdk from: %s", src_dir)
self.process_sdk_wheels(src_dir, maxdepth=maxdepth, recurse=True)
logger.debug("Working directory: %s", CI_CWD)
wheels_index = self.generate_index(self.s3_lief_wheel,
DEFAULT_TEMPLATE,
skiplist=("index.html", ))
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")
sdk_index = self.generate_index(self.s3_lief_sdk, DEFAULT_TEMPLATE,
skiplist=("index.html", ))
if DEPLOY_KEY is None:
logger.error("Deploy key is not set!")
sys.exit(1)
self.push_content(wheels_index, f"{self.s3_lief_wheel}/index.html")
self.push_content(sdk_index, f"{self.s3_lief_sdk}/index.html")
logger.info("Done!")
logger.info("URL: %s/%s", self.url, "sdk")
logger.info("URL: %s/%s", self.url, "lief")
def s3_list(self, dirname: str) -> list[Any]:
if self._dry_run:
return []
return self.s3().Bucket(self._s3_bucket).objects.filter(Prefix=dirname)
def generate_index(self, dirname: str, template: str, skiplist=None):
files = self.s3_list(dirname)
selected_files = []
for s3_object in files:
filename = Path(s3_object.key).name
if skiplist is not None and filename in skiplist:
continue
selected_files.append((s3_object.key, filename))
return Template(template).render(files=selected_files)
class GithubDeploy:
def __init__(self, branches: list[str],
main_branches: list[str],
default_dir: str,
s3_manager: S3Manager):
self.s3_manager: S3Manager = s3_manager
self._branches: list[str] = branches
self._main_branches: list[str] = main_branches
self._default_dir: str = default_dir
if DEPLOY_IV is None:
logger.error("Deploy IV is not set!")
sys.exit(1)
@classmethod
def from_config(cls, config_file: Path):
with open(config_file, "rb") as f:
toml_config = tomli.load(f)
#####################
# Clone package repo
#####################
target_branch = "gh-pages"
if "lief" not in toml_config:
logger.warning("Missing lief entries in '%s'", config_file)
return None
lief_conf = toml_config["lief"]
if BRANCH_NAME != "master":
target_branch = "packages-{}".format(BRANCH_NAME.replace("/", "-").replace("_", "-"))
if "s3" not in lief_conf:
logger.warning("Missing lief.s3 entries in '%s'", config_file)
return None
if IS_TAGGED:
target_branch = str(TAG_NAME)
if "deploy" not in lief_conf:
logger.warning("Missing lief.deploy entries in '%s'", config_file)
return None
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()
branches = lief_conf["deploy"]["branches"]
main_branches = lief_conf["deploy"]["main-branches"]
default_dir = lief_conf["deploy"]["default-dir"]
s3_config = lief_conf["s3"]
s3_region = s3_config["region"]
s3_bucket = s3_config["bucket"]
s3_endpoint = s3_config["endpoint"]
s3_manager = S3Manager(default_dir, s3_bucket, s3_region, s3_endpoint)
return cls(branches, main_branches, default_dir, s3_manager)
@staticmethod
def branch() -> Optional[str]:
ref = os.getenv("GITHUB_REF")
if ref is None:
return None
return ref.replace("refs/heads/", "")
@staticmethod
def is_pr() -> bool:
head_ref = os.getenv("GITHUB_HEAD_REF", "")
repo_path = os.getenv("GITHUB_REPOSITORY", "")
is_owned_repo = any(repo_path.startswith(org) for org in OWNED_ORGS)
return head_ref != "" or not is_owned_repo
@staticmethod
def is_tagged() -> bool:
tag = GithubDeploy.tag_name()
return tag is not None and len(tag) > 0
@staticmethod
def tag_name() -> Optional[str]:
ref = os.getenv("GITHUB_REF", "")
logger.info("Github Action tag: %s", ref)
if ref.startswith("refs/tags/"):
return ref.replace("refs/tags/", "")
return ""
@staticmethod
def workspace() -> str:
return os.getenv("GITHUB_WORKSPACE", "")
def is_main_branch(self, name: str) -> bool:
return name in self._main_branches
def deploy(self, directories: list[str]):
s3dir = None
if GithubDeploy.is_tagged():
s3dir = GithubDeploy.tag_name()
else:
branch = GithubDeploy.branch()
if branch is None:
logger.warning("Can't resolve the branch name")
sys.exit(1)
if branch.startswith(RELEASE_KEYWRD):
_, s3dir = branch.split(RELEASE_KEYWRD)
elif self.is_main_branch(branch):
s3dir = self._default_dir
else:
s3dir = branch.replace("/", "-").replace("_", "-")
if s3dir is None:
logger.error("Target directory is not set")
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)
logger.info("s3dir: %s", s3dir)
self.s3_manager.change_dir(s3dir)
for dirname in directories:
dirpath = Path(dirname).resolve().absolute().expanduser()
self.s3_manager.upload_wheels_sdk(dirpath, maxdepth=1)
new_branch = True
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--config", "-c")
parser.add_argument("--dry-run", "-n", action="store_true", default=False)
parser.add_argument("directories", nargs="+")
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)
args = parser.parse_args()
config_path = None
if args.config is not None:
config_path = Path(args.config)
else:
config_path = DEFAULT_CONFIG
cmd = "{} reset --hard".format(GIT)
pmaster = subprocess.Popen(cmd, shell=True, cwd=LIEF_PACKAGE_DIR, stderr=subprocess.STDOUT)
pmaster.wait()
if not config_path.is_file():
logger.error("'%s' is not a valid config path")
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)
gh_deploy = GithubDeploy.from_config(config_path)
gh_deploy.deploy(args.directories)
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"""
<html>
<title>Links for lief</title>
<body>
<h1>Links for lief</h1>
% for name in names:
<a href="${base_url}/${base}/${name}">${name}</a><br />
% endfor
</body>
</html>
"""
EXCLUDED = ['index.html', '.gitkeep']
BASE_URL = "https://lief-project.github.io"
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)
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)
output_key_path.unlink()
logger.info("Done!")
if __name__ == "__main__":
main()
sys.exit(0)
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

+37 -53
View File
@@ -1,79 +1,63 @@
name: 'Android'
on: workflow_dispatch
on: push
jobs:
build-sdk:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
arch: ['arm', 'arm64']
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v1.1.0
with:
path: ~/.ccache
key: android-${{ runner.os }}-${{ matrix.arch }}-${{ steps.get-date.outputs.date }}
key: android-${{ runner.os }}-${{ steps.get-date.outputs.date }}
restore-keys: |
android-${{ runner.os }}-${{ matrix.arch }}
- name: Build SDK [${{ matrix.arch }}]
android-${{ runner.os }}-
- name: Build ARM SDK
shell: bash
env:
ARCH: ${{ matrix.arch }}
run: |
docker run \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
docker run \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-${ARCH}.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: android-sdk-${{ matrix.arch }}
path: build/*.tar.gz
retention-days: 3
deploy:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: build-sdk
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
-v $HOME/.ccache:/ccache \
--rm liefproject/android-arm bash /work/scripts/docker/android-arm.sh
- name: Build AArch64 SDK
shell: bash
run: |
docker run \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/android-arm64 bash /work/scripts/docker/android-aarch64.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 --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
docker run \
-v $GITHUB_WORKSPACE:/src \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
-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
-31
View File
@@ -1,31 +0,0 @@
name: code-check
on:
workflow_dispatch:
inputs:
branch:
description: 'LIEF branch'
default: 'master'
required: false
type: string
push:
branches:
- test/code-check
jobs:
coverage:
runs-on: ubuntu-latest
container:
image: liefproject/code-check
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
GH_BRANCH: ${{ inputs.branch }}
steps:
- uses: actions/checkout@v3
with:
repository: lief-project/code-check
token: ${{ secrets.LIEF_CLONE_TOKEN }}
- name: Print info
run: |
echo ${GH_BRANCH}
- name: Running LIEF coverage
run: ./lief-coverage --debug
+15 -47
View File
@@ -1,20 +1,17 @@
name: 'iOS'
on: workflow_dispatch
env:
python-version: '3.10'
on: push
jobs:
ios-sdk:
osx-sdk:
runs-on: macos-11.0
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
python-version: 3.9
- name: Install system dependencies
run: |
brew install cmake ninja ccache
@@ -22,65 +19,36 @@ jobs:
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Setup cache dir
shell: bash
run: |
mkdir -p ~/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v1.1.0
with:
path: ${{ runner.temp }}/.ccache
path: ~/.ccache
key: ios-${{ runner.os }}-${{ steps.get-date.outputs.date }}
restore-keys: |
ios-${{ runner.os }}
ios-${{ runner.os }}-
- name: Build iOS SDK
shell: bash
env:
CCACHE_DIR: ${{ runner.temp }}/.ccache
CCACHE_DIR: ~/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
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
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: ios-sdk
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
- 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 --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
python -m pip install --upgrade requests mako
python .github/deploy.py
+43 -101
View File
@@ -1,129 +1,71 @@
name: 'Linux AArch64'
on: workflow_dispatch
on: push
jobs:
linux-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
with:
path: ~/.ccache
key: linux-aarch64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-aarch64-${{ runner.os }}-sdk
- name: Build SDK
shell: bash
run: |
mkdir -p $RUNNER_TEMP/lief-install
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-aarch64-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload Install Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-aarch64-install
path: ${{ runner.temp }}/lief-install
retention-days: 1
wheels:
runs-on: ubuntu-latest
needs: linux-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v1.1.0
with:
path: ~/.ccache
key: linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
key: linux-aarch64-${{ runner.os }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
with:
name: linux-aarch64-install
path: ${{ runner.temp }}/lief-install
- name: Python ${{ matrix.python-version }} -- Wheel
linux-aarch64-${{ runner.os }}-
- name: Build SDK
if: matrix.python-version == '3.9'
shell: bash
run: |
docker run \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/manylinux2014-aarch64 bash /work/scripts/docker/linux-aarch64.sh
- name: Build Python ${{ matrix.python-version }} wheel
shell: bash
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
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_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.sh
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-aarch64-python${{ matrix.python-version }}-wheel
path: dist/*.whl
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [linux-sdk, wheels]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
PYTHON_VERSION2=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
docker run \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_CPP2=1 \
-e CCACHE_DIR=/ccache \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION2}-cp${PYTHON_VERSION2}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/work \
-v $HOME/.ccache:/ccache \
--rm liefproject/manylinux2014-aarch64 bash /work/scripts/docker/manylinux2014-aarch64.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 --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
docker run \
-v $GITHUB_WORKSPACE:/src \
-e GITHUB_ACTIONS="true" \
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-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
+76 -145
View File
@@ -1,177 +1,108 @@
name: 'Linux x86-64'
on: workflow_dispatch
on: push
jobs:
linux-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v1.1.0
with:
path: ~/.ccache
key: linux-x86-64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
key: linux-x86-64-${{ runner.os }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-sdk
- name: Build SDK
linux-x86-64-${{ runner.os }}-
- name: Build Python 3.7 wheel
shell: bash
env:
PYTHON_VERSION: 37
run: |
mkdir -p $RUNNER_TEMP/lief-install
docker run --name lief_sdk --rm \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP/lief-install:/install \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_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 Install Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-x86-64-install
path: ${{ runner.temp }}/lief-install
retention-days: 1
testing:
if: "!contains(github.event.commits[0].message, '[skip-test]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
with:
path: ~/.ccache
key: linux-x86-64-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-test
- name: Python 3.8 -- Wheel & Test
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/cp37-cp37m/bin/python3.7 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build Python 3.8 wheel
shell: bash
env:
PYTHON_VERSION: 38
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 \
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/cp38-cp38/bin/python3.8 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
pywheels:
runs-on: ubuntu-latest
needs: linux-sdk
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
uses: actions/cache@v3
with:
path: ~/.ccache
key: linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
linux-x86-64-${{ runner.os }}-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
with:
name: linux-x86-64-install
path: ${{ runner.temp }}/lief-install
- name: Python ${{ matrix.python-version }} -- Wheel
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build Python 3.9 wheel
shell: bash
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PYTHON_VERSION: 39
run: |
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
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_ALT \
-e PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION} \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
-v $RUNNER_TEMP/lief-install:/install \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux.sh
- name: 'Artifact'
uses: actions/upload-artifact@v3
with:
name: linux-x86-64-python${{ matrix.python-version }}-wheel
path: dist/*.whl
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [linux-sdk, pywheels]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
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/cp39-cp39/bin/python3.9 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
- name: Build SDK
shell: bash
run: |
docker run --name lief_sdk --rm \
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
-e CCACHE_COMPRESS=1 \
-e CCACHE_MAXSIZE=10.0G \
-e CCACHE_DIR=/ccache \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
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 --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
documentation:
needs: [deploy]
runs-on: ubuntu-latest
container:
image: liefproject/manylinux_2_28_x86_64
env:
CIRCLE_CI_URL: "https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline"
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
steps:
docker run \
-v $GITHUB_WORKSPACE:/src \
-e GITHUB_ACTIONS="true" \
-e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
-e GITHUB_REF=$GITHUB_REF \
-e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
-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: |
curl --request POST --url ${CIRCLE_CI_URL} \
--header "Circle-Token: ${CIRCLE_CI_TOKEN}" \
--header 'content-type: application/json' \
--data '{"parameters":{"lief-branch":"master"}}'
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'";
+31 -175
View File
@@ -1,136 +1,18 @@
name: 'macOS'
on: workflow_dispatch
env:
python-test-version: '3.10'
on: push
jobs:
osx-sdk:
runs-on: macos-11.0
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install system dependencies
run: |
brew install cmake ninja ccache
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup cache dir
shell: bash
run: |
mkdir -p $RUNNER_TEMP/.ccache
- name: ccache cache files
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
restore-keys: |
osx-${{ runner.os }}-sdk
- name: Build SDK
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_DIR: ${{ runner.temp }}/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
run: |
bash scripts/osx/package_sdk.sh
- name: 'Upload SDK Artifact'
uses: actions/upload-artifact@v3
with:
name: osx-sdk
path: build/*.tar.gz
retention-days: 3
- name: 'Upload install artifact [arm64]'
uses: actions/upload-artifact@v3
with:
name: osx-arm64-install
path: install/arm64
retention-days: 1
- name: 'Upload install artifact [x64]'
uses: actions/upload-artifact@v3
with:
name: osx-x64-install
path: install/x64
retention-days: 1
osx-testing:
runs-on: macos-11.0
if: "!contains(github.event.commits[0].message, '[skip-test]')"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-test-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-test-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup cache dir
shell: bash
run: |
mkdir -p $RUNNER_TEMP/.ccache
- name: ccache cache files
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
restore-keys: |
osx-${{ runner.os }}-test
- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip setuptools
- name: Build Python 3.10 with tests
shell: bash
env:
LIEF_SAMPLES_DIR: "/tmp/samples"
BUILD_DIR: "/tmp/lief-build"
MACOSX_TARGET: "11.7"
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_DIR: ${{ runner.temp }}/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
cd api/python
PYLIEF_CONF=${GITHUB_WORKSPACE}/scripts/osx/osx-testing-x64.toml \
python ./setup.py build \
--build-base=${BUILD_DIR}/base \
--build-temp=${BUILD_DIR}/temp \
install --user
cd ${GITHUB_WORKSPACE}
python tests/run_pytest.py
python tests/run_tools_check.py ${BUILD_DIR}/temp
ctest --output-on-failure --test-dir ${BUILD_DIR}/temp
wheels:
runs-on: macos-11.0
needs: osx-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
arch: ['x64', 'arm64']
fail-fast: false
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
@@ -140,75 +22,49 @@ jobs:
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
shell: bash
- name: Setup cache dir
shell: bash
run: |
mkdir -p $RUNNER_TEMP/.ccache
mkdir -p ~/.ccache
- name: ccache cache files
uses: actions/cache@v3
uses: actions/cache@v1.1.0
with:
path: ${{ runner.temp }}/.ccache
key: osx-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
path: ~/.ccache
key: osx-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
osx-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}
- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip setuptools
- name: Download LIEF install dir
uses: actions/download-artifact@v3
with:
name: osx-${{ matrix.arch }}-install
path: ~/lief-${{ matrix.arch }}-install
- name: Build Python ${{ matrix.python-version }} [${{ matrix.arch }}]
osx-${{ runner.os }}-${{ matrix.python-version }}-
osx-${{ runner.os }}-
- name: Build Python ${{ matrix.python-version }} wheel
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_DIR: ${{ runner.temp }}/.ccache
MACOSX_DEPLOYMENT_TARGET: "10.14"
CCACHE_DIR: ~/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
PYLIEF_CONF: "${{ github.workspace }}/scripts/osx/py-${{ matrix.arch }}.toml"
run: |
python -m pip -vv wheel --wheel-dir=dist/ api/python
- name: 'Upload Python wheel artifact - ${{ matrix.python-version }}'
uses: actions/upload-artifact@v3
with:
name: osx-wheel-${{ matrix.arch }}-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [osx-sdk, wheels]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Display artifacts
run: ls -R
working-directory: ${{ runner.temp }}/artifacts
python ./setup.py --ninja build bdist_wheel --skip-build --plat-name=macosx_${MACOSX_DEPLOYMENT_TARGET}_x86_64
- name: Build SDK
shell: bash
if: matrix.python-version == '3.9' # Build the SDk only with Python 3.9
env:
MACOSX_DEPLOYMENT_TARGET: "10.14"
CCACHE_DIR: ~/.ccache
CCACHE_MAXSIZE: 10.0G
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
run: |
bash scripts/osx/package_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 --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
python -m pip install --upgrade requests mako
python .github/deploy.py
-96
View File
@@ -1,96 +0,0 @@
name: LIEF PR
on: [pull_request, workflow_dispatch]
env:
python-osx-version: '3.10'
python-win-version: '3.10'
jobs:
osx:
runs-on: macos-11.0
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-osx-version }}
- name: Install system dependencies
run: |
brew install cmake ninja ccache
python -m pip install --upgrade pip setuptools wheel
- name: Build with Python ${{ env.python-osx-version }} & Test
shell: bash
env:
LIEF_SAMPLES_DIR: "/tmp/samples"
BUILD_DIR: "/tmp/lief-build"
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
cd api/python
PYLIEF_CONF=${GITHUB_WORKSPACE}/scripts/osx/osx-testing-x64.toml \
python ./setup.py build \
--build-base=${BUILD_DIR}/base \
--build-temp=${BUILD_DIR}/temp \
install --user
cd ${GITHUB_WORKSPACE}
python tests/run_pytest.py
python tests/run_tools_check.py ${BUILD_DIR}/temp
ctest --output-on-failure --test-dir ${BUILD_DIR}/temp
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build & Test
shell: bash
env:
PYTHON_VERSION: 39
run: |
docker run --rm \
-e PYTHON_VERSION=$PYTHON_VERSION \
-e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
-v $GITHUB_WORKSPACE:/src \
liefproject/manylinux_2_28_x86_64 bash /src/scripts/docker/run_linux_test.sh
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-win-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-win-version }}
architecture: x64
- name: Install system dependencies
run: |
choco install ninja
python -m pip install --upgrade pip setuptools
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Set env variables
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
echo ("BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
echo ("PYLIEF_CONF=" + $env:GITHUB_WORKSPACE + "/scripts/windows/py-x64-test.toml") >> $env:GITHUB_ENV
- name: Build Python ${{ env.python-win-version }}
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
cd api/python
python ./setup.py build ^
--build-base=%BUILD_DIR%/base ^
--build-temp=%BUILD_DIR%/temp ^
install --user
shell: cmd
- name: Run tests
run: |
cd %GITHUB_WORKSPACE%
python tests/run_pytest.py
ctest --output-on-failure --test-dir %BUILD_DIR%/temp/Release
shell: cmd
-44
View File
@@ -1,44 +0,0 @@
name: 'sanitize'
on: workflow_dispatch
jobs:
gcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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
-249
View File
@@ -1,249 +0,0 @@
name: LIEF Windows
on: workflow_dispatch
env:
python-test-version: '3.10'
python-version: '3.9'
jobs:
build-sdk:
runs-on: windows-2019
strategy:
matrix:
arch: ['x64', 'x86']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
architecture: ${{ matrix.arch }}
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup sccache
uses: actions/cache@v3
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.arch }}-sccache-sdk-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-sccache-sdk
- name: Start sccache server
run: sccache --start-server
- name: Build SDK
run: |
python ./scripts/windows/package_sdk.py
- name: 'Upload SDK artifact'
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}-sdk
path: build/*.zip
retention-days: 3
- name: 'Upload install artifact'
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}-install
path: ${{ runner.temp }}/lief-install
retention-days: 1
- name: sccache stats
run: sccache --show-stats
- name: stop sccache server
run: sccache --stop-server || true
tests:
runs-on: windows-2019
if: "!contains(github.event.commits[0].message, '[skip-test]')"
strategy:
matrix:
arch: ['x64']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-test-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-test-version }}
architecture: ${{ matrix.arch }}
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Setup sccache
uses: actions/cache@v3
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.arch }}-sccache-test-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-sccache-test
- name: Start sccache server
run: sccache --start-server
- name: Set arch specific env
if: matrix.arch == 'x64'
run: |
echo "ARCH=x64" >> $env:GITHUB_ENV
- name: Set arch specific env
if: matrix.arch == 'x86'
run: |
echo "ARCH=x86" >> $env:GITHUB_ENV
- name: Set Python config (${{ matrix.arch }})
run: |
echo ("PYLIEF_CONF=" + $env:GITHUB_WORKSPACE + "/scripts/windows/py-" + $env:ARCH + "-test.toml") >> $env:GITHUB_ENV
- name: Set env variables
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
echo ("BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
- name: Build Python ${{ env.python-test-version }}
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
cd api/python
python ./setup.py build ^
--build-base=%BUILD_DIR%/base ^
--build-temp=%BUILD_DIR%/temp ^
install --user
shell: cmd
- name: Run tests
run: |
cd %GITHUB_WORKSPACE%
python tests/run_pytest.py
ctest --output-on-failure --test-dir %BUILD_DIR%/temp/Release
shell: cmd
- name: sccache stats
run: sccache --show-stats
- name: stop sccache server
run: sccache --stop-server || true
wheels:
runs-on: windows-2019
needs: build-sdk
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12-dev']
arch: ['x86', 'x64']
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.arch }}
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools wheel
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Save sccache
uses: actions/cache@v3
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.arch }}-sccache-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-sccache-${{ matrix.python-version }}
- name: Download LIEF install dir
uses: actions/download-artifact@v3
with:
name: windows-${{ matrix.arch }}-install
path: ~/lief-${{ matrix.arch }}-install
- name: Start sccache server
run: sccache --start-server
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
shell: cmd
- name: Set arch specific env
if: matrix.arch == 'x64'
run: |
echo "ARCH=x64" >> $env:GITHUB_ENV
- name: Set arch specific env
if: matrix.arch == 'x86'
run: |
echo "ARCH=x86" >> $env:GITHUB_ENV
- name: Set Python config (${{ matrix.arch }})
run: |
echo ("PYLIEF_CONF=" + $env:GITHUB_WORKSPACE + "/scripts/windows/py-" + $env:ARCH + ".toml") >> $env:GITHUB_ENV
- name: Set env variables
run: |
chcp 65001 #set code page to utf-8
- name: Build Python ${{ matrix.python-version }}
run: |
python -m pip -vv wheel --wheel-dir=dist/ api/python
shell: cmd
- name: 'Upload Python artifacts [${{ matrix.python-version }}]'
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}-wheel-${{ matrix.python-version }}
path: dist/*.whl
retention-days: 3
deploy:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [build-sdk, wheels]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ runner.temp }}/artifacts
- name: Deploy
env:
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
shell: bash
run: |
docker run --rm \
-v $GITHUB_WORKSPACE:/src \
-v $RUNNER_TEMP:/runner_tmp \
-e GITHUB_ACTIONS="true" \
-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 \
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
-70
View File
@@ -1,70 +0,0 @@
name: LIEF Windows Quick
on: workflow_dispatch
env:
python-version: '3.9'
jobs:
quick-test:
runs-on: windows-2019
strategy:
matrix:
arch: [x64, x86]
fail-fast: false
env:
SCCACHE_CACHE_SIZE: 2G
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
architecture: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
choco install ninja
choco install sccache
python -m pip install --upgrade pip setuptools wheel
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
shell: bash
- name: Save sccache
uses: actions/cache@v3
continue-on-error: false
with:
path: ${{ vars.SCCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.arch }}-quick-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-quick
- name: Start sccache server
run: sccache --start-server
- name: Set env variables
run: |
chcp 65001 #set code page to utf-8
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
shell: cmd
- name: Build Python ${{ env.python-version }}
run: |
python -m pip install -r tests/requirements.txt
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
python -m pip -vv install api/python
shell: cmd
- name: Run tests
run: |
python ./tests/run_pytest.py
shell: cmd
- name: sccache stats
run: sccache --show-stats
- name: sccache server
run: sccache --stop-server || true
+30
View File
@@ -0,0 +1,30 @@
name: LIEF Windows Tests
on: [pull_request]
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
choco install ninja
python -m pip install --upgrade pip setuptools
python -m pip install wheel mako
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
- name: Build and Test
run: |
python ./setup.py --ninja --lief-test bdist_wheel
shell: cmd
-5
View File
@@ -1,5 +0,0 @@
build/
*.so
*.whl
lief.egg-info/
dist/
+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
+209 -325
View File
@@ -1,18 +1,12 @@
cmake_minimum_required(VERSION 3.15)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
# Enable https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
cmake_policy(SET CMP0091 NEW)
cmake_minimum_required(VERSION 3.5)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
if(WIN32)
include(ChooseMSVCCRT)
endif()
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
include(ExternalProject)
@@ -27,8 +21,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
include(LIEFGit)
else()
set(LIEF_VERSION_MAJOR "0")
set(LIEF_VERSION_MINOR "14")
set(LIEF_VERSION_PATCH "0")
set(LIEF_VERSION_MINOR "11")
set(LIEF_VERSION_PATCH "5")
endif()
# LIEF Project
@@ -38,36 +32,6 @@ project(
VERSION ${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}")
# Select the MSVC runtime based on the LIEF_USE_CRT_XXX variable
if(MSVC)
foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if(DEFINED "LIEF_USE_CRT_${build}")
set(runtime "${LIEF_USE_CRT_${build}}")
if(build_type STREQUAL Debug)
set(default_runtime MDd)
else()
set(default_runtime MD)
endif()
if(runtime AND NOT "${runtime}" STREQUAL "${default_runtime}")
if(runtime STREQUAL "MT")
set(runtime_library "MultiThreaded")
elseif(runtime STREQUAL "MD")
set(runtime_library "MultiThreadedDLL")
elseif(runtime STREQUAL "MTd")
set(runtime_library "MultiThreadedDebug")
elseif(runtime STREQUAL "MDd")
set(runtime_library "MultiThreadedDebugDLL")
else()
message(FATAL_ERROR "Unsupported value LIEF_USE_CRT_${build}=${runtime}")
endif()
message(STATUS "LIEF_CRT_${build}: ${runtime}")
set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}$<$<CONFIG:${build_type}>:${runtime_library}>")
endif()
endif()
endforeach()
endif()
# LIEF options
# =============
include(LIEFOptions)
@@ -86,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}")
@@ -126,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)
@@ -134,20 +101,22 @@ set(LIEF_PUBLIC_INCLUDE_FILES)
set(LIEF_PRIVATE_INCLUDE_FILES)
set(LIBLIEF_SOURCE_FILES
"${ELG_CC_PATH}"
"${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")
@@ -155,9 +124,9 @@ 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"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iostream.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iterators.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/LIEF.hpp"
@@ -172,14 +141,9 @@ 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")
@@ -187,14 +151,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})
@@ -204,43 +166,13 @@ source_group("Header Files\\visitors" FILES ${LIEF_VISITOR_INCLUDE_FILES})
add_library(LIB_LIEF ${LIBLIEF_SOURCE_FILES} ${LIEF_INCLUDE_FILES})
if(NOT LIEF_PY_LIEF_EXT)
add_library(LIEF::LIEF ALIAS LIB_LIEF)
endif()
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)
add_compile_options(/bigobj)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug AND WINDOWS)
@@ -257,6 +189,9 @@ if(BUILD_SHARED_LIBS OR LIEF_FORCE_API_EXPORTS)
else()
target_compile_definitions(LIB_LIEF PRIVATE -DLIEF_STATIC)
endif()
if(LIEF_SUPPORT_CXX14)
target_compile_features(LIB_LIEF PRIVATE cxx_std_14)
endif()
# Abstract part
include("${CMAKE_CURRENT_SOURCE_DIR}/src/Abstract/CMakeLists.txt")
@@ -292,14 +227,14 @@ endif()
# =====================
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_DISABLE_DEFAULT_LOGGER
SPDLOG_NO_EXCEPTIONS
SPDLOG_FUNCTION=)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_NO_THREAD_ID)
# Frozen Configuration
# ====================
if(LIEF_FROZEN_ENABLED)
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${FROZEN_INCLUDE_DIR}")
endif()
# OAT part
# ========
if(LIEF_OAT)
@@ -348,123 +283,74 @@ 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/")
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}")
"${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
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 "${SPDLOG_SOURCE_DIR}/include"
"${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()
# =======================================
# Expected
# Leaf
# =======================================
if(LIEF_EXTERNAL_EXPECTED)
message(STATUS "Using external Expected version")
find_package(tl-expected REQUIRED)
target_link_libraries(LIB_LIEF PUBLIC tl::expected)
else()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/expected.hpp
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
COMMAND
${CMAKE_COMMAND} -E copy_directory ${EXPECTED_SRC_DIR}/include/tl/
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/
DEPENDS lief_expected)
target_sources(LIB_LIEF PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/expected.hpp)
endif()
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/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}/include/LIEF/third-party/utfcpp/utf8.h)
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_link_libraries(LIB_LIEF PRIVATE lief_spdlog)
if(ANDROID AND BUILD_SHARED_LIBS AND LIEF_LOGGING)
target_link_libraries(LIB_LIEF PUBLIC log)
endif()
add_dependencies(LIB_LIEF lief_spdlog lief_mbed_tls)
# Flags definition
# ----------------
@@ -473,7 +359,7 @@ endif()
set_target_properties(
LIB_LIEF
PROPERTIES POSITION_INDEPENDENT_CODE ON
CXX_STANDARD 17
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden)
@@ -488,15 +374,27 @@ endif()
target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
# LIEF Sanitizer options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Enable support for MD2 and MD4 for parsing the Authenticode sigs of older
# executables. Also, some older signed executables use certs with the
# 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_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_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION)
# 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()
@@ -504,8 +402,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()
@@ -514,58 +414,74 @@ 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
# =============
include(LIEFCompilerFlags)
# Profiling flags
# ---------------
if(LIEF_PROFILING)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profiling")
set(PROFILING_FLAGS
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc
-fno-builtin-free -fno-omit-frame-pointer -g)
target_compile_options(LIB_LIEF PUBLIC ${PROFILING_FLAGS})
add_executable(elf_profiler profiling/elf_profiler.cpp)
target_compile_options(elf_profiler PUBLIC ${PROFILING_FLAGS})
target_link_libraries(elf_profiler PRIVATE LIB_LIEF)
endif()
set_target_properties(LIB_LIEF PROPERTIES
OUTPUT_NAME LIEF
EXPORT_NAME LIEF
CLEAN_DIRECT_OUTPUT 1)
# Coverage flags
# --------------
if(LIEF_COVERAGE)
target_compile_options(LIB_LIEF PRIVATE -g -O0 --coverage -fprofile-arcs
-ftest-coverage)
target_link_libraries(LIB_LIEF gcov)
endif()
set_target_properties(LIB_LIEF PROPERTIES OUTPUT_NAME LIEF CLEAN_DIRECT_OUTPUT 1)
# Set a default build type if none was specified
@@ -576,14 +492,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
@@ -610,10 +528,22 @@ if(LIEF_DOC)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc)
endif()
# Find Package Config
# ======================
configure_package_config_file(
LIEFConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
INSTALL_DESTINATION share/LIEF/cmake)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
# 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"
@@ -622,7 +552,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"
@@ -632,101 +562,55 @@ if(BUILD_SHARED_LIBS AND CMAKE_BUILD_TYPE MATCHES "Release")
endif()
endif()
# Generate install target and package
# =======================================
if(LIEF_INSTALL)
# Find Package Config
# ======================
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
@ONLY)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
# Install Prefix
# ======================
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND UNIX)
if(UNIX AND NOT APPLE)
set(CMAKE_INSTALL_PREFIX
"/usr"
CACHE PATH "Install path prefix prepended on to install directories."
FORCE)
elseif(APPLE)
set(CMAKE_INSTALL_PREFIX
"/usr/local"
CACHE PATH "" FORCE)
endif()
# Install Prefix
# ======================
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND UNIX)
if(UNIX AND NOT APPLE)
set(CMAKE_INSTALL_PREFIX
"/usr"
CACHE PATH "Install path prefix prepended on to install directories."
FORCE)
elseif(APPLE)
set(CMAKE_INSTALL_PREFIX
"/usr/local"
CACHE PATH "" FORCE)
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})
install(
DIRECTORY ${LIEF_PUBLIC_INCLUDE_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers
FILES_MATCHING
REGEX "(.*).(hpp|h|def|inc)$")
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
COMPONENT config)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/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)
# Package
# ======================
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package")
endif()
# Installation
# ======================
install(
TARGETS LIB_LIEF
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib COMPONENT libraries)
install(
DIRECTORY ${LIEF_PUBLIC_INCLUDE_DIR}
DESTINATION include
COMPONENT headers
FILES_MATCHING
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 share/LIEF/cmake
COMPONENT config)
install(
FILES ${CMAKE_BINARY_DIR}/LIEF.pc
DESTINATION lib/pkgconfig
COMPONENT libraries)
export(TARGETS LIB_LIEF FILE LIEFExport.cmake)
# Package
# ======================
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package")
+21
View File
@@ -0,0 +1,21 @@
# Docker file used to compile LIEF on Linux x86-64 compliant with Python tag: manylinux1
# docker build -t liefproject/manylinux1_x86_64:latest -f ./Dockerfile .
FROM quay.io/pypa/manylinux1_x86_64:2020-12-30-e2b3664
RUN yum update -y \
&& yum install -y ccache \
&& yum clean all
RUN /opt/python/cp37-cp37m/bin/pip install cmake==3.13.3 ninja==1.10.0.post2
ENV PATH=$PATH:/opt/python/cp37-cp37m/bin/
RUN curl --output /tmp/gcc-6.3.0-binutils-2.27-x86_64.tar.bz2 -L https://github.com/squeaky-pl/centos-devtools/releases/download/6.3/gcc-6.3.0-binutils-2.27-x86_64.tar.bz2 && \
echo "ca3e9f92411507018c839c8cc2b496f14956a49fcf6df0cdcb356de7161bcbc5 /tmp/gcc-6.3.0-binutils-2.27-x86_64.tar.bz2" | sha256sum --check --status && \
tar -C / -xj -f /tmp/gcc-6.3.0-binutils-2.27-x86_64.tar.bz2 && \
rm -rf /tmp/gcc-6.3.0-binutils-2.27-x86_64.tar.bz2
ENV CC=/opt/devtools-6.3/bin/gcc
ENV CXX=/opt/devtools-6.3/bin/g++
ENV CXXFLAGS="-static-libstdc++ -static-libgcc"
WORKDIR /src
+2 -2
View File
@@ -186,8 +186,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2017 - 2023 R. Thomas
Copyright 2017 - 2023 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.
View File
+4
View File
@@ -0,0 +1,4 @@
@PACKAGE_INIT@
set(LIEF_DIR "${PACKAGE_PREFIX_DIR}")
include("${CMAKE_CURRENT_LIST_DIR}/FindLIEF.cmake")
+26
View File
@@ -0,0 +1,26 @@
include README.md LICENSE setup.cfg CMakeLists.txt LIEF.pc.in LIEFConfig.cmake.in
# Examples
recursive-include examples *
# LIEF Sources
recursive-include src *
recursive-include include *
recursive-include third-party *
recursive-include cmake *
recursive-include scripts *
# Bindings
recursive-include api *
prune api/python/build
# Global exclude
recursive-exclude *.egg-info *.so
# Install script
recursive-include package *
# Documentation
recursive-include doc *
+116 -65
View File
@@ -3,32 +3,32 @@
</p>
<p align="center">
<a href="https://discord.gg/7hRFGWYedu">
<img src="https://img.shields.io/discord/1117013848914931762">
<a href="https://gitter.im/lief-project">
<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/workflows/linux-x86-64.yml">
<img alt="Linux x86-64 CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/linux-x86-64.yml?branch=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/workflows/linux-aarch64.yml">
<img alt="Linux AArch64 CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/linux-aarch64.yml?branch=master&label=Linux%20AArch64&logo=github">
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3A%22Linux+AArch64%22">
<img alt="Linux AArch64 CI status" src="https://img.shields.io/github/workflow/status/lief-project/LIEF/Linux%20AArch64/master?label=Linux%20AArch64&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/android.yml">
<img alt="Android CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/android.yml?branch=master&label=Android&logo=github">
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3AAndroid">
<img alt="Android CI status" src="https://img.shields.io/github/workflow/status/lief-project/LIEF/Android/master?label=Android&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/osx.yml">
<img alt="macOS CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/osx.yml?branch=master&label=macOS&logo=github">
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3AmacOS">
<img alt="macOS CI status" src="https://img.shields.io/github/workflow/status/lief-project/LIEF/macOS/master?label=macOS&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/ios.yml">
<img alt="iOS CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/ios.yml?branch=master&label=iOS&logo=github">
<a href="https://github.com/lief-project/LIEF/actions?query=workflow%3AiOS">
<img alt="iOS CI status" src="https://img.shields.io/github/workflow/status/lief-project/LIEF/iOS/master?label=iOS&logo=github">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/actions/workflows/windows-all.yml">
<img alt="Windows CI status" src="https://img.shields.io/github/actions/workflow/status/lief-project/LIEF/windows-all.yml?branch=master&label=Windows&logo=github">
<a href="https://ci.appveyor.com/project/Romain/lief/branch/master">
<img alt="Windows CI status" src="https://img.shields.io/appveyor/build/Romain/LIEF/master?label=Windows&logo=appveyor">
</a>
&nbsp;
<a href="https://github.com/lief-project/LIEF/releases">
@@ -36,22 +36,14 @@
</a>
&nbsp;
<a href="https://twitter.com/LIEF_project">
<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/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="#user-content-about-1"><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,21 @@ 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)
- [Contact](#contact)
- [About](#about)
- [Authors](#authors)
@@ -102,25 +93,70 @@ 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.14.0.dev0
pip install [--user] --index-url https://lief.quarkslab.com/packages lief==0.11.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.13.2**: https://github.com/lief-project/LIEF/releases/tag/0.13.2
<table>
<tr><td colspan="4"><a href="https://lief-project.github.io/packages/sdk"><img src="https://img.shields.io/badge/release-master-brightgreen.svg?style=default"></a></td></tr>
<tr>
<th>Linux</th>
<th>Windows - x86</th>
<th>Windows - x86-64</th>
<th>OSX</th>
</tr>
<tr>
<td><a href="https://lief-project.github.io/packages/sdk/LIEF-0.11.0-Linux.tar.gz">SDK</a></td>
<td><a href="https://lief-project.github.io/packages/sdk/LIEF-0.11.0-win32.zip">SDK</a></td>
<td><a href="https://lief-project.github.io/packages/sdk/LIEF-0.11.0-win64.zip">SDK</a></td>
<td><a href="https://lief-project.github.io/packages/sdk/LIEF-0.11.0-Darwin.tar.gz">SDK</a></td>
</tr>
<tr>
<td colspan="4"><p align="center"><a href="https://lief-project.github.io/packages/lief">Python</a></p></td>
</tr>
</table>
<table>
<tr><td colspan="6"><b><img src="https://img.shields.io/badge/release-0.10.1-brightgreen.svg?style=default"></b></td></tr>
<tr>
<th>Linux</th>
<th>Windows</th>
<th>OSX</th>
<th>Documentation</th>
</tr>
<tr>
<td><a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/LIEF-0.10.1-Linux.tar.gz">SDK</a></td>
<td>
<a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/LIEF-0.10.1-win32.zip">SDK - x86</a>
<br />
<a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/LIEF-0.10.1-win64.zip">SDK - x86-64</a>
</td>
<td><a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/LIEF-0.10.1-Darwin.tar.gz">SDK</a></td>
<td><a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/documentation-0.10.1.tar.gz">Sphinx + Doxygen</a></td>
</tr>
<tr>
<td colspan="3"><p align="center"><a href="https://github.com/lief-project/LIEF/releases/download/0.10.1/">Python</a></p></td>
</tr>
</table>
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
@@ -149,18 +185,27 @@ print(binary)
int main(int argc, char** argv) {
// ELF
if (std::unique_ptr<const LIEF::ELF::Binary> elf = LIEF::ELF::Parser::parse("/bin/ls")) {
std::cout << *elf << '\n';
try {
std::unique_ptr<LIEF::ELF::Binary> elf = LIEF::ELF::Parser::parse("/bin/ls");
std::cout << *elf << std::endl;
} catch (const LIEF::exception& err) {
std::cerr << err.what() << std::endl;
}
// PE
if (std::unique_ptr<const LIEF::PE::Binary> pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe")) {
std::cout << *pe << '\n';
try {
std::unique_ptr<LIEF::PE::Binary> pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe");
std::cout << *pe << std::endl;
} catch (const LIEF::exception& err) {
std::cerr << err.what() << std::endl;
}
// Mach-O
if (std::unique_ptr<LIEF::MachO::FatBinary> macho = LIEF::MachO::Parser::parse("/bin/ls")) {
std::cout << *macho << '\n';
try {
std::unique_ptr<LIEF::MachO::FatBinary> macho = LIEF::MachO::Parser::parse("/bin/ls");
std::cout << *macho << std::endl;
} catch (const LIEF::exception& err) {
std::cerr << err.what() << std::endl;
}
return 0;
@@ -189,15 +234,15 @@ 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
* **Discord**: [LIEF](https://discord.gg/7hRFGWYedu)
* **Mail**: lief at quarkslab com
* **Gitter**: [lief-project](https://gitter.im/lief-project)
## About
@@ -207,18 +252,24 @@ 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.13.0/LICENSE).
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.10.1/LICENSE).
### Bibtex
```bibtex
```latex
@MISC {LIEF,
author = "Romain Thomas",
title = "LIEF - Library to Instrument Executable Formats",
howpublished = "https://lief.quarkslab.com/",
month = "apr",
year = "2017"
month = "April",
year = "2017",
}
```
---------------
<p align="center" >
<img width="40%" src="http://lief.quarkslab.com/resources/QB-big.png"/>
</p>
+6 -10
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
@@ -36,10 +36,11 @@ namespace LIEF {
namespace ELF {
void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->handler = reinterpret_cast<void*>(binary);
c_binary->name = binary->name().c_str();
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)),
@@ -64,12 +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();
if (binary == nullptr) {
return nullptr;
}
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;
@@ -96,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 - 2023 R. Thomas
* Copyright 2017 - 2023 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"
)
+24 -34
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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);
@@ -162,9 +162,9 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
{
c_binary->dynamic_entries[i] =
static_cast<Elf_DynamicEntry_t*>(malloc(sizeof(Elf_DynamicEntry_t)));
c_binary->dynamic_entries[i]->tag = static_cast<uint64_t>(entry.tag());
c_binary->dynamic_entries[i]->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
c_binary->dynamic_entries[i]->value = entry.value();
break;
}
}
}
@@ -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:
{
@@ -208,24 +208,14 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
case DYNAMIC_TAGS::DT_FINI_ARRAY:
case DYNAMIC_TAGS::DT_PREINIT_ARRAY:
{
Elf_DynamicEntry_Array_t* entry_array=reinterpret_cast<Elf_DynamicEntry_Array_t*>(dynamic_entries[idx]);
free(entry_array->array);
free(entry_array);
free(reinterpret_cast<Elf_DynamicEntry_Array_t*>(dynamic_entries[idx]));
break;
}
case DYNAMIC_TAGS::DT_FLAGS:
{
Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast<Elf_DynamicEntry_Flags_t*>(dynamic_entries[idx]);
free(entry_flags->flags);
free(entry_flags);
break;
}
case DYNAMIC_TAGS::DT_FLAGS_1:
{
Elf_DynamicEntry_Flags_t* entry_flags=reinterpret_cast<Elf_DynamicEntry_Flags_t*>(dynamic_entries[idx]);
free(entry_flags->flags_1);
free(entry_flags);
free(reinterpret_cast<Elf_DynamicEntry_Flags_t*>(dynamic_entries[idx]));
break;
}
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
+12 -7
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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,9 +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();
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();
@@ -39,10 +44,9 @@ void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->sections[i]->info = b_section.information();
c_binary->sections[i]->alignment = b_section.alignment();
c_binary->sections[i]->entry_size = b_section.entry_size();
c_binary->sections[i]->content = content;
c_binary->sections[i]->size = section_content.size();
c_binary->sections[i]->entropy = b_section.entropy();
c_binary->sections[i]->content = !section_content.empty() ?
const_cast<uint8_t*>(section_content.data()) : nullptr;
}
c_binary->sections[sections.size()] = nullptr;
@@ -54,6 +58,7 @@ void destroy_sections(Elf_Binary_t* c_binary) {
Elf_Section_t **sections = c_binary->sections;
for (size_t idx = 0; sections[idx] != nullptr; ++idx) {
free(sections[idx]->content);
free(sections[idx]);
}
free(c_binary->sections);
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
+11 -6
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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,13 +20,18 @@ 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();
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),
content);
c_binary->segments[i] = static_cast<Elf_Segment_t*>(malloc(sizeof(Elf_Segment_t)));
c_binary->segments[i]->type = static_cast<enum LIEF_ELF_SEGMENT_TYPES>(segment.type());
@@ -36,8 +41,7 @@ void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->segments[i]->offset = segment.file_offset();
c_binary->segments[i]->alignment = segment.alignment();
c_binary->segments[i]->size = segment_content.size();
c_binary->segments[i]->content = !segment_content.empty() ?
const_cast<uint8_t*>(segment_content.data()) : nullptr;
c_binary->segments[i]->content = content;
}
c_binary->segments[segments.size()] = nullptr;
@@ -50,6 +54,7 @@ void destroy_segments(Elf_Binary_t* c_binary) {
Elf_Segment_t **segments = c_binary->segments;
for (size_t idx = 0; segments[idx] != nullptr; ++idx) {
free(segments[idx]->content);
free(segments[idx]);
}
free(c_binary->segments);
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
@@ -32,6 +32,7 @@ namespace MachO {
void init_c_binary(Macho_Binary_t* c_binary, Binary* binary) {
c_binary->handler = reinterpret_cast<void*>(binary);
c_binary->name = binary->name().c_str();
c_binary->imagebase = binary->imagebase();
init_c_header(c_binary, binary);
init_c_commands(c_binary, binary);
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
+12 -22
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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,28 +24,18 @@
using namespace LIEF::MachO;
Macho_Binary_t** macho_parse(const char *file) {
FatBinary* fat = Parser::parse(file).release();
if (fat == nullptr) {
return nullptr;
FatBinary* macho_binaries = Parser::parse(file).release();
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 < 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);
}
size_t nb_bin = fat->size();
auto** c_macho_binaries = static_cast<Macho_Binary_t**>(
malloc((fat->size() + 1) * sizeof(Macho_Binary_t**)));
for (size_t i = 0; i < nb_bin; ++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);
}
}
fat->release_all_binaries();
c_macho_binaries[nb_bin] = nullptr;
delete fat;
c_macho_binaries[macho_binaries->size()] = nullptr;
return c_macho_binaries;
}
+12 -10
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 -8
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
@@ -34,6 +34,7 @@ namespace LIEF {
namespace PE {
void init_c_binary(Pe_Binary_t* c_binary, Binary* binary) {
c_binary->name = binary->name().c_str();
c_binary->handler = reinterpret_cast<void*>(binary);
init_c_dos_header(c_binary, binary);
@@ -50,12 +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();
if (binary == nullptr) {
return nullptr;
}
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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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,7 +16,7 @@
#ifndef C_LIEF_ELF_H_
#define C_LIEF_ELF_H_
/** @defgroup elf_c_api ELF C API */
//! @defgroup elf_c_api ELF C API
#include "LIEF/ELF/Binary.h"
#include "LIEF/ELF/Symbol.h"
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 -21
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
@@ -34,44 +34,44 @@ extern "C" {
#endif
struct Elf_DynamicEntry_t {
uint64_t tag;
uint64_t value;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
};
struct Elf_DynamicEntry_Library_t {
uint64_t tag;
uint64_t value;
const char* name;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
const char* name;
};
struct Elf_DynamicEntry_SharedObject_t {
uint64_t tag;
uint64_t value;
const char* name;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
const char* name;
};
struct Elf_DynamicEntry_Array_t {
uint64_t tag;
uint64_t value;
uint64_t* array;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
uint64_t* array;
};
struct Elf_DynamicEntry_Rpath_t {
uint64_t tag;
uint64_t value;
const char* rpath;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
const char* rpath;
};
struct Elf_DynamicEntry_RunPath_t {
uint64_t tag;
uint64_t value;
const char* runpath;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
const char* runpath;
};
struct Elf_DynamicEntry_Flags_t {
uint64_t tag;
uint64_t value;
enum LIEF_ELF_DYNAMIC_TAGS tag;
uint64_t value;
enum LIEF_ELF_DYNAMIC_FLAGS *flags;
enum LIEF_ELF_DYNAMIC_FLAGS_1 *flags_1;
};
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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.
@@ -6,11 +6,11 @@
extern "C" {
#endif
#define _LIEF_EN(N) LIEF_ELF_##N
#define _LIEF_EN_2(N, TYPE) LIEF_ELF_##N
#define _LIEF_EI(X) LIEF_ELF_##X
#define _LIEF_EN(N) LIEF_ELF_##N // enum LIEF_N {
#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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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 - 2023 R. Thomas
* Copyright 2017 - 2023 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,7 +16,7 @@
#ifndef C_LIEF_MACHO_H_
#define C_LIEF_MACHO_H_
/** @defgroup macho_c_api MachO C API */
//! @defgroup macho_c_api MachO C API
#include "LIEF/MachO/Binary.h"
#include "LIEF/MachO/Symbol.h"
+4 -3
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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,7 +24,7 @@
* @{
*/
#include <stdint.h>
#include <stddef.h>
#include "LIEF/visibility.h"
@@ -33,6 +33,7 @@
#include "LIEF/MachO/Symbol.h"
#include "LIEF/MachO/Section.h"
#include "LIEF/MachO/Segment.h"
#include "LIEF/MachO/enums.h"
#ifdef __cplusplus
extern "C" {
+2 -2
View File
@@ -1,5 +1,5 @@
/* Copyright 2017 - 2023 R. Thomas
* Copyright 2017 - 2023 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