Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cd66ae9b3 | ||
|
|
555bcdabaa |
+1
-1
@@ -1 +1 @@
|
||||
github: [lief-project]
|
||||
github: [romainthomas]
|
||||
|
||||
@@ -4,6 +4,7 @@ about: You identified a bug or a problem in LIEF
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: romainthomas
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
@@ -22,12 +23,3 @@ A clear and concise description of what you expected to happen (if applicable)
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
|
||||
**NOTICE**
|
||||
|
||||
If the issue does not contain enough information to be reproduced,
|
||||
it will be flagged as [incomplete](https://github.com/lief-project/LIEF/issues?q=is%3Aissue+is%3Aclosed+label%3AIncomplete)
|
||||
and closed.
|
||||
|
||||
**/NOTICE**
|
||||
|
||||
@@ -4,6 +4,6 @@ bucket = "lief"
|
||||
endpoint = "https://s3.fr-par.scw.cloud"
|
||||
|
||||
[lief.deploy]
|
||||
branches = ["main", "master", "deploy", "devel"]
|
||||
main-branches = ["main", "master"]
|
||||
branches = ["master", "deploy", "devel"]
|
||||
main-branches = ["master", "main"]
|
||||
default-dir = "latest"
|
||||
|
||||
+21
-28
@@ -12,18 +12,17 @@ import os
|
||||
import sys
|
||||
import tempfile
|
||||
import tomli
|
||||
import re
|
||||
|
||||
LOG_LEVEL = logging.INFO
|
||||
|
||||
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_KEYWORD = ["release-", "release/"]
|
||||
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-"
|
||||
|
||||
DEFAULT_CONFIG = CONFIG_DIR / "gh-ci.toml"
|
||||
DEFAULT_TEMPLATE = (ASSET_DIR / "index.j2").read_text()
|
||||
@@ -249,31 +248,25 @@ class GithubDeploy:
|
||||
def is_main_branch(self, name: str) -> bool:
|
||||
return name in self._main_branches
|
||||
|
||||
def should_be_deployed(self, branch: str) -> bool:
|
||||
if any(re.match(s, branch) for s in self._branches):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
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)
|
||||
|
||||
branch = GithubDeploy.branch()
|
||||
|
||||
if branch is None:
|
||||
logger.warning("Can't resolve the branch name")
|
||||
sys.exit(1)
|
||||
|
||||
s3dir = self._default_dir
|
||||
|
||||
if not self.should_be_deployed(branch):
|
||||
logger.info("Skipping deployment for branch: %s", branch)
|
||||
return
|
||||
|
||||
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")
|
||||
sys.exit(1)
|
||||
|
||||
logger.info("s3dir: %s", s3dir)
|
||||
self.s3_manager.change_dir(s3dir)
|
||||
for dirname in directories:
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
setuptools
|
||||
boto3
|
||||
requests
|
||||
twine
|
||||
tomli
|
||||
mako
|
||||
wheel
|
||||
@@ -1,5 +1,5 @@
|
||||
name: 'Android'
|
||||
on: push
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
build-sdk:
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
arch: ['arm', 'arm64']
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: android-${{ runner.os }}-${{ matrix.arch }}-${{ steps.get-date.outputs.date }}
|
||||
@@ -36,9 +36,9 @@ jobs:
|
||||
-e CCACHE_DIR=/ccache \
|
||||
-v $GITHUB_WORKSPACE:/work \
|
||||
-v $HOME/.ccache:/ccache \
|
||||
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-sdk-${ARCH}
|
||||
--rm liefproject/android-${ARCH} bash /work/scripts/docker/android-${ARCH}.sh
|
||||
- name: 'Upload Artifact'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: android-sdk-${{ matrix.arch }}
|
||||
path: build/*.tar.gz
|
||||
@@ -48,11 +48,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Display artifacts
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
@@ -1,16 +1,24 @@
|
||||
name: 'iOS'
|
||||
on: push
|
||||
on: workflow_dispatch
|
||||
|
||||
env:
|
||||
python-version: '3.10'
|
||||
|
||||
jobs:
|
||||
ios-sdk:
|
||||
runs-on: macos-13
|
||||
runs-on: macos-11.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ env.python-version }}
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: ${{ env.python-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: |
|
||||
@@ -21,7 +29,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p ~/.ccache
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/.ccache
|
||||
key: ios-${{ runner.os }}-${{ steps.get-date.outputs.date }}
|
||||
@@ -37,7 +45,7 @@ jobs:
|
||||
run: |
|
||||
bash scripts/osx/package_ios.sh
|
||||
- name: 'Upload Artifact'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ios-sdk
|
||||
path: build/*.tar.gz
|
||||
@@ -47,11 +55,11 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
needs: ios-sdk
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Display artifacts
|
||||
@@ -72,8 +80,7 @@ jobs:
|
||||
-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
|
||||
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
name: 'Linux AArch64'
|
||||
on: push
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
linux-sdk:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: linux-aarch64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
|
||||
@@ -24,27 +24,22 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p $RUNNER_TEMP/lief-install
|
||||
mkdir -p $HOME/.ccache
|
||||
|
||||
chmod -R 777 $HOME/.ccache
|
||||
|
||||
docker run --name lief-sdk -u 1001:1001 --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/manylinux2014-aarch64 \
|
||||
bash /src/scripts/docker/linux-sdk-aarch64
|
||||
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@v4
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: linux-aarch64-install
|
||||
path: ${{ runner.temp }}/lief-install
|
||||
@@ -54,9 +49,9 @@ jobs:
|
||||
needs: linux-sdk
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
|
||||
python-version: [3.8, 3.9, '3.10', '3.11']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -65,14 +60,14 @@ jobs:
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}-${{ steps.get-date.outputs.date }}
|
||||
restore-keys: |
|
||||
linux-aarch64-${{ runner.os }}-${{ matrix.python-version }}
|
||||
- name: Download LIEF install dir
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: linux-aarch64-install
|
||||
path: ${{ runner.temp }}/lief-install
|
||||
@@ -81,25 +76,20 @@ jobs:
|
||||
env:
|
||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
run: |
|
||||
mkdir -p $HOME/.ccache
|
||||
chmod -R 777 $HOME/.ccache
|
||||
|
||||
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
|
||||
PYTHON_BINARY="/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}"
|
||||
docker run -u 1001:1001 --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=$PYTHON_BINARY \
|
||||
-v $GITHUB_WORKSPACE:/src \
|
||||
-v $HOME/.ccache:/ccache \
|
||||
-v $RUNNER_TEMP/lief-install:/install \
|
||||
liefproject/manylinux2014-aarch64 \
|
||||
bash /src/scripts/docker/linux-py-aarch64
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: linux-aarch64-python${{ matrix.python-version }}-wheel
|
||||
path: dist/*.whl
|
||||
@@ -109,14 +99,12 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
needs: [linux-sdk, wheels]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: linux-aarch64-*
|
||||
merge-multiple: true
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Display artifacts
|
||||
run: ls -R
|
||||
@@ -136,7 +124,6 @@ jobs:
|
||||
-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
|
||||
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
name: 'Linux x86-64'
|
||||
on: push
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
linux-sdk:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: liefproject/manylinux_2_28_x86_64
|
||||
env:
|
||||
CCACHE_DIR: "/home/pylief/.ccache"
|
||||
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libstdc++ -static-libgcc"
|
||||
CFLAGS: "-ffunction-sections -fdata-sections -static-libstdc++ -static-libgcc"
|
||||
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
|
||||
BUILD_DIR_STATIC: "/tmp/build/linux-x86-64/static-release"
|
||||
BUILD_DIR_SHARED: "/tmp/build/linux-x86-64/shared-release"
|
||||
CLICOLOR_FORCE: "1"
|
||||
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
|
||||
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
|
||||
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
|
||||
options: --user 1001:1001
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -27,74 +13,42 @@ jobs:
|
||||
run: |
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: Prepare ccache
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /home/pylief/.ccache/tmp
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /home/pylief/.ccache
|
||||
path: ~/.ccache
|
||||
key: linux-x86-64-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
|
||||
restore-keys: |
|
||||
linux-x86-64-${{ runner.os }}-sdk
|
||||
- name: CMake - Static
|
||||
- name: Build SDK
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ${BUILD_DIR_STATIC}
|
||||
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_STATIC} -GNinja \
|
||||
-DCMAKE_LINK_WHAT_YOU_USE=on \
|
||||
-DBUILD_SHARED_LIBS=off \
|
||||
-DLIEF_INSTALL_COMPILED_EXAMPLES=on \
|
||||
-DCMAKE_INSTALL_PREFIX=/install \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
- name: Compile - Static
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build ${BUILD_DIR_STATIC} --target install
|
||||
- name: CMake - Shared
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ${BUILD_DIR_SHARED}
|
||||
cmake -S $GITHUB_WORKSPACE -B ${BUILD_DIR_SHARED} -GNinja \
|
||||
-DCMAKE_LINK_WHAT_YOU_USE=on \
|
||||
-DBUILD_SHARED_LIBS=on \
|
||||
-DLIEF_INSTALL_COMPILED_EXAMPLES=off \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
- name: Compile - Shared
|
||||
run: |
|
||||
cmake --build ${BUILD_DIR_SHARED} --target all
|
||||
- name: Package
|
||||
run: |
|
||||
cd /tmp/build/linux-x86-64
|
||||
cpack --config $GITHUB_WORKSPACE/cmake/cpack.config.cmake
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: linux-x86-64-sdk
|
||||
path: /tmp/build/linux-x86-64/*.tar.gz
|
||||
path: build/*.tar.gz
|
||||
retention-days: 3
|
||||
- name: 'Upload Install Artifact'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: linux-x86-64-install
|
||||
path: /install
|
||||
path: ${{ runner.temp }}/lief-install
|
||||
retention-days: 1
|
||||
testing:
|
||||
if: "!contains(github.event.commits[0].message, '[skip-test]')"
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: liefproject/manylinux_2_28_x86_64
|
||||
env:
|
||||
PYTHON_BINARY: "/opt/python/cp38-cp38/bin/python3.8"
|
||||
LIEF_SAMPLES_DIR: "/tmp/samples"
|
||||
LIEF_BUILD_DIR: "/tmp/lief-build"
|
||||
LIEF_VENV: "/tmp/venv"
|
||||
CLICOLOR_FORCE: "1"
|
||||
PYTEST_ADDOPTS: "--color=yes"
|
||||
options: --user 1001:1001
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -103,90 +57,35 @@ jobs:
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
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: Prepare Python virtual env
|
||||
- name: Python 3.8 -- Wheel & Test
|
||||
shell: bash
|
||||
env:
|
||||
PYTHON_VERSION: 38
|
||||
run: |
|
||||
$PYTHON_BINARY -m venv ${LIEF_VENV}
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
python -m pip install \
|
||||
-r tests/requirements.txt \
|
||||
-r api/python/build-requirements.txt
|
||||
- name: Build & install LIEF
|
||||
shell: bash
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
export PYLIEF_CONF="${GITHUB_WORKSPACE}/scripts/docker/config/pylinux-test-x64.toml"
|
||||
python -m pip -vvv install api/python
|
||||
- name: Prepare test samples
|
||||
shell: bash
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
mkdir -p ${LIEF_SAMPLES_DIR}
|
||||
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
|
||||
- name: Run tests
|
||||
timeout-minutes: 5
|
||||
shell: bash
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
python tests/run_pytest.py
|
||||
python tests/run_tools_check.py ${LIEF_BUILD_DIR}/
|
||||
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
|
||||
- name: Fuzzing [ls x86-64]
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
|
||||
python tests/elf/fuzzing.py \
|
||||
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
|
||||
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_ls.bin -n 100
|
||||
- name: Fuzzing [openssl x86-64]
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
|
||||
python tests/elf/fuzzing.py \
|
||||
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
|
||||
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_openssl.bin -n 100
|
||||
- name: Fuzzing [nm x86-64]
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
run: |
|
||||
source ${LIEF_VENV}/bin/activate
|
||||
export PYTHONPATH="${GITHUB_WORKSPACE}/tests:$PYTHONPATH"
|
||||
python tests/elf/fuzzing.py \
|
||||
${LIEF_BUILD_DIR}/tests/Melkor/src/MELKOR/melkor \
|
||||
--input-seed ${LIEF_SAMPLES_DIR}/ELF/ELF64_x86-64_binary_nm.bin -n 100
|
||||
|
||||
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
|
||||
container:
|
||||
image: liefproject/manylinux_2_28_x86_64
|
||||
env:
|
||||
CCACHE_DIR: "/home/pylief/.ccache"
|
||||
CXXFLAGS: "-ffunction-sections -fdata-sections -fvisibility-inlines-hidden -static-libgcc"
|
||||
CFLAGS: "-ffunction-sections -fdata-sections -static-libgcc"
|
||||
LDFLAGS: "-Wl,--gc-sections -Wl,--exclude-libs,ALL"
|
||||
CLICOLOR_FORCE: "1"
|
||||
FORCE_COLOR: "1"
|
||||
LIEF_BUILD_DIR: "/tmp/lief-build"
|
||||
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
|
||||
ACTIONS_RUNTIME_TOKEN: "${{ env.ACTIONS_RUNTIME_TOKEN }}"
|
||||
ACTIONS_CACHE_URL: "${{ env.ACTIONS_CACHE_URL }}"
|
||||
options: --user 1001:1001
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
|
||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get Date
|
||||
@@ -194,42 +93,37 @@ jobs:
|
||||
run: |
|
||||
echo "date=$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: Prepare ccache
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /home/pylief/.ccache/tmp
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /home/pylief/.ccache
|
||||
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@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: linux-x86-64-install
|
||||
path: /install
|
||||
- name: Generate wheel
|
||||
path: ${{ runner.temp }}/lief-install
|
||||
- name: Python ${{ matrix.python-version }} -- Wheel
|
||||
shell: bash
|
||||
env:
|
||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
shell: bash
|
||||
run: |
|
||||
export PYLIEF_CONF=$GITHUB_WORKSPACE/scripts/docker/config/pylinux-x64.toml
|
||||
PYTHON_VERSION_ALT=$(echo "${PYTHON_VERSION}" | sed 's/\.//') # Transform 3.8 -> 38
|
||||
PYTHON_BINARY=/opt/python/cp${PYTHON_VERSION_ALT}-cp${PYTHON_VERSION_ALT}/bin/python${PYTHON_VERSION}
|
||||
$PYTHON_BINARY -m pip -vvv wheel --disable-pip-version-check \
|
||||
--wheel-dir=$GITHUB_WORKSPACE/wheel_stage \
|
||||
$GITHUB_WORKSPACE/api/python
|
||||
- name: Run auditwheel
|
||||
shell: bash
|
||||
run: |
|
||||
ls -alh $GITHUB_WORKSPACE/wheel_stage
|
||||
find $GITHUB_WORKSPACE/wheel_stage -exec \
|
||||
auditwheel repair -w $GITHUB_WORKSPACE/dist {} \;
|
||||
ls -alh $GITHUB_WORKSPACE/dist
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: linux-x86-64-python${{ matrix.python-version }}-wheel
|
||||
path: dist/*.whl
|
||||
@@ -239,14 +133,12 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
needs: [linux-sdk, pywheels]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: linux-x86-64-*
|
||||
merge-multiple: true
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Display artifacts
|
||||
run: ls -R
|
||||
@@ -266,5 +158,20 @@ jobs:
|
||||
-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
|
||||
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:
|
||||
- name: Trigger documentation
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
curl --request POST --url ${CIRCLE_CI_URL} \
|
||||
--header "Circle-Token: ${CIRCLE_CI_TOKEN}" \
|
||||
--header 'content-type: application/json' \
|
||||
--data '{"parameters":{"lief-branch":"master"}}'
|
||||
|
||||
+38
-45
@@ -1,14 +1,14 @@
|
||||
name: 'macOS'
|
||||
on: push
|
||||
on: workflow_dispatch
|
||||
|
||||
env:
|
||||
python-test-version: '3.10'
|
||||
|
||||
jobs:
|
||||
osx-sdk:
|
||||
runs-on: macos-13
|
||||
runs-on: macos-11.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install system dependencies
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $RUNNER_TEMP/.ccache
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/.ccache
|
||||
key: osx-${{ runner.os }}-sdk-${{ steps.get-date.outputs.date }}
|
||||
@@ -33,7 +33,6 @@ jobs:
|
||||
- name: Build SDK
|
||||
shell: bash
|
||||
env:
|
||||
CLICOLOR_FORCE: "1"
|
||||
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
||||
CCACHE_DIR: ${{ runner.temp }}/.ccache
|
||||
CCACHE_MAXSIZE: 10.0G
|
||||
@@ -42,37 +41,38 @@ jobs:
|
||||
run: |
|
||||
bash scripts/osx/package_sdk.sh
|
||||
- name: 'Upload SDK Artifact'
|
||||
uses: actions/upload-artifact@v4
|
||||
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@v4
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: osx-x64-install
|
||||
path: install/x64
|
||||
retention-days: 1
|
||||
osx-testing:
|
||||
runs-on: macos-13
|
||||
runs-on: macos-11.0
|
||||
if: "!contains(github.event.commits[0].message, '[skip-test]')"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ env.python-test-version }}
|
||||
uses: actions/setup-python@v5
|
||||
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: |
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $RUNNER_TEMP/.ccache
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/.ccache
|
||||
key: osx-${{ runner.os }}-test-${{ steps.get-date.outputs.date }}
|
||||
@@ -92,16 +92,12 @@ jobs:
|
||||
- name: Upgrade pip
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip setuptools
|
||||
- name: Build Python 3.10 with tests
|
||||
shell: bash
|
||||
env:
|
||||
LIEF_SAMPLES_DIR: "/tmp/samples"
|
||||
LIEF_BUILD_DIR: "/tmp/lief-build"
|
||||
PYLIEF_CONF: "${{ github.workspace }}/scripts/osx/osx-testing-x64.toml"
|
||||
CLICOLOR_FORCE: "1"
|
||||
PYTEST_ADDOPTS: "--color=yes"
|
||||
FORCE_COLOR: "1"
|
||||
BUILD_DIR: "/tmp/lief-build"
|
||||
MACOSX_TARGET: "11.7"
|
||||
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
||||
CCACHE_DIR: ${{ runner.temp }}/.ccache
|
||||
@@ -110,39 +106,37 @@ jobs:
|
||||
CCACHE_COMPRESS: 1
|
||||
run: |
|
||||
python -m pip install -r tests/requirements.txt
|
||||
python -m pip -vvv install api/python
|
||||
python tests/dl_samples.py ${LIEF_SAMPLES_DIR}
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
LIEF_SAMPLES_DIR: "/tmp/samples"
|
||||
LIEF_BUILD_DIR: "/tmp/lief-build"
|
||||
PYTEST_ADDOPTS: "--color=yes"
|
||||
run: |
|
||||
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 ${LIEF_BUILD_DIR}/
|
||||
ctest --output-on-failure --test-dir ${LIEF_BUILD_DIR}/
|
||||
python tests/run_tools_check.py ${BUILD_DIR}/temp
|
||||
ctest --output-on-failure --test-dir ${BUILD_DIR}/temp
|
||||
wheels:
|
||||
runs-on: macos-13
|
||||
runs-on: macos-11.0
|
||||
needs: osx-sdk
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13.0-rc.1']
|
||||
python-version: [3.8, 3.9, '3.10', '3.11']
|
||||
arch: ['x64', 'arm64']
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
brew install cmake ninja ccache
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
- name: Get Date
|
||||
id: get-date
|
||||
run: |
|
||||
@@ -153,14 +147,18 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $RUNNER_TEMP/.ccache
|
||||
- name: ccache cache files
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ runner.temp }}/.ccache
|
||||
key: osx-${{ runner.os }}-${{ matrix.arch }}-${{ 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@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: osx-${{ matrix.arch }}-install
|
||||
path: ~/lief-${{ matrix.arch }}-install
|
||||
@@ -168,8 +166,6 @@ jobs:
|
||||
shell: bash
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
||||
FORCE_COLOR: "1"
|
||||
CLICOLOR_FORCE: "1"
|
||||
CCACHE_DIR: ${{ runner.temp }}/.ccache
|
||||
CCACHE_MAXSIZE: 10.0G
|
||||
CCACHE_CPP2: 1
|
||||
@@ -178,7 +174,7 @@ jobs:
|
||||
run: |
|
||||
python -m pip -vv wheel --wheel-dir=dist/ api/python
|
||||
- name: 'Upload Python wheel artifact - ${{ matrix.python-version }}'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: osx-wheel-${{ matrix.arch }}-${{ matrix.python-version }}
|
||||
path: dist/*.whl
|
||||
@@ -188,14 +184,12 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
needs: [osx-sdk, wheels]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: osx-*
|
||||
merge-multiple: true
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Display artifacts
|
||||
run: ls -R
|
||||
@@ -215,7 +209,6 @@ jobs:
|
||||
-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
|
||||
liefproject/deploy python3 /src/.github/deploy.py /runner_tmp/artifacts
|
||||
|
||||
|
||||
|
||||
+31
-24
@@ -9,34 +9,39 @@ jobs:
|
||||
osx:
|
||||
runs-on: macos-11.0
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
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
|
||||
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"
|
||||
LIEF_BUILD_DIR: "/tmp/lief-build"
|
||||
PYLIEF_CONF: "${{ github.workspace }}/scripts/osx/osx-testing-x64.toml"
|
||||
BUILD_DIR: "/tmp/lief-build"
|
||||
run: |
|
||||
python -m pip install -r tests/requirements.txt
|
||||
python -m pip install -e api/python
|
||||
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}
|
||||
ctest --output-on-failure --test-dir ${BUILD_DIR}
|
||||
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@v4
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Build & Test
|
||||
@@ -44,46 +49,48 @@ jobs:
|
||||
env:
|
||||
PYTHON_VERSION: 39
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e PYTHON_VERSION=$PYTHON_VERSION \
|
||||
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/test-linux-x64
|
||||
-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@v4
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ env.python-win-version }}
|
||||
uses: actions/setup-python@v5
|
||||
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
|
||||
python -m pip install --upgrade pip setuptools
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: "2022"
|
||||
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 ("LIEF_BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $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 }}
|
||||
shell: cmd
|
||||
run: |
|
||||
python -m pip install -r tests/requirements.txt
|
||||
python -m pip install api/python
|
||||
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
|
||||
- name: Run tests
|
||||
timeout-minutes: 20
|
||||
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%
|
||||
ctest --output-on-failure --test-dir %BUILD_DIR%/temp/Release
|
||||
shell: cmd
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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
|
||||
@@ -1,13 +1,5 @@
|
||||
name: LIEF Windows
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'master'
|
||||
- 'release-**'
|
||||
- 'release/**'
|
||||
tags:
|
||||
- '**'
|
||||
on: workflow_dispatch
|
||||
|
||||
env:
|
||||
python-test-version: '3.10'
|
||||
@@ -15,7 +7,7 @@ env:
|
||||
|
||||
jobs:
|
||||
build-sdk:
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
arch: ['x64', 'x86']
|
||||
@@ -24,11 +16,11 @@ jobs:
|
||||
SCCACHE_CACHE_SIZE: 2G
|
||||
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.python-version }}
|
||||
architecture: ${{ matrix.arch }}
|
||||
@@ -38,14 +30,14 @@ jobs:
|
||||
choco install sccache
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: "2022"
|
||||
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@v4
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: ${{ vars.SCCACHE_DIR }}
|
||||
@@ -58,13 +50,13 @@ jobs:
|
||||
run: |
|
||||
python ./scripts/windows/package_sdk.py
|
||||
- name: 'Upload SDK artifact'
|
||||
uses: actions/upload-artifact@v4
|
||||
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@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: windows-${{ matrix.arch }}-install
|
||||
path: ${{ runner.temp }}/lief-install
|
||||
@@ -74,7 +66,7 @@ jobs:
|
||||
- name: stop sccache server
|
||||
run: sccache --stop-server || true
|
||||
tests:
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-2019
|
||||
if: "!contains(github.event.commits[0].message, '[skip-test]')"
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -84,11 +76,11 @@ jobs:
|
||||
SCCACHE_CACHE_SIZE: 2G
|
||||
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ env.python-test-version }}
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.python-test-version }}
|
||||
architecture: ${{ matrix.arch }}
|
||||
@@ -98,14 +90,14 @@ jobs:
|
||||
choco install sccache
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: "2022"
|
||||
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@v4
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: ${{ vars.SCCACHE_DIR }}
|
||||
@@ -129,46 +121,44 @@ jobs:
|
||||
run: |
|
||||
chcp 65001 #set code page to utf-8
|
||||
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
|
||||
echo ("LIEF_BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
|
||||
echo ("BUILD_DIR=" + $env:RUNNER_TEMP + "/lief-build") >> $env:GITHUB_ENV
|
||||
- name: Build Python ${{ env.python-test-version }}
|
||||
shell: cmd
|
||||
run: |
|
||||
python -m pip install -r tests/requirements.txt
|
||||
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
|
||||
python -m pip -vvv install --user api/python
|
||||
- name: Download samples
|
||||
cd api/python
|
||||
python ./setup.py build ^
|
||||
--build-base=%BUILD_DIR%/base ^
|
||||
--build-temp=%BUILD_DIR%/temp ^
|
||||
install --user
|
||||
shell: cmd
|
||||
run: |
|
||||
python -m pip install -r tests/requirements.txt
|
||||
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
|
||||
- name: Run tests
|
||||
timeout-minutes: 20
|
||||
shell: cmd
|
||||
run: |
|
||||
cd %GITHUB_WORKSPACE%
|
||||
python tests/run_pytest.py
|
||||
ctest --output-on-failure --test-dir %LIEF_BUILD_DIR%/
|
||||
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-2022
|
||||
runs-on: windows-2019
|
||||
needs: build-sdk
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13.0-beta.2']
|
||||
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@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
architecture: ${{ matrix.arch }}
|
||||
@@ -176,17 +166,17 @@ jobs:
|
||||
run: |
|
||||
choco install ninja
|
||||
choco install sccache
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: "2022"
|
||||
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@v4
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: ${{ vars.SCCACHE_DIR }}
|
||||
@@ -194,12 +184,16 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.arch }}-sccache-${{ matrix.python-version }}
|
||||
- name: Download LIEF install dir
|
||||
uses: actions/download-artifact@v4
|
||||
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: |
|
||||
@@ -216,10 +210,10 @@ jobs:
|
||||
chcp 65001 #set code page to utf-8
|
||||
- name: Build Python ${{ matrix.python-version }}
|
||||
run: |
|
||||
python -m pip -vvv wheel --wheel-dir=dist/ ./api/python
|
||||
python -m pip -vv wheel --wheel-dir=dist/ api/python
|
||||
shell: cmd
|
||||
- name: 'Upload Python artifacts [${{ matrix.python-version }}]'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: windows-${{ matrix.arch }}-wheel-${{ matrix.python-version }}
|
||||
path: dist/*.whl
|
||||
@@ -229,14 +223,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-sdk, wheels]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: windows-*
|
||||
merge-multiple: true
|
||||
path: ${{ runner.temp }}/artifacts
|
||||
- name: Deploy
|
||||
env:
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
name: LIEF Windows Quick
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
- '!master'
|
||||
- '!main'
|
||||
- '!release-**'
|
||||
- '!release/**'
|
||||
tags-ignore:
|
||||
- "**"
|
||||
on: workflow_dispatch
|
||||
|
||||
env:
|
||||
python-version: '3.12'
|
||||
python-version: '3.9'
|
||||
|
||||
jobs:
|
||||
quick-test:
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x64, x86]
|
||||
@@ -24,11 +15,11 @@ jobs:
|
||||
SCCACHE_CACHE_SIZE: 2G
|
||||
SCCACHE_DIR: ${{ vars.SCCACHE_DIR }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ env.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.python-version }}
|
||||
architecture: ${{ matrix.python-version }}
|
||||
@@ -36,17 +27,17 @@ jobs:
|
||||
run: |
|
||||
choco install ninja
|
||||
choco install sccache
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: "2022"
|
||||
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@v4
|
||||
uses: actions/cache@v3
|
||||
continue-on-error: false
|
||||
with:
|
||||
path: ${{ vars.SCCACHE_DIR }}
|
||||
@@ -59,20 +50,20 @@ jobs:
|
||||
run: |
|
||||
chcp 65001 #set code page to utf-8
|
||||
echo ("LIEF_SAMPLES_DIR=" + $env:RUNNER_TEMP + "/samples") >> $env:GITHUB_ENV
|
||||
- name: Build Python ${{ env.python-version }}
|
||||
- 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 -m pip -vvv install api/python
|
||||
- name: Download samples
|
||||
shell: cmd
|
||||
run: |
|
||||
python tests/dl_samples.py %LIEF_SAMPLES_DIR%
|
||||
- name: Run tests
|
||||
python -m pip -vv install api/python
|
||||
shell: cmd
|
||||
timeout-minutes: 20
|
||||
- name: Run tests
|
||||
run: |
|
||||
python ./tests/run_pytest.py
|
||||
shell: cmd
|
||||
- name: sccache stats
|
||||
run: sccache --show-stats
|
||||
- name: sccache server
|
||||
|
||||
@@ -3,6 +3,3 @@ build/
|
||||
*.whl
|
||||
lief.egg-info/
|
||||
dist/
|
||||
api/rust/cargo/target/*
|
||||
api/rust/examples/target/*
|
||||
Cargo.lock
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
include:
|
||||
- project: 'LIEF/ci'
|
||||
ref: main
|
||||
file: 'main.yml'
|
||||
+275
-97
@@ -1,8 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(LIEF LANGUAGES C CXX)
|
||||
|
||||
enable_language(C)
|
||||
enable_language(CXX)
|
||||
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")
|
||||
@@ -22,38 +18,56 @@ include(CheckCCompilerFlag)
|
||||
include(ExternalProject)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
find_package(Git)
|
||||
if (DEFINED ENV{LIEF_VERSION_ENV})
|
||||
string(REGEX MATCHALL "([0-9]+)" VERSION_STRING "$ENV{LIEF_VERSION_ENV}")
|
||||
if (NOT VERSION_STRING)
|
||||
message(FATAL_ERROR "Invalid version")
|
||||
endif()
|
||||
list(GET VERSION_STRING 0 LIEF_VERSION_MAJOR)
|
||||
list(GET VERSION_STRING 1 LIEF_VERSION_MINOR)
|
||||
list(GET VERSION_STRING 2 LIEF_VERSION_PATCH)
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
|
||||
AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" AND Git_FOUND)
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
|
||||
AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
# Information from git
|
||||
# ====================
|
||||
include(LIEFGit)
|
||||
else()
|
||||
set(LIEF_VERSION_MAJOR "0")
|
||||
set(LIEF_VERSION_MINOR "16")
|
||||
set(LIEF_VERSION_PATCH "4")
|
||||
endif()
|
||||
|
||||
if (DEFINED ENV{LIEF_COMMIT})
|
||||
set(LIEF_COMMIT_HASH "$ENV{LIEF_COMMIT}")
|
||||
endif()
|
||||
|
||||
if (DEFINED ENV{LIEF_BRANCH})
|
||||
set(LIEF_GIT_BRANCH "$ENV{LIEF_BRANCH}")
|
||||
set(LIEF_VERSION_MINOR "14")
|
||||
set(LIEF_VERSION_PATCH "0")
|
||||
endif()
|
||||
|
||||
# LIEF Project
|
||||
# ============
|
||||
project(LIEF VERSION
|
||||
${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
|
||||
project(
|
||||
LIEF
|
||||
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)
|
||||
@@ -97,8 +111,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS "CMAKE_CXX_LINK_EXECUTABLE: ${CMAKE_CXX_LINK_EXECUTABLE}")
|
||||
message(STATUS "CMAKE_CXX_LINK_FLAGS: ${CMAKE_CXX_LINK_FLAGS}")
|
||||
@@ -111,60 +123,131 @@ message(STATUS "CMAKE_LINK_LIBRARY_FILE_FLAG: ${CMAKE_LINK_LIBRARY_FILE_FLA
|
||||
message(STATUS "CMAKE_LINK_INTERFACE_LIBRARIES: ${CMAKE_LINK_INTERFACE_LIBRARIES}")
|
||||
message(STATUS "CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}")
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
|
||||
|
||||
if(LIEF_INSTALL)
|
||||
if(UNIX)
|
||||
include(GNUInstallDirs)
|
||||
set(CMAKE_INSTALL_LIBDIR "lib")
|
||||
else()
|
||||
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 to: ${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# LIEF Source definition
|
||||
# ======================
|
||||
add_library(LIB_LIEF src/Object.cpp)
|
||||
add_subdirectory(src)
|
||||
|
||||
set(LIEF_PRIVATE_INCLUDE_DIR)
|
||||
set(LIEF_PUBLIC_INCLUDE_DIR)
|
||||
|
||||
set(LIEF_PUBLIC_INCLUDE_FILES)
|
||||
set(LIEF_PRIVATE_INCLUDE_FILES)
|
||||
|
||||
set(LIBLIEF_SOURCE_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/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")
|
||||
|
||||
# Grouping basic headers together
|
||||
# ===============================
|
||||
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/iostream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iterators.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/LIEF.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/logging.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/MachO.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/PE.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/types.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visibility.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Object.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Visitor.hpp"
|
||||
"${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"
|
||||
)
|
||||
|
||||
set(LIEF_VISITOR_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/hash.hpp")
|
||||
|
||||
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")
|
||||
|
||||
if(LIEF_ENABLE_JSON)
|
||||
list(APPEND LIBLIEF_SOURCE_FILES "${LIEF_JSON_SRC}")
|
||||
list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}")
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${LIEF_INC_FILES})
|
||||
source_group("Source Files" FILES ${LIBLIEF_SOURCE_FILES})
|
||||
|
||||
source_group("Header Files\\visitors" FILES ${LIEF_VISITOR_INCLUDE_FILES})
|
||||
|
||||
add_library(LIB_LIEF ${LIBLIEF_SOURCE_FILES} ${LIEF_INCLUDE_FILES})
|
||||
|
||||
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_files} PROPERTIES GENERATED TRUE)
|
||||
target_sources(LIB_LIEF PRIVATE ${mbedtls_src_files})
|
||||
target_compile_definitions(LIB_LIEF PRIVATE -DMBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
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}")
|
||||
|
||||
target_include_directories(LIB_LIEF SYSTEM PRIVATE
|
||||
${MBEDTLS_INCLUDE_DIRS}
|
||||
"${MBEDTLS_SOURCE_DIR}/library"
|
||||
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)
|
||||
MbedTLS::mbedcrypto
|
||||
MbedTLS::mbedx509)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(LIB_LIEF PRIVATE
|
||||
-DMBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_SOURCE_DIR}/config/mbedtls/config.h"
|
||||
)
|
||||
|
||||
if(WIN32 AND BUILD_SHARED_LIBS)
|
||||
target_link_libraries(LIB_LIEF PRIVATE ws2_32)
|
||||
if(WINDOWS AND BUILD_SHARED_LIBS)
|
||||
target_link_libraries(LIB_LIEF ws2_32)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/bigobj)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug AND WINDOWS)
|
||||
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0 -D_SECURE_SCL=0
|
||||
-D_HAS_ITERATOR_DEBUGGING=0)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug AND UNIX)
|
||||
target_compile_options(LIB_LIEF PRIVATE -g -O0)
|
||||
endif()
|
||||
@@ -175,18 +258,39 @@ else()
|
||||
target_compile_definitions(LIB_LIEF PRIVATE -DLIEF_STATIC)
|
||||
endif()
|
||||
|
||||
# Abstract part
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/Abstract/CMakeLists.txt")
|
||||
|
||||
if(LIEF_ENABLE_JSON)
|
||||
# Make nlohmann/json is only using C++11 API.
|
||||
# Especially, MSVC[14.37.32822] is buggy with (no)rtti & std::any
|
||||
# Ref:
|
||||
# - https://github.com/nlohmann/json/issues/3900
|
||||
# - https://github.com/microsoft/STL/issues/4349#issuecomment-1920093172
|
||||
target_compile_definitions(LIB_LIEF PRIVATE JSON_HAS_CPP_11)
|
||||
# ELF Part
|
||||
# ========
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/ELF/CMakeLists.txt")
|
||||
if(LIEF_ELF)
|
||||
set(ENABLE_ELF_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_ELF_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# PE Part
|
||||
# =======
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/PE/CMakeLists.txt")
|
||||
if(LIEF_PE)
|
||||
set(ENABLE_PE_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_PE_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# MachO part
|
||||
# ==========
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/MachO/CMakeLists.txt")
|
||||
if(LIEF_MACHO)
|
||||
set(ENABLE_MACHO_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_MACHO_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# Logging Configuration
|
||||
# =====================
|
||||
|
||||
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||
SPDLOG_NO_EXCEPTIONS
|
||||
SPDLOG_FUNCTION=)
|
||||
@@ -195,6 +299,47 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_NO_THREAD_ID)
|
||||
endif()
|
||||
|
||||
|
||||
# OAT part
|
||||
# ========
|
||||
if(LIEF_OAT)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/OAT/CMakeLists.txt)
|
||||
set(ENABLE_OAT_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_OAT_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# DEX part
|
||||
# ========
|
||||
if(LIEF_DEX)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/DEX/CMakeLists.txt)
|
||||
set(ENABLE_DEX_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_DEX_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# VDEX part
|
||||
# =========
|
||||
if(LIEF_VDEX)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/VDEX/CMakeLists.txt)
|
||||
set(ENABLE_VDEX_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_VDEX_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# ART part
|
||||
# ========
|
||||
if(LIEF_ART)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/ART/CMakeLists.txt)
|
||||
set(ENABLE_ART_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_ART_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# Platforms
|
||||
# =========
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/CMakeLists.txt)
|
||||
|
||||
# LIEF includes
|
||||
# =============
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
|
||||
@@ -203,18 +348,16 @@ 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)
|
||||
|
||||
set(LIEF_PUBLIC_INCLUDE_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/
|
||||
${CMAKE_CURRENT_BINARY_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/")
|
||||
|
||||
set(LIEF_PRIVATE_INCLUDE_DIR
|
||||
${LIEF_PUBLIC_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
|
||||
@ONLY)
|
||||
|
||||
target_include_directories(LIB_LIEF
|
||||
PUBLIC "$<BUILD_INTERFACE:${LIEF_PUBLIC_INCLUDE_DIR}>"
|
||||
@@ -239,7 +382,6 @@ if(LIEF_ENABLE_JSON)
|
||||
target_include_directories(LIB_LIEF PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/)
|
||||
endif()
|
||||
target_compile_definitions(LIB_LIEF PRIVATE JSON_NOEXCEPTION)
|
||||
endif()
|
||||
|
||||
if(LIEF_FROZEN_ENABLED)
|
||||
@@ -281,7 +423,7 @@ endif()
|
||||
|
||||
if(LIEF_OPT_UTFCPP_EXTERNAL)
|
||||
find_package(utf8cpp REQUIRED)
|
||||
target_link_libraries(LIB_LIEF PRIVATE utf8cpp::utf8cpp)
|
||||
target_link_libraries(LIB_LIEF PRIVATE utf8cpp)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/internal/utfcpp/utf8.h
|
||||
COMMAND
|
||||
@@ -320,23 +462,28 @@ endif()
|
||||
|
||||
target_link_libraries(LIB_LIEF PRIVATE lief_spdlog)
|
||||
|
||||
if(ANDROID AND LIEF_LOGGING)
|
||||
if(ANDROID AND BUILD_SHARED_LIBS AND LIEF_LOGGING)
|
||||
target_link_libraries(LIB_LIEF PUBLIC log)
|
||||
endif()
|
||||
|
||||
# Flags definition
|
||||
# ----------------
|
||||
set_target_properties(LIB_LIEF
|
||||
|
||||
# cmake-format: off
|
||||
set_target_properties(
|
||||
LIB_LIEF
|
||||
PROPERTIES POSITION_INDEPENDENT_CODE ON
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
VISIBILITY_INLINES_HIDDEN ON
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
C_VISIBILITY_PRESET hidden)
|
||||
# cmake-format: on
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
set_property(TARGET LIB_LIEF APPEND
|
||||
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
set_property(
|
||||
TARGET LIB_LIEF
|
||||
APPEND
|
||||
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
|
||||
@@ -392,7 +539,7 @@ endif()
|
||||
if(LIEF_SANITIZER)
|
||||
message("LIEF Sanitizer enabled: ${SANITIZER_FLAGS}")
|
||||
target_compile_options(LIB_LIEF PUBLIC ${SANITIZER_FLAGS})
|
||||
add_subdirectory(tests/sanitizer)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/sanitizer")
|
||||
endif()
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -406,13 +553,13 @@ if(LIEF_FUZZING)
|
||||
|
||||
target_compile_options(LIB_LIEF PRIVATE ${FUZZING_FLAGS})
|
||||
target_link_libraries(LIB_LIEF PUBLIC asan pthread)
|
||||
add_subdirectory(fuzzing)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/fuzzing")
|
||||
endif()
|
||||
|
||||
include(LIEFCompilerFlags)
|
||||
|
||||
if(LIEF_PROFILING)
|
||||
add_subdirectory(profiling)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profiling")
|
||||
endif()
|
||||
|
||||
set_target_properties(LIB_LIEF PROPERTIES
|
||||
@@ -439,22 +586,30 @@ if(APPLE)
|
||||
set_target_properties(LIB_LIEF PROPERTIES MACOSX_RPATH ON)
|
||||
endif()
|
||||
|
||||
add_subdirectory(api)
|
||||
# API
|
||||
# ======================
|
||||
include(LIEFApi)
|
||||
|
||||
# Examples
|
||||
# ======================
|
||||
if(LIEF_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
||||
endif()
|
||||
|
||||
# Tests
|
||||
# ======================
|
||||
|
||||
if(LIEF_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
endif()
|
||||
|
||||
# Documentation
|
||||
# ======================
|
||||
if(LIEF_DOC)
|
||||
add_subdirectory(doc)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc)
|
||||
endif()
|
||||
|
||||
|
||||
# Post-build operations
|
||||
# ======================
|
||||
if(BUILD_SHARED_LIBS AND CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
@@ -483,8 +638,10 @@ if(LIEF_INSTALL)
|
||||
|
||||
# Find Package Config
|
||||
# ======================
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake @ONLY)
|
||||
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
|
||||
@@ -506,6 +663,25 @@ if(LIEF_INSTALL)
|
||||
endif()
|
||||
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
|
||||
@@ -524,7 +700,7 @@ if(LIEF_INSTALL)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LIEF
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
|
||||
COMPONENT config)
|
||||
|
||||
install(
|
||||
@@ -541,7 +717,7 @@ if(LIEF_INSTALL)
|
||||
install(
|
||||
EXPORT LIEFExport
|
||||
NAMESPACE LIEF::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LIEF
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/LIEF/cmake
|
||||
FILE LIEFExport-${lib_type}.cmake
|
||||
COMPONENT config)
|
||||
|
||||
@@ -550,5 +726,7 @@ if(LIEF_INSTALL)
|
||||
NAMESPACE LIEF::
|
||||
FILE LIEFExport-${lib_type}.cmake)
|
||||
|
||||
add_subdirectory(package)
|
||||
# Package
|
||||
# ======================
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package")
|
||||
endif()
|
||||
|
||||
@@ -186,8 +186,8 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2017 - 2024 R. Thomas
|
||||
Copyright 2017 - 2024 Quarkslab
|
||||
Copyright 2017 - 2023 R. Thomas
|
||||
Copyright 2017 - 2023 Quarkslab
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
<p align="center" >
|
||||
<img width="90%" src="https://github.com/lief-project/LIEF/blob/main/.github/images/architecture.png"/><br />
|
||||
<img width="90%" src="https://github.com/lief-project/LIEF/blob/master/.github/images/architecture.png"/><br />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/jGQtyAYChJ">
|
||||
<a href="https://discord.gg/7hRFGWYedu">
|
||||
<img src="https://img.shields.io/discord/1117013848914931762">
|
||||
</a>
|
||||
|
||||
<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=main&label=Linux%20x86-64&logo=github">
|
||||
<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>
|
||||
|
||||
<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=main&label=Linux%20AArch64&logo=github">
|
||||
<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>
|
||||
|
||||
<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=main&label=Android&logo=github">
|
||||
<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>
|
||||
|
||||
<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=main&label=macOS&logo=github">
|
||||
<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>
|
||||
|
||||
<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=main&label=iOS&logo=github">
|
||||
<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>
|
||||
|
||||
<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=main&label=Windows&logo=github">
|
||||
<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>
|
||||
|
||||
<a href="https://github.com/lief-project/LIEF/releases">
|
||||
@@ -38,40 +38,27 @@
|
||||
<a href="https://twitter.com/LIEF_project">
|
||||
<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/lief_project">
|
||||
</a>
|
||||
|
||||
<a href="https://gurubase.io/g/lief">
|
||||
<img src="https://img.shields.io/badge/Gurubase-Ask%20LIEF%20Guru-006BFF">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<p align="center">
|
||||
<a href="https://lief.re/blog/"><b>Blog</b></a> •
|
||||
<a href="https://lief.re/doc/latest/index.html"><b>Documentation</b></a> •
|
||||
<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 to parse,
|
||||
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**:
|
||||
Main features:
|
||||
|
||||
* **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides an user-friendly API to access to internals.
|
||||
* **Modify**: LIEF can use to modify some parts of these formats (adding a section, changing a symbol's name, ...)
|
||||
* **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides an user-friendly API to access to format internals.
|
||||
* **Modify**: LIEF enables to modify some parts of these formats
|
||||
* **Abstract**: Three formats have common features like sections, symbols, entry point... LIEF factors them.
|
||||
* **API**: LIEF can be used in C++, Python, Rust and C
|
||||
|
||||
**Extended features**:
|
||||
|
||||
* [**DWARF/PDB** Support](https://lief.re/doc/latest/extended/debug_info/index.html)
|
||||
* [**Objective-C** Metadata](https://lief.re/doc/latest/extended/objc/index.html)
|
||||
* [**Dyld Shared Cache**](https://lief.re/doc/latest/extended/dsc/index.html) with support for extracting Dylib
|
||||
* [**Disassembler**](https://lief.re/doc/latest/extended/disassembler/index.html): AArch64, x86/x86-64, ARM, RISC-V, Mips, PowerPC, eBPF
|
||||
* [**Assembler**](https://lief.re/doc/latest/extended/assembler/index.html): AArch64, x86/x86-64
|
||||
|
||||
* **API**: LIEF can be used in C, C++ and Python
|
||||
|
||||
# Content
|
||||
|
||||
@@ -79,23 +66,22 @@ modify and abstract ELF, PE and MachO formats.
|
||||
- [Download / Install](#downloads--install)
|
||||
- [Getting started](#getting-started)
|
||||
- [Documentation](#documentation)
|
||||
- [Rust](https://lief.re/doc/stable/rust/lief/)
|
||||
- [Sphinx](https://lief.re/doc/latest/index.html)
|
||||
- [Doxygen](https://lief.re/doc/latest/doxygen/index.html)
|
||||
- [Sphinx](https://lief-project.github.io/doc/stable/index.html)
|
||||
- [Doxygen](https://lief-project.github.io/doc/latest/doxygen/index.html)
|
||||
- Tutorials:
|
||||
- [Parse and manipulate formats](https://lief.re/doc/latest/tutorials/01_play_with_formats.html)
|
||||
- [Create a PE from scratch](https://lief.re/doc/latest/tutorials/02_pe_from_scratch.html)
|
||||
- [Play with ELF symbols](https://lief.re/doc/latest/tutorials/03_elf_change_symbols.html)
|
||||
- [ELF Hooking](https://lief.re/doc/latest/tutorials/04_elf_hooking.html)
|
||||
- [Infecting the plt/got](https://lief.re/doc/latest/tutorials/05_elf_infect_plt_got.html)
|
||||
- [PE Hooking](https://lief.re/doc/latest/tutorials/06_pe_hooking.html)
|
||||
- [PE Resources](https://lief.re/doc/latest/tutorials/07_pe_resource.html)
|
||||
- [Transforming an ELF executable into a library](https://lief.re/doc/latest/tutorials/08_elf_bin2lib.html)
|
||||
- [How to use frida on a non-rooted device](https://lief.re/doc/latest/tutorials/09_frida_lief.html)
|
||||
- [Android formats](https://lief.re/doc/latest/tutorials/10_android_formats.html)
|
||||
- [Mach-O modification](https://lief.re/doc/latest/tutorials/11_macho_modification.html)
|
||||
- [ELF Coredump](https://lief.re/doc/latest/tutorials/12_elf_coredump.html)
|
||||
- [PE Authenticode](https://lief.re/doc/latest/tutorials/13_pe_authenticode.html)
|
||||
- [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)
|
||||
- [Contact](#contact)
|
||||
- [About](#about)
|
||||
- [Authors](#authors)
|
||||
@@ -104,27 +90,12 @@ modify and abstract ELF, PE and MachO formats.
|
||||
|
||||
## Downloads / Install
|
||||
|
||||
## C++
|
||||
First, make sure to have an updated version of setuptools:
|
||||
|
||||
```cmake
|
||||
find_package(LIEF REQUIRED)
|
||||
target_link_libraries(my-project LIEF::LIEF)
|
||||
```console
|
||||
pip install setuptools --upgrade
|
||||
```
|
||||
|
||||
## Rust
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "my-awesome-project"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
lief = "0.16.4"
|
||||
```
|
||||
|
||||
## Python
|
||||
|
||||
To install the latest **version** (release):
|
||||
|
||||
```console
|
||||
@@ -134,23 +105,22 @@ pip install lief
|
||||
To install nightly build:
|
||||
|
||||
```console
|
||||
pip install [--user] --force-reinstall --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==0.17.0.dev0
|
||||
pip install [--user] --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief==0.14.0.dev0
|
||||
```
|
||||
|
||||
### Packages
|
||||
|
||||
- LIEF Extended: https://extended.lief.re (GitHub OAuth)
|
||||
- **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.16.4**: https://github.com/lief-project/LIEF/releases/tag/0.16.4
|
||||
- **v0.13.2**: https://github.com/lief-project/LIEF/releases/tag/0.13.2
|
||||
|
||||
Here are guides to install or integrate LIEF:
|
||||
|
||||
* [Python](https://lief.re/doc/latest/installation.html#python)
|
||||
* [Visual Studio](https://lief.re/doc/latest/installation.html#visual-studio-integration)
|
||||
* [XCode](https://lief.re/doc/latest/installation.html#xcode-integration)
|
||||
* [CMake](https://lief.re/doc/latest/installation.html#cmake-integration)
|
||||
* [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)
|
||||
|
||||
## Getting started
|
||||
|
||||
@@ -161,34 +131,15 @@ import lief
|
||||
|
||||
# ELF
|
||||
binary = lief.parse("/usr/bin/ls")
|
||||
for section in binary.sections:
|
||||
print(section.name, section.virtual_address)
|
||||
print(binary)
|
||||
|
||||
# PE
|
||||
binary = lief.parse("C:\\Windows\\explorer.exe")
|
||||
|
||||
if rheader := pe.rich_header:
|
||||
print(rheader.key)
|
||||
print(binary)
|
||||
|
||||
# Mach-O
|
||||
binary = lief.parse("/usr/bin/ls")
|
||||
for fixup in binary.dyld_chained_fixups:
|
||||
print(fixup)
|
||||
```
|
||||
|
||||
### Rust
|
||||
|
||||
```rust
|
||||
use lief::Binary;
|
||||
use lief::pe::debug::Entries::CodeViewPDB;
|
||||
|
||||
if let Some(Binary::PE(pe)) = Binary::parse(path.as_str()) {
|
||||
for entry in pe.debug() {
|
||||
if let CodeViewPDB(pdb_view) = entry {
|
||||
println!("{}", pdb_view.filename());
|
||||
}
|
||||
}
|
||||
}
|
||||
print(binary)
|
||||
```
|
||||
|
||||
### C++
|
||||
@@ -199,23 +150,17 @@ if let Some(Binary::PE(pe)) = Binary::parse(path.as_str()) {
|
||||
int main(int argc, char** argv) {
|
||||
// ELF
|
||||
if (std::unique_ptr<const LIEF::ELF::Binary> elf = LIEF::ELF::Parser::parse("/bin/ls")) {
|
||||
for (const LIEF::ELF::Section& section : elf->sections()) {
|
||||
std::cout << section->name() << ' ' << section->virtual_address() << '\n';
|
||||
}
|
||||
std::cout << *elf << '\n';
|
||||
}
|
||||
|
||||
// PE
|
||||
if (std::unique_ptr<const LIEF::PE::Binary> pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe")) {
|
||||
if (const LIEF::PE::RichHeader* rheader : pe->rich_header()) {
|
||||
std::cout << rheader->key() << '\n';
|
||||
}
|
||||
std::cout << *pe << '\n';
|
||||
}
|
||||
|
||||
// Mach-O
|
||||
if (std::unique_ptr<LIEF::MachO::FatBinary> macho = LIEF::MachO::Parser::parse("/bin/ls")) {
|
||||
for (const LIEF::MachO::DyldChainedFixups& fixup : macho->dyld_chained_fixups()) {
|
||||
std::cout << fixup << '\n';
|
||||
}
|
||||
std::cout << *macho << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -244,9 +189,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
## Documentation
|
||||
|
||||
* [Main documentation](https://lief.re/doc/latest/index.html)
|
||||
* [Doxygen](https://lief.re/doc/latest/doxygen/index.html)
|
||||
* [Rust](https://lief.re/doc/stable/rust/lief/)
|
||||
* [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)
|
||||
|
||||
## Contact
|
||||
|
||||
@@ -257,11 +203,11 @@ int main(int argc, char** argv) {
|
||||
|
||||
### Authors
|
||||
|
||||
Romain Thomas ([@rh0main](https://www.romainthomas.fr/)) - [Quarkslab](https://www.quarkslab.com)
|
||||
Romain Thomas ([@rh0main](https://twitter.com/rh0main)) - [Quarkslab](https://www.quarkslab.com)
|
||||
|
||||
### License
|
||||
|
||||
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.16.4/LICENSE).
|
||||
LIEF is provided under the [Apache 2.0 license](https://github.com/lief-project/LIEF/blob/0.13.0/LICENSE).
|
||||
|
||||
### Bibtex
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
if (LIEF_PYTHON_API)
|
||||
add_subdirectory(python)
|
||||
endif()
|
||||
|
||||
if(LIEF_C_API)
|
||||
add_subdirectory(c)
|
||||
endif()
|
||||
|
||||
if(LIEF_RUST_API)
|
||||
add_subdirectory(rust)
|
||||
endif()
|
||||
|
||||
+26
-9
@@ -1,15 +1,32 @@
|
||||
if(LIEF_ELF)
|
||||
add_subdirectory(ELF)
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
set(LIEF_C_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/LIEF.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/logging.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/types.h"
|
||||
)
|
||||
|
||||
set(LIEF_C_SRC "${CMAKE_CURRENT_LIST_DIR}/logging.cpp")
|
||||
|
||||
if (LIEF_ELF)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ELF/CMakeLists.txt")
|
||||
endif()
|
||||
|
||||
if(LIEF_PE)
|
||||
add_subdirectory(PE)
|
||||
if (LIEF_PE)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/PE/CMakeLists.txt")
|
||||
endif()
|
||||
|
||||
if(LIEF_MACHO)
|
||||
add_subdirectory(MachO)
|
||||
if (LIEF_MACHO)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/MachO/CMakeLists.txt")
|
||||
endif()
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE logging.cpp)
|
||||
target_include_directories(LIB_LIEF PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
|
||||
source_group("Header Files\\C API" FILES ${LIEF_C_INCLUDE_FILES})
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE "${LIEF_C_SRC}" ${LIEF_C_INCLUDE_FILES})
|
||||
|
||||
|
||||
+11
-8
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ namespace LIEF {
|
||||
namespace ELF {
|
||||
void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
c_binary->handler = reinterpret_cast<void*>(binary);
|
||||
c_binary->type = static_cast<uint32_t>(binary->type());
|
||||
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();
|
||||
@@ -48,12 +48,15 @@ void init_c_binary(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
reinterpret_cast<char*>(const_cast<char*>(c_binary->interpreter))[interp.size()] = '\0';
|
||||
}
|
||||
|
||||
|
||||
init_c_header(c_binary, binary);
|
||||
init_c_sections(c_binary, binary);
|
||||
init_c_segments(c_binary, binary);
|
||||
init_c_dynamic_symbols(c_binary, binary);
|
||||
init_c_symtab_symbols(c_binary, binary);
|
||||
init_c_static_symbols(c_binary, binary);
|
||||
init_c_dynamic_entries(c_binary, binary);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,9 +81,9 @@ Elf_Binary_t* elf_parse(const char *file) {
|
||||
int elf_binary_save_header(Elf_Binary_t* binary) {
|
||||
Header& hdr = reinterpret_cast<Binary*>(binary->handler)->header();
|
||||
|
||||
hdr.file_type(LIEF::ELF::Header::FILE_TYPE(binary->header.file_type));
|
||||
hdr.machine_type(LIEF::ELF::ARCH(binary->header.machine_type));
|
||||
hdr.object_file_version(LIEF::ELF::Header::VERSION(binary->header.object_file_version));
|
||||
hdr.file_type(static_cast<LIEF::ELF::E_TYPE>(binary->header.file_type));
|
||||
hdr.machine_type(static_cast<LIEF::ELF::ARCH>(binary->header.machine_type));
|
||||
hdr.object_file_version(static_cast<LIEF::ELF::VERSION>(binary->header.object_file_version));
|
||||
hdr.program_headers_offset(binary->header.program_headers_offset);
|
||||
hdr.section_headers_offset(binary->header.section_headers_offset);
|
||||
hdr.processor_flag(binary->header.processor_flags);
|
||||
@@ -101,7 +104,7 @@ void elf_binary_destroy(Elf_Binary_t* binary) {
|
||||
destroy_sections(binary);
|
||||
destroy_segments(binary);
|
||||
destroy_dynamic_symbols(binary);
|
||||
destroy_symtab_symbols(binary);
|
||||
destroy_static_symbols(binary);
|
||||
destroy_dynamic_entries(binary);
|
||||
|
||||
if (binary->interpreter != nullptr) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,9 +1,44 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Symbol.cpp
|
||||
Section.cpp
|
||||
Segment.cpp
|
||||
DynamicEntry.cpp
|
||||
Header.cpp
|
||||
Binary.cpp
|
||||
utils.cpp
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
set(LIEF_C_ELF_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/utils.cpp"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_API_C_ELF_INCLUDE_FILES_CPP
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
|
||||
)
|
||||
|
||||
set(LIEF_API_C_ELF_INCLUDE_FILES_C
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Binary.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/DynamicEntry.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/EnumToString.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/ELF/Header.h"
|
||||
"${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_SOURCE_DIR}/api/c/include/LIEF/ELF/utils.h"
|
||||
)
|
||||
|
||||
set(LIEF_C_ELF_INC "${LIEF_API_C_ELF_INCLUDE_FILES_C}" "${LIEF_API_C_ELF_INCLUDE_FILES_CPP}")
|
||||
|
||||
source_group("Source Files\\C API\\ELF" FILES ${LIEF_API_C_ELF_SRC})
|
||||
source_group("Header Files\\C API\\ELF" FILES ${LIEF_C_ELF_INC})
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE "${LIEF_C_ELF_SRC}" "${LIEF_C_ELF_INC}")
|
||||
|
||||
+59
-30
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,12 +34,13 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
for (size_t i = 0; i < dyn_entries.size(); ++i) {
|
||||
DynamicEntry& entry = dyn_entries[i];
|
||||
switch(entry.tag()) {
|
||||
case DynamicEntry::TAG::NEEDED:
|
||||
case DYNAMIC_TAGS::DT_NEEDED:
|
||||
{
|
||||
|
||||
auto* e = static_cast<Elf_DynamicEntry_Library_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_Library_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
|
||||
e->value = entry.value();
|
||||
e->name = reinterpret_cast<DynamicEntryLibrary*>(&entry)->name().c_str();
|
||||
|
||||
@@ -47,12 +48,12 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::SONAME:
|
||||
case DYNAMIC_TAGS::DT_SONAME:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_SharedObject_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_SharedObject_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
|
||||
e->value = entry.value();
|
||||
e->name = reinterpret_cast<DynamicSharedObject*>(&entry)->name().c_str();
|
||||
|
||||
@@ -60,42 +61,42 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::RPATH:
|
||||
case DYNAMIC_TAGS::DT_RPATH:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_Rpath_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_Rpath_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
|
||||
e->value = entry.value();
|
||||
e->rpath = reinterpret_cast<DynamicEntryRpath*>(&entry)->rpath().c_str();
|
||||
e->rpath = reinterpret_cast<DynamicEntryRpath*>(&entry)->name().c_str();
|
||||
|
||||
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::RUNPATH:
|
||||
case DYNAMIC_TAGS::DT_RUNPATH:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_RunPath_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_RunPath_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
e->tag = static_cast<enum LIEF_ELF_DYNAMIC_TAGS>(entry.tag());
|
||||
e->value = entry.value();
|
||||
e->runpath = reinterpret_cast<DynamicEntryRunPath*>(&entry)->runpath().c_str();
|
||||
e->runpath = reinterpret_cast<DynamicEntryRunPath*>(&entry)->name().c_str();
|
||||
|
||||
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::INIT_ARRAY:
|
||||
case DynamicEntry::TAG::FINI_ARRAY:
|
||||
case DynamicEntry::TAG::PREINIT_ARRAY:
|
||||
case DYNAMIC_TAGS::DT_INIT_ARRAY:
|
||||
case DYNAMIC_TAGS::DT_FINI_ARRAY:
|
||||
case DYNAMIC_TAGS::DT_PREINIT_ARRAY:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_Array_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_Array_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
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();
|
||||
e->array = static_cast<uint64_t*>(malloc((array.size() + 1) * sizeof(uint64_t)));
|
||||
@@ -108,33 +109,55 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::FLAGS:
|
||||
case DYNAMIC_TAGS::DT_FLAGS:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
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();
|
||||
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);
|
||||
|
||||
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
|
||||
e->flags[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS>(*it);
|
||||
}
|
||||
|
||||
e->flags[flags.size()] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS>(0);
|
||||
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::FLAGS_1:
|
||||
case DYNAMIC_TAGS::DT_FLAGS_1:
|
||||
{
|
||||
auto* e = static_cast<Elf_DynamicEntry_Flags_t*>(
|
||||
malloc(sizeof(Elf_DynamicEntry_Flags_t)));
|
||||
|
||||
e->tag = static_cast<uint64_t>(entry.tag());
|
||||
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();
|
||||
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);
|
||||
|
||||
for (size_t i = 0; it != std::end(flags); ++i, ++it) {
|
||||
e->flags_1[i] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1>(*it);
|
||||
}
|
||||
|
||||
e->flags_1[flags.size()] = static_cast<enum LIEF_ELF_DYNAMIC_FLAGS_1>(0);
|
||||
c_binary->dynamic_entries[i] = reinterpret_cast<Elf_DynamicEntry_t*>(e);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
c_binary->dynamic_entries[i] =
|
||||
@@ -147,6 +170,7 @@ void init_c_dynamic_entries(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
}
|
||||
|
||||
c_binary->dynamic_entries[dyn_entries.size()] = nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -155,34 +179,34 @@ 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) {
|
||||
switch(DynamicEntry::TAG(dynamic_entries[idx]->tag)) {
|
||||
case DynamicEntry::TAG::NEEDED:
|
||||
switch(static_cast<DYNAMIC_TAGS>(dynamic_entries[idx]->tag)) {
|
||||
case DYNAMIC_TAGS::DT_NEEDED:
|
||||
{
|
||||
free(reinterpret_cast<Elf_DynamicEntry_Library_t*>(dynamic_entries[idx]));
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::SONAME:
|
||||
case DYNAMIC_TAGS::DT_SONAME:
|
||||
{
|
||||
free(reinterpret_cast<Elf_DynamicEntry_SharedObject_t*>(dynamic_entries[idx]));
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::RPATH:
|
||||
case DYNAMIC_TAGS::DT_RPATH:
|
||||
{
|
||||
free(reinterpret_cast<Elf_DynamicEntry_Rpath_t*>(dynamic_entries[idx]));
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::RUNPATH:
|
||||
case DYNAMIC_TAGS::DT_RUNPATH:
|
||||
{
|
||||
free(reinterpret_cast<Elf_DynamicEntry_RunPath_t*>(dynamic_entries[idx]));
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::INIT_ARRAY:
|
||||
case DynamicEntry::TAG::FINI_ARRAY:
|
||||
case DynamicEntry::TAG::PREINIT_ARRAY:
|
||||
case DYNAMIC_TAGS::DT_INIT_ARRAY:
|
||||
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);
|
||||
@@ -190,21 +214,24 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
|
||||
break;
|
||||
}
|
||||
|
||||
case DynamicEntry::TAG::FLAGS:
|
||||
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 DynamicEntry::TAG::FLAGS_1:
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
free(dynamic_entries[idx]);
|
||||
}
|
||||
|
||||
@@ -217,3 +244,5 @@ void destroy_dynamic_entries(Elf_Binary_t* c_binary) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "LIEF/ELF/EnumToString.h"
|
||||
#include "LIEF/ELF/EnumToString.hpp"
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
#include "LIEF/ELF/enums.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
const char* E_TYPE_to_string(enum LIEF_ELF_E_TYPE e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::E_TYPE>(e));
|
||||
}
|
||||
|
||||
const char* SYMBOL_BINDINGS_to_string(enum LIEF_ELF_SYMBOL_BINDINGS e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SYMBOL_BINDINGS>(e));
|
||||
}
|
||||
|
||||
const char* VERSION_to_string(enum LIEF_ELF_VERSION e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::VERSION>(e));
|
||||
}
|
||||
|
||||
const char* ARCH_to_string(enum LIEF_ELF_ARCH e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ARCH>(e));
|
||||
}
|
||||
|
||||
const char* SEGMENT_TYPES_to_string(enum LIEF_ELF_SEGMENT_TYPES e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::SEGMENT_TYPES>(e));
|
||||
}
|
||||
|
||||
const char* DYNAMIC_TAGS_to_string(enum LIEF_ELF_DYNAMIC_TAGS e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_TAGS>(e));
|
||||
}
|
||||
|
||||
const char* ELF_SECTION_TYPES_to_string(enum LIEF_ELF_ELF_SECTION_TYPES e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_TYPES>(e));
|
||||
}
|
||||
|
||||
const char* ELF_SECTION_FLAGS_to_string(enum LIEF_ELF_ELF_SECTION_FLAGS e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SECTION_FLAGS>(e));
|
||||
}
|
||||
|
||||
const char* ELF_SYMBOL_TYPES_to_string(enum LIEF_ELF_ELF_SYMBOL_TYPES e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_SYMBOL_TYPES>(e));
|
||||
}
|
||||
|
||||
const char* ELF_CLASS_to_string(enum LIEF_ELF_ELF_CLASS e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_CLASS>(e));
|
||||
}
|
||||
|
||||
const char* ELF_DATA_to_string(enum LIEF_ELF_ELF_DATA e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::ELF_DATA>(e));
|
||||
}
|
||||
|
||||
const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::OS_ABI>(e));
|
||||
}
|
||||
|
||||
const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_FLAGS>(e));
|
||||
}
|
||||
|
||||
const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e) {
|
||||
return LIEF::ELF::to_string(static_cast<LIEF::ELF::DYNAMIC_FLAGS_1>(e));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,9 +21,9 @@ namespace ELF {
|
||||
void init_c_header(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
|
||||
const Header& hdr = binary->header();
|
||||
c_binary->header.file_type = static_cast<uint32_t>(hdr.file_type());
|
||||
c_binary->header.machine_type = static_cast<uint32_t>(hdr.machine_type());
|
||||
c_binary->header.object_file_version = static_cast<uint32_t>(hdr.object_file_version());
|
||||
c_binary->header.file_type = static_cast<enum LIEF_ELF_E_TYPE>(hdr.file_type());
|
||||
c_binary->header.machine_type = static_cast<enum LIEF_ELF_ARCH>(hdr.machine_type());
|
||||
c_binary->header.object_file_version = static_cast<enum LIEF_ELF_VERSION>(hdr.object_file_version());
|
||||
c_binary->header.program_headers_offset = hdr.program_headers_offset();
|
||||
c_binary->header.section_headers_offset = hdr.section_headers_offset();
|
||||
c_binary->header.processor_flags = hdr.processor_flag();
|
||||
@@ -35,7 +35,10 @@ void init_c_header(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
c_binary->header.name_string_table_idx = hdr.section_name_table_idx();
|
||||
c_binary->header.entrypoint = hdr.entrypoint();
|
||||
const Header::identity_t& ident = hdr.identity();
|
||||
std::copy(std::begin(ident), std::end(ident), c_binary->header.identity);
|
||||
std::copy(
|
||||
std::begin(ident),
|
||||
std::end(ident),
|
||||
c_binary->header.identity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ void init_c_sections(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
|
||||
c_binary->sections[i]->name = b_section.fullname().c_str();
|
||||
c_binary->sections[i]->flags = b_section.flags();
|
||||
c_binary->sections[i]->type = static_cast<uint32_t>(b_section.type());
|
||||
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();
|
||||
c_binary->sections[i]->offset = b_section.file_offset();
|
||||
c_binary->sections[i]->original_size = b_section.original_size();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
span<const uint8_t> segment_content = segment.content();
|
||||
|
||||
c_binary->segments[i] = static_cast<Elf_Segment_t*>(malloc(sizeof(Elf_Segment_t)));
|
||||
c_binary->segments[i]->type = static_cast<uint32_t>(segment.type());
|
||||
c_binary->segments[i]->type = static_cast<enum LIEF_ELF_SEGMENT_TYPES>(segment.type());
|
||||
c_binary->segments[i]->flags = static_cast<uint32_t>(segment.flags());
|
||||
c_binary->segments[i]->virtual_address = segment.virtual_address();
|
||||
c_binary->segments[i]->virtual_size = segment.virtual_size();
|
||||
@@ -44,7 +44,10 @@ void init_c_segments(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
+26
-24
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,8 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
Symbol& b_sym = dyn_symb[i];
|
||||
c_binary->dynamic_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
|
||||
c_binary->dynamic_symbols[i]->name = b_sym.name().c_str();
|
||||
c_binary->dynamic_symbols[i]->type = static_cast<uint32_t>(b_sym.type());
|
||||
c_binary->dynamic_symbols[i]->binding = static_cast<uint32_t>(b_sym.binding());
|
||||
c_binary->dynamic_symbols[i]->type = static_cast<enum LIEF_ELF_ELF_SYMBOL_TYPES>(b_sym.type());
|
||||
c_binary->dynamic_symbols[i]->binding = static_cast<enum LIEF_ELF_SYMBOL_BINDINGS>(b_sym.binding());
|
||||
c_binary->dynamic_symbols[i]->other = b_sym.other();
|
||||
c_binary->dynamic_symbols[i]->shndx = b_sym.shndx();
|
||||
c_binary->dynamic_symbols[i]->value = b_sym.value();
|
||||
@@ -40,30 +40,32 @@ void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
}
|
||||
c_binary->dynamic_symbols[dyn_symb.size()] = nullptr;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_c_symtab_symbols(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
Binary::it_symtab_symbols static_symb = binary->symtab_symbols();
|
||||
void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary) {
|
||||
Binary::it_static_symbols static_symb = binary->static_symbols();
|
||||
|
||||
c_binary->symtab_symbols = static_cast<Elf_Symbol_t**>(
|
||||
c_binary->static_symbols = static_cast<Elf_Symbol_t**>(
|
||||
malloc((static_symb.size() + 1) * sizeof(Elf_Symbol_t**)));
|
||||
|
||||
for (size_t i = 0; i < static_symb.size(); ++i) {
|
||||
Symbol& b_sym = static_symb[i];
|
||||
c_binary->symtab_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
|
||||
c_binary->symtab_symbols[i]->name = b_sym.name().c_str();
|
||||
c_binary->symtab_symbols[i]->type = static_cast<uint32_t>(b_sym.type());
|
||||
c_binary->symtab_symbols[i]->binding = static_cast<uint32_t>(b_sym.binding());
|
||||
c_binary->symtab_symbols[i]->other = b_sym.other();
|
||||
c_binary->symtab_symbols[i]->shndx = b_sym.shndx();
|
||||
c_binary->symtab_symbols[i]->value = b_sym.value();
|
||||
c_binary->symtab_symbols[i]->size = b_sym.size();
|
||||
c_binary->symtab_symbols[i]->information = b_sym.information();
|
||||
c_binary->symtab_symbols[i]->is_exported = b_sym.is_exported();
|
||||
c_binary->symtab_symbols[i]->is_imported = b_sym.is_imported();
|
||||
c_binary->static_symbols[i] = static_cast<Elf_Symbol_t*>(malloc(sizeof(Elf_Symbol_t)));
|
||||
c_binary->static_symbols[i]->name = b_sym.name().c_str();
|
||||
c_binary->static_symbols[i]->type = static_cast<enum LIEF_ELF_ELF_SYMBOL_TYPES>(b_sym.type());
|
||||
c_binary->static_symbols[i]->binding = static_cast<enum LIEF_ELF_SYMBOL_BINDINGS>(b_sym.binding());
|
||||
c_binary->static_symbols[i]->other = b_sym.other();
|
||||
c_binary->static_symbols[i]->shndx = b_sym.shndx();
|
||||
c_binary->static_symbols[i]->value = b_sym.value();
|
||||
c_binary->static_symbols[i]->size = b_sym.size();
|
||||
c_binary->static_symbols[i]->information = b_sym.information();
|
||||
c_binary->static_symbols[i]->is_exported = b_sym.is_exported();
|
||||
c_binary->static_symbols[i]->is_imported = b_sym.is_imported();
|
||||
}
|
||||
c_binary->symtab_symbols[static_symb.size()] = nullptr;
|
||||
c_binary->static_symbols[static_symb.size()] = nullptr;
|
||||
|
||||
}
|
||||
|
||||
@@ -78,12 +80,12 @@ void destroy_dynamic_symbols(Elf_Binary_t* c_binary) {
|
||||
}
|
||||
|
||||
|
||||
void destroy_symtab_symbols(Elf_Binary_t* c_binary) {
|
||||
Elf_Symbol_t **symtab_symbols = c_binary->symtab_symbols;
|
||||
for (size_t idx = 0; symtab_symbols[idx] != nullptr; ++idx) {
|
||||
free(symtab_symbols[idx]);
|
||||
void destroy_static_symbols(Elf_Binary_t* c_binary) {
|
||||
Elf_Symbol_t **static_symbols = c_binary->static_symbols;
|
||||
for (size_t idx = 0; static_symbols[idx] != nullptr; ++idx) {
|
||||
free(static_symbols[idx]);
|
||||
}
|
||||
free(c_binary->symtab_symbols);
|
||||
free(c_binary->static_symbols);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,10 +26,10 @@ namespace LIEF {
|
||||
namespace ELF {
|
||||
|
||||
void init_c_dynamic_symbols(Elf_Binary_t* c_binary, Binary* binary);
|
||||
void init_c_symtab_symbols(Elf_Binary_t* c_binary, Binary* binary);
|
||||
void init_c_static_symbols(Elf_Binary_t* c_binary, Binary* binary);
|
||||
|
||||
void destroy_dynamic_symbols(Elf_Binary_t* c_binary);
|
||||
void destroy_symtab_symbols(Elf_Binary_t* c_binary);
|
||||
void destroy_static_symbols(Elf_Binary_t* c_binary);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,9 +1,45 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Parser.cpp
|
||||
LoadCommand.cpp
|
||||
Segment.cpp
|
||||
Symbol.cpp
|
||||
Section.cpp
|
||||
Header.cpp
|
||||
Binary.cpp
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
set(LIEF_API_C_MACHO_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Parser.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_API_C_MACHO_INCLUDE_FILES_CPP
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/LoadCommand.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Segment.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.hpp"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_API_C_MACHO_INCLUDE_FILES_C
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/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"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/LoadCommand.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Section.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Segment.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/MachO/Symbol.h"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_C_MACHO_INC "${LIEF_API_C_MACHO_INCLUDE_FILES_C}" "${LIEF_API_C_MACHO_INCLUDE_FILES_CPP}")
|
||||
|
||||
source_group("Source Files\\C API\\MachO" FILES ${LIEF_API_C_MACHO_SRC})
|
||||
source_group("Header Files\\C API\\MachO" FILES ${LIEF_C_MACHO_INC})
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_MACHO_SRC}" ${LIEF_C_MACHO_INC})
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "LIEF/MachO/EnumToString.h"
|
||||
#include "LIEF/MachO/EnumToString.hpp"
|
||||
|
||||
#include "LIEF/MachO/enums.hpp"
|
||||
#include "LIEF/MachO/enums.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
const char* LOAD_COMMAND_TYPES_to_string(enum LIEF_MACHO_LOAD_COMMAND_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::LOAD_COMMAND_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* MACHO_TYPES_to_string(enum LIEF_MACHO_MACHO_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* FILE_TYPES_to_string(enum LIEF_MACHO_FILE_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::FILE_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* CPU_TYPES_to_string(enum LIEF_MACHO_CPU_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::CPU_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* HEADER_FLAGS_to_string(enum LIEF_MACHO_HEADER_FLAGS e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::HEADER_FLAGS>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* MACHO_SECTION_TYPES_to_string(enum LIEF_MACHO_MACHO_SECTION_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SECTION_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* MACHO_SYMBOL_TYPES_to_string(enum LIEF_MACHO_MACHO_SYMBOL_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::MACHO_SYMBOL_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* N_LIST_TYPES_to_string(enum LIEF_MACHO_N_LIST_TYPES e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::N_LIST_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* SYMBOL_DESCRIPTIONS_to_string(enum LIEF_MACHO_SYMBOL_DESCRIPTIONS e) {
|
||||
return LIEF::MachO::to_string(static_cast<LIEF::MachO::SYMBOL_DESCRIPTIONS>(e));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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 @@ void init_c_commands(Macho_Binary_t* c_binary, Binary* binary) {
|
||||
LoadCommand& cmd = commands[i];
|
||||
|
||||
c_binary->commands[i] = static_cast<Macho_Command_t*>(malloc(sizeof(Macho_Command_t)));
|
||||
const span<const uint8_t> cmd_content = cmd.data();
|
||||
const std::vector<uint8_t>& cmd_content = cmd.data();
|
||||
auto* content = static_cast<uint8_t*>(malloc(cmd_content.size() * sizeof(uint8_t)));
|
||||
std::copy(
|
||||
std::begin(cmd_content),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
|
||||
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();
|
||||
c_binary->sections[i]->flags = section.raw_flags();
|
||||
c_binary->sections[i]->flags = section.flags();
|
||||
c_binary->sections[i]->type = static_cast<enum LIEF_MACHO_MACHO_SECTION_TYPES>(section.type());
|
||||
c_binary->sections[i]->reserved1 = section.reserved1();
|
||||
c_binary->sections[i]->reserved2 = section.reserved2();
|
||||
@@ -53,6 +53,7 @@ void init_c_sections(Macho_Binary_t* c_binary, Binary* binary) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroy_sections(Macho_Binary_t* c_binary) {
|
||||
Macho_Section_t **sections = c_binary->sections;
|
||||
for (size_t idx = 0; sections[idx] != nullptr; ++idx) {
|
||||
@@ -66,3 +67,4 @@ void destroy_sections(Macho_Binary_t* c_binary) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ void init_c_symbols(Macho_Binary_t* c_binary, Binary* binary) {
|
||||
c_binary->symbols[i] = static_cast<Macho_Symbol_t*>(malloc(sizeof(Macho_Symbol_t)));
|
||||
|
||||
c_binary->symbols[i]->name = symbol.name().c_str();
|
||||
c_binary->symbols[i]->type = symbol.raw_type();
|
||||
c_binary->symbols[i]->type = symbol.type();
|
||||
c_binary->symbols[i]->numberof_sections = symbol.numberof_sections();
|
||||
c_binary->symbols[i]->description = symbol.description();
|
||||
c_binary->symbols[i]->value = symbol.value();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
+47
-10
@@ -1,11 +1,48 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Binary.cpp
|
||||
DosHeader.cpp
|
||||
Header.cpp
|
||||
OptionalHeader.cpp
|
||||
Section.cpp
|
||||
DataDirectory.cpp
|
||||
EnumToString.cpp
|
||||
Import.cpp
|
||||
ImportEntry.cpp
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
set(LIEF_API_C_PE_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Import.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.cpp"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_API_C_PE_INCLUDE_FILES_CPP
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataDirectory.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DosHeader.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/OptionalHeader.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Import.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ImportEntry.hpp"
|
||||
)
|
||||
|
||||
set(LIEF_API_C_PE_INCLUDE_FILES_C
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/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"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/EnumToString.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Header.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/OptionalHeader.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Section.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/Import.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/LIEF/PE/ImportEntry.h"
|
||||
)
|
||||
|
||||
|
||||
set(LIEF_C_PE_INC "${LIEF_API_C_PE_INCLUDE_FILES_C}" "${LIEF_API_C_PE_INCLUDE_FILES_CPP}")
|
||||
|
||||
source_group("Source Files\\C API\\PE" FILES ${LIEF_API_C_PE_SRC})
|
||||
source_group("Header Files\\C API\\PE" FILES ${LIEF_C_PE_INC})
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE "${LIEF_API_C_PE_SRC}" "${LIEF_C_PE_INC}")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API
|
||||
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API
|
||||
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API_
|
||||
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API_
|
||||
|
||||
#include "LIEF/PE/Binary.h"
|
||||
#include "LIEF/PE/Binary.hpp"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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_dos_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
const DosHeader& dos_header = binary->dos_header();
|
||||
c_binary->dos_header.magic = dos_header.magic();
|
||||
c_binary->dos_header.used_bytes_in_last_page = dos_header.used_bytes_in_last_page();
|
||||
c_binary->dos_header.used_bytes_in_the_last_page = dos_header.used_bytes_in_the_last_page();
|
||||
c_binary->dos_header.file_size_in_pages = dos_header.file_size_in_pages();
|
||||
c_binary->dos_header.numberof_relocation = dos_header.numberof_relocation();
|
||||
c_binary->dos_header.header_size_in_paragraphs = dos_header.header_size_in_paragraphs();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,10 +20,21 @@
|
||||
#include "LIEF/PE/enums.h"
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
|
||||
const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::PE_TYPE>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::MACHINE_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::SUBSYSTEM>(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-13
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,18 +32,11 @@ void init_c_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
c_binary->header.sizeof_optional_header = header.sizeof_optional_header();
|
||||
c_binary->header.characteristics = static_cast<uint16_t>(header.characteristics());
|
||||
|
||||
std::copy(std::begin(signature), std::end(signature),
|
||||
c_binary->header.signature);
|
||||
std::copy(
|
||||
std::begin(signature),
|
||||
std::end(signature),
|
||||
c_binary->header.signature);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::MACHINE_TYPES>(e));
|
||||
}
|
||||
|
||||
const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::CHARACTERISTICS>(e));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "OptionalHeader.hpp"
|
||||
#include "LIEF/PE/OptionalHeader.h"
|
||||
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
@@ -60,8 +59,3 @@ void init_c_optional_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::OptionalHeader::SUBSYSTEM>(e));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,13 @@
|
||||
#ifndef C_LIEF_ELF_H_
|
||||
#define C_LIEF_ELF_H_
|
||||
|
||||
/** @defgroup elf_c_api ELF C API */
|
||||
|
||||
#include "LIEF/ELF/Binary.h"
|
||||
#include "LIEF/ELF/Symbol.h"
|
||||
#include "LIEF/ELF/Section.h"
|
||||
#include "LIEF/ELF/Header.h"
|
||||
#include "LIEF/ELF/DynamicEntry.h"
|
||||
#include "LIEF/ELF/EnumToString.h"
|
||||
#include "LIEF/ELF/utils.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,8 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_BINARY_H
|
||||
#define LIEF_C_ELF_BINARY_H
|
||||
#ifndef C_LIEF_ELF_BINARY_H_
|
||||
#define C_LIEF_ELF_BINARY_H_
|
||||
|
||||
/** @defgroup elf_binary_c_api Binary
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_binary_c_api
|
||||
* @brief Binary C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -32,31 +40,40 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** LIEF::ELF::Binary C Handler */
|
||||
/** @brief LIEF::ELF::Binary C Handler */
|
||||
struct Elf_Binary_t {
|
||||
void* handler;
|
||||
const char* name;
|
||||
const char* interpreter;
|
||||
uint32_t type;
|
||||
enum LIEF_ELF_ELF_CLASS type;
|
||||
Elf_Header_t header;
|
||||
Elf_Section_t **sections;
|
||||
Elf_Segment_t **segments;
|
||||
Elf_DynamicEntry_t **dynamic_entries;
|
||||
Elf_Symbol_t **dynamic_symbols;
|
||||
Elf_Symbol_t **symtab_symbols;
|
||||
Elf_Symbol_t **static_symbols;
|
||||
};
|
||||
|
||||
typedef struct Elf_Binary_t Elf_Binary_t;
|
||||
|
||||
/** Wrapper for LIEF::ELF::Parser::parse */
|
||||
/** @brief Wrapper for LIEF::ELF::Parser::parse */
|
||||
LIEF_API Elf_Binary_t* elf_parse(const char *file);
|
||||
|
||||
LIEF_API void elf_binary_destroy(Elf_Binary_t* binary);
|
||||
|
||||
/** Update LIEF::ELF::Header object */
|
||||
/* ELF::Binary methods
|
||||
* ==================
|
||||
*/
|
||||
|
||||
/** @brief Update LIEF::ELF::Header object */
|
||||
LIEF_API int elf_binary_save_header(Elf_Binary_t* binary);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_DYNAMIC_ENTRY_H
|
||||
#define LIEF_C_ELF_DYNAMIC_ENTRY_H
|
||||
#ifndef C_LIEF_ELF_DYNAMIC_ENTRY_H_
|
||||
#define C_LIEF_ELF_DYNAMIC_ENTRY_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
|
||||
/** @defgroup elf_dynamic_entry_c_api Dynamic Entry
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_dynamic_entry_c_api
|
||||
* @brief Dynamic Entry C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -57,9 +68,12 @@ struct Elf_DynamicEntry_RunPath_t {
|
||||
const char* runpath;
|
||||
};
|
||||
|
||||
|
||||
struct Elf_DynamicEntry_Flags_t {
|
||||
uint64_t tag;
|
||||
uint64_t value;
|
||||
enum LIEF_ELF_DYNAMIC_FLAGS *flags;
|
||||
enum LIEF_ELF_DYNAMIC_FLAGS_1 *flags_1;
|
||||
};
|
||||
|
||||
typedef struct Elf_DynamicEntry_t Elf_DynamicEntry_t;
|
||||
@@ -74,4 +88,5 @@ typedef struct Elf_DynamicEntry_Flags_t Elf_DynamicEntry_Flags_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_ELF_ENUM_TO_STRING_H_
|
||||
#define C_LIEF_ELF_ENUM_TO_STRING_H_
|
||||
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LIEF_API const char* SYMBOL_BINDINGS_to_string(enum LIEF_ELF_SYMBOL_BINDINGS e);
|
||||
LIEF_API const char* E_TYPE_to_string(enum LIEF_ELF_E_TYPE e);
|
||||
LIEF_API const char* VERSION_to_string(enum LIEF_ELF_VERSION e);
|
||||
LIEF_API const char* ARCH_to_string(enum LIEF_ELF_ARCH e);
|
||||
LIEF_API const char* SEGMENT_TYPES_to_string(enum LIEF_ELF_SEGMENT_TYPES e);
|
||||
LIEF_API const char* DYNAMIC_TAGS_to_string(enum LIEF_ELF_DYNAMIC_TAGS e);
|
||||
LIEF_API const char* ELF_SECTION_TYPES_to_string(enum LIEF_ELF_ELF_SECTION_TYPES e);
|
||||
LIEF_API const char* ELF_SECTION_FLAGS_to_string(enum LIEF_ELF_ELF_SECTION_FLAGS e);
|
||||
LIEF_API const char* ELF_SYMBOL_TYPES_to_string(enum LIEF_ELF_ELF_SYMBOL_TYPES e);
|
||||
LIEF_API const char* ELF_CLASS_to_string(enum LIEF_ELF_ELF_CLASS e);
|
||||
LIEF_API const char* ELF_DATA_to_string(enum LIEF_ELF_ELF_DATA e);
|
||||
LIEF_API const char* OS_ABI_to_string(enum LIEF_ELF_OS_ABI e);
|
||||
LIEF_API const char* DYNAMIC_FLAGS_to_string(enum LIEF_ELF_DYNAMIC_FLAGS e);
|
||||
LIEF_API const char* DYNAMIC_FLAGS_1_to_string(enum LIEF_ELF_DYNAMIC_FLAGS_1 e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,31 +13,38 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_HEADER_H
|
||||
#define LIEF_C_ELF_HEADER_H
|
||||
#ifndef C_LIEF_ELF_HEADER_H_
|
||||
#define C_LIEF_ELF_HEADER_H_
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
/** @defgroup elf_header_c_api Header
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_header_c_api
|
||||
* @brief Header C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Elf_Header_t {
|
||||
uint8_t identity[LIEF_EI_NIDENT];
|
||||
uint32_t file_type;
|
||||
uint32_t machine_type;
|
||||
uint32_t object_file_version;
|
||||
uint64_t entrypoint;
|
||||
uint64_t program_headers_offset;
|
||||
uint64_t section_headers_offset;
|
||||
uint32_t processor_flags;
|
||||
uint32_t header_size;
|
||||
uint32_t program_header_size;
|
||||
uint32_t numberof_segments;
|
||||
uint32_t section_header_size;
|
||||
uint32_t numberof_sections;
|
||||
uint32_t name_string_table_idx;
|
||||
uint8_t identity[LIEF_ELF_EI_NIDENT];
|
||||
enum LIEF_ELF_E_TYPE file_type;
|
||||
enum LIEF_ELF_ARCH machine_type;
|
||||
enum LIEF_ELF_VERSION object_file_version;
|
||||
uint64_t entrypoint;
|
||||
uint64_t program_headers_offset;
|
||||
uint64_t section_headers_offset;
|
||||
uint32_t processor_flags;
|
||||
uint32_t header_size;
|
||||
uint32_t program_header_size;
|
||||
uint32_t numberof_segments;
|
||||
uint32_t section_header_size;
|
||||
uint32_t numberof_sections;
|
||||
uint32_t name_string_table_idx;
|
||||
};
|
||||
|
||||
typedef struct Elf_Header_t Elf_Header_t;
|
||||
@@ -47,4 +54,5 @@ typedef struct Elf_Header_t Elf_Header_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,29 +13,39 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_SECTION_H
|
||||
#define LIEF_C_ELF_SECTION_H
|
||||
#ifndef C_LIEF_ELF_SECTION_H_
|
||||
#define C_LIEF_ELF_SECTION_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
|
||||
/** @defgroup elf_section_c_api Section
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_section_c_api
|
||||
* @brief Section C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Elf_Section_t {
|
||||
const char* name;
|
||||
uint32_t flags;
|
||||
uint32_t type;
|
||||
uint64_t virtual_address;
|
||||
uint64_t offset;
|
||||
uint64_t original_size;
|
||||
uint32_t link;
|
||||
uint32_t info;
|
||||
uint64_t alignment;
|
||||
uint64_t entry_size;
|
||||
uint64_t size;
|
||||
uint8_t* content;
|
||||
double entropy;
|
||||
const char* name;
|
||||
uint32_t flags;
|
||||
enum LIEF_ELF_ELF_SECTION_TYPES type;
|
||||
uint64_t virtual_address;
|
||||
uint64_t offset;
|
||||
uint64_t original_size;
|
||||
uint32_t link;
|
||||
uint32_t info;
|
||||
uint64_t alignment;
|
||||
uint64_t entry_size;
|
||||
uint64_t size;
|
||||
uint8_t* content;
|
||||
double entropy;
|
||||
};
|
||||
|
||||
typedef struct Elf_Section_t Elf_Section_t;
|
||||
@@ -44,4 +54,5 @@ typedef struct Elf_Section_t Elf_Section_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,25 +13,33 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_SEGMENT_H_
|
||||
#define LIEF_C_ELF_SEGMENT_H_
|
||||
#ifndef C_LIEF_ELF_SEGMENT_H_
|
||||
#define C_LIEF_ELF_SEGMENT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "LIEF/ELF/enums.h"
|
||||
|
||||
/** @defgroup elf_segment_c_api Segment
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_segment_c_api
|
||||
* @brief Segment C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Elf_Segment_t {
|
||||
uint32_t type;
|
||||
uint32_t flags;
|
||||
uint64_t virtual_address;
|
||||
uint64_t virtual_size;
|
||||
uint64_t offset;
|
||||
uint64_t alignment;
|
||||
uint64_t size;
|
||||
uint8_t* content;
|
||||
enum LIEF_ELF_SEGMENT_TYPES type;
|
||||
uint32_t flags;
|
||||
uint64_t virtual_address;
|
||||
uint64_t virtual_size;
|
||||
uint64_t offset;
|
||||
uint64_t alignment;
|
||||
uint64_t size;
|
||||
uint8_t* content;
|
||||
};
|
||||
|
||||
typedef struct Elf_Segment_t Elf_Segment_t;
|
||||
@@ -40,4 +48,5 @@ typedef struct Elf_Segment_t Elf_Segment_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,27 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_SYMBOL_H
|
||||
#define LIEF_C_ELF_SYMBOL_H
|
||||
#ifndef C_LIEF_ELF_SYMBOL_H_
|
||||
#define C_LIEF_ELF_SYMBOL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
#include "LIEF/types.h"
|
||||
/** @defgroup elf_symbol_c_api Symbol
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_symbol_c_api
|
||||
* @brief Symbol C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Elf_Symbol_t {
|
||||
const char* name;
|
||||
uint32_t type;
|
||||
uint32_t binding;
|
||||
uint8_t information;
|
||||
uint8_t other;
|
||||
uint16_t shndx;
|
||||
uint64_t value;
|
||||
uint64_t size;
|
||||
bool is_exported; /**< Whether or not the symbol is exported */
|
||||
bool is_imported; /**< Whether or not the symbol is imported */
|
||||
const char* name;
|
||||
enum LIEF_ELF_ELF_SYMBOL_TYPES type;
|
||||
enum LIEF_ELF_SYMBOL_BINDINGS binding;
|
||||
uint8_t information;
|
||||
uint8_t other;
|
||||
uint16_t shndx;
|
||||
uint64_t value;
|
||||
uint64_t size;
|
||||
bool is_exported; /**< Whether or not the symbol is exported */
|
||||
bool is_imported; /**< Whether or not the symbol is imported */
|
||||
};
|
||||
|
||||
typedef struct Elf_Symbol_t Elf_Symbol_t;
|
||||
@@ -42,4 +51,5 @@ typedef struct Elf_Symbol_t Elf_Symbol_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
+7
-1001
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,8 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_C_ELF_UTILS_H
|
||||
#define LIEF_C_ELF_UTILS_H
|
||||
#ifndef C_LIEF_ELF_UTILS_H_
|
||||
#define C_LIEF_ELF_UTILS_H_
|
||||
|
||||
/** @defgroup elf_utils_c_api Utils
|
||||
* @ingroup elf_c_api
|
||||
* @addtogroup elf_utils_c_api
|
||||
* @brief Utils C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -34,4 +42,5 @@ LIEF_API bool is_elf(const char* file);
|
||||
#endif
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,13 @@
|
||||
#ifndef C_LIEF_MACHO_H_
|
||||
#define C_LIEF_MACHO_H_
|
||||
|
||||
/** @defgroup macho_c_api MachO C API */
|
||||
|
||||
#include "LIEF/MachO/Binary.h"
|
||||
#include "LIEF/MachO/Symbol.h"
|
||||
#include "LIEF/MachO/Segment.h"
|
||||
#include "LIEF/MachO/Section.h"
|
||||
#include "LIEF/MachO/LoadCommand.h"
|
||||
#include "LIEF/MachO/Header.h"
|
||||
#include "LIEF/MachO/EnumToString.h"
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,14 @@
|
||||
#ifndef C_LIEF_MACHO_BINARY_H_
|
||||
#define C_LIEF_MACHO_BINARY_H_
|
||||
|
||||
/** @defgroup macho_binary_c_api Binary
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_binary_c_api
|
||||
* @brief Binary C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "LIEF/visibility.h"
|
||||
@@ -33,6 +41,7 @@ extern "C" {
|
||||
/** @brief LIEF::MachO::Binary C Handler */
|
||||
struct Macho_Binary_t {
|
||||
void* handler;
|
||||
const char* name;
|
||||
uint64_t imagebase;
|
||||
Macho_Header_t header;
|
||||
Macho_Command_t** commands;
|
||||
@@ -54,4 +63,5 @@ LIEF_API void macho_binaries_destroy(Macho_Binary_t** binaries);
|
||||
#endif
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_MACHO_ENUM_TO_STRING_H_
|
||||
#define C_LIEF_MACHO_ENUM_TO_STRING_H_
|
||||
|
||||
#include "LIEF/visibility.h"
|
||||
#include "LIEF/MachO/enums.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LIEF_API const char* LOAD_COMMAND_TYPES_to_string(enum LIEF_MACHO_LOAD_COMMAND_TYPES e);
|
||||
LIEF_API const char* MACHO_TYPES_to_string(enum LIEF_MACHO_MACHO_TYPES e);
|
||||
LIEF_API const char* FILE_TYPES_to_string(enum LIEF_MACHO_FILE_TYPES e);
|
||||
LIEF_API const char* CPU_TYPES_to_string(enum LIEF_MACHO_CPU_TYPES e);
|
||||
LIEF_API const char* HEADER_FLAGS_to_string(enum LIEF_MACHO_HEADER_FLAGS e);
|
||||
LIEF_API const char* MACHO_SECTION_TYPES_to_string(enum LIEF_MACHO_MACHO_SECTION_TYPES e);
|
||||
LIEF_API const char* MACHO_SYMBOL_TYPES_to_string(enum LIEF_MACHO_MACHO_SYMBOL_TYPES e);
|
||||
LIEF_API const char* N_LIST_TYPES_to_string(enum LIEF_MACHO_N_LIST_TYPES e);
|
||||
LIEF_API const char* SYMBOL_DESCRIPTIONS_to_string(enum LIEF_MACHO_SYMBOL_DESCRIPTIONS e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,13 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/MachO/enums.h"
|
||||
/** @defgroup macho_header_c_api Header
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_header_c_api
|
||||
* @brief Header C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -41,4 +48,5 @@ typedef struct Macho_Header_t Macho_Header_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,14 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/MachO/enums.h"
|
||||
/** @defgroup macho_load_command_c_api Header
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_load_command_c_api
|
||||
* @brief Load Command C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -36,4 +44,5 @@ typedef struct Macho_Command_t Macho_Command_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,14 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/MachO/enums.h"
|
||||
/** @defgroup macho_section_c_api Header
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_section_c_api
|
||||
* @brief Section C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -47,4 +55,5 @@ typedef struct Macho_Section_t Macho_Section_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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,14 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/MachO/enums.h"
|
||||
#include "LIEF/MachO/Section.h"
|
||||
/** @defgroup macho_segment_c_api Header
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_segment_c_api
|
||||
* @brief Segment C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -45,4 +52,5 @@ typedef struct Macho_Segment_t Macho_Segment_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,13 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/MachO/enums.h"
|
||||
/** @defgroup macho_symbol_c_api Header
|
||||
* @ingroup macho_c_api
|
||||
* @addtogroup macho_symbol_c_api
|
||||
* @brief Symbol C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -38,4 +45,5 @@ typedef struct Macho_Symbol_t Macho_Symbol_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef C_LIEF_PE_H_
|
||||
#define C_LIEF_PE_H_
|
||||
|
||||
/** @defgroup pe_c_api PE C API */
|
||||
|
||||
#include "LIEF/PE/Binary.h"
|
||||
#include "LIEF/PE/EnumToString.h"
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,14 @@
|
||||
#ifndef C_LIEF_PE_BINARY_H_
|
||||
#define C_LIEF_PE_BINARY_H_
|
||||
|
||||
/** @defgroup pe_binary_c_api Binary
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_binary_c_api
|
||||
* @brief Binary C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "LIEF/visibility.h"
|
||||
@@ -36,6 +44,7 @@ extern "C" {
|
||||
/** @brief LIEF::PE::Binary C Handler */
|
||||
struct Pe_Binary_t {
|
||||
void* handler;
|
||||
const char* name;
|
||||
Pe_DosHeader_t dos_header;
|
||||
Pe_Header_t header;
|
||||
Pe_OptionalHeader_t optional_header;
|
||||
@@ -55,4 +64,6 @@ LIEF_API void pe_binary_destroy(Pe_Binary_t* binary);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License",;
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@@ -13,39 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_DATA_DIRECTORY_H
|
||||
#define C_LIEF_PE_DATA_DIRECTORY_H
|
||||
#ifndef C_LIEF_PE_DATA_DIRECTORY_H_
|
||||
#define C_LIEF_PE_DATA_DIRECTORY_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
/** @defgroup pe_data_directory_c_api Section
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_data_directory_c_api
|
||||
* @brief Data directory C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum LIEF_PE_DATA_DIRECTORY {
|
||||
LIEF_PE_DATA_DIR_EXPORT_TABLE = 0,
|
||||
LIEF_PE_DATA_DIR_IMPORT_TABLE,
|
||||
LIEF_PE_DATA_DIR_RESOURCE_TABLE,
|
||||
LIEF_PE_DATA_DIR_EXCEPTION_TABLE,
|
||||
LIEF_PE_DATA_DIR_CERTIFICATE_TABLE,
|
||||
LIEF_PE_DATA_DIR_BASE_RELOCATION_TABLE,
|
||||
LIEF_PE_DATA_DIR_DEBUG,
|
||||
LIEF_PE_DATA_DIR_ARCHITECTURE,
|
||||
LIEF_PE_DATA_DIR_GLOBAL_PTR,
|
||||
LIEF_PE_DATA_DIR_TLS_TABLE,
|
||||
LIEF_PE_DATA_DIR_LOAD_CONFIG_TABLE,
|
||||
LIEF_PE_DATA_DIR_BOUND_IMPORT,
|
||||
LIEF_PE_DATA_DIR_IAT,
|
||||
LIEF_PE_DATA_DIR_DELAY_IMPORT_DESCRIPTOR,
|
||||
LIEF_PE_DATA_DIR_CLR_RUNTIME_HEADER,
|
||||
LIEF_PE_DATA_DIR_RESERVED,
|
||||
|
||||
LIEF_PE_DATA_DIR_NONE,
|
||||
};
|
||||
|
||||
struct Pe_DataDirectory_t {
|
||||
uint32_t rva;
|
||||
uint32_t size;
|
||||
@@ -58,4 +43,5 @@ typedef struct Pe_DataDirectory_t Pe_DataDirectory_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,13 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
/** @defgroup pe_dos_header_c_api DosHeader
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_dos_header_c_api
|
||||
* @brief Dos Header C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -25,7 +32,7 @@ extern "C" {
|
||||
|
||||
struct Pe_DosHeader_t {
|
||||
uint16_t magic ;
|
||||
uint16_t used_bytes_in_last_page;
|
||||
uint16_t used_bytes_in_the_last_page;
|
||||
uint16_t file_size_in_pages;
|
||||
uint16_t numberof_relocation;
|
||||
uint16_t header_size_in_paragraphs;
|
||||
@@ -52,4 +59,5 @@ typedef struct Pe_DosHeader_t Pe_DosHeader_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 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,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LIEF_API const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e);
|
||||
LIEF_API const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e);
|
||||
LIEF_API const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,65 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_HEADER_H
|
||||
#define C_LIEF_PE_HEADER_H
|
||||
#ifndef C_LIEF_PE_HEADER_H_
|
||||
#define C_LIEF_PE_HEADER_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/visibility.h"
|
||||
#include "LIEF/PE/enums.h"
|
||||
/** @defgroup pe_header_c_api Header
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_header_c_api
|
||||
* @brief Header C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_MACHINE_TYPES {
|
||||
LIEF_PE_MACHINE_UNKNOWN = 0x0,
|
||||
LIEF_PE_MACHINE_AM33 = 0x1D3, /**< Matsushita AM33 */
|
||||
LIEF_PE_MACHINE_AMD64 = 0x8664, /**< AMD x64 */
|
||||
LIEF_PE_MACHINE_ARM = 0x1C0, /**< ARM little endian */
|
||||
LIEF_PE_MACHINE_ARMNT = 0x1C4, /**< ARMv7 Thumb mode only */
|
||||
LIEF_PE_MACHINE_ARM64 = 0xAA64, /**< ARMv8 in 64-bits mode */
|
||||
LIEF_PE_MACHINE_EBC = 0xEBC, /**< EFI byte code */
|
||||
LIEF_PE_MACHINE_I386 = 0x14C, /**< Intel 386 or later */
|
||||
LIEF_PE_MACHINE_IA64 = 0x200, /**< Intel Itanium processor family */
|
||||
LIEF_PE_MACHINE_M32R = 0x9041, /**< Mitsubishi M32R little endian */
|
||||
LIEF_PE_MACHINE_MIPS16 = 0x266, /**< MIPS16 */
|
||||
LIEF_PE_MACHINE_MIPSFPU = 0x366, /**< MIPS with FPU */
|
||||
LIEF_PE_MACHINE_MIPSFPU16 = 0x466, /**< MIPS16 with FPU */
|
||||
LIEF_PE_MACHINE_POWERPC = 0x1F0, /**< Power PC little endian */
|
||||
LIEF_PE_MACHINE_POWERPCFP = 0x1F1, /**< Power PC with floating point */
|
||||
LIEF_PE_MACHINE_POWERPCBE = 0x1F2, /**< Power PC big endian */
|
||||
LIEF_PE_MACHINE_R4000 = 0x166, /**< MIPS with little endian */
|
||||
LIEF_PE_MACHINE_RISCV32 = 0x5032, /**< RISC-V 32-bit address space */
|
||||
LIEF_PE_MACHINE_RISCV64 = 0x5064, /**< RISC-V 64-bit address space */
|
||||
LIEF_PE_MACHINE_RISCV128 = 0x5128, /**< RISC-V 128-bit address space */
|
||||
LIEF_PE_MACHINE_SH3 = 0x1A2, /**< Hitachi SH3 */
|
||||
LIEF_PE_MACHINE_SH3DSP = 0x1A3, /**< Hitachi SH3 DSP */
|
||||
LIEF_PE_MACHINE_SH4 = 0x1A6, /**< Hitachi SH4 */
|
||||
LIEF_PE_MACHINE_SH5 = 0x1A8, /**< Hitachi SH5 */
|
||||
LIEF_PE_MACHINE_THUMB = 0x1C2, /**< ARM or Thumb */
|
||||
LIEF_PE_MACHINE_WCEMIPSV2 = 0x169 /**< MIPS little-endian WCE v2 */
|
||||
};
|
||||
|
||||
enum LIEF_PE_HEADER_CHARACTERISTICS {
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_INVALID = 0x0000,
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_RELOCS_STRIPPED = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_EXECUTABLE_IMAGE = 0x0002, /**< The file is valid and can be run.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LINE_NUMS_STRIPPED = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LOCAL_SYMS_STRIPPED = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_AGGRESSIVE_WS_TRIM = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LARGE_ADDRESS_AWARE = 0x0020, /**< Image can handle > 2GiB addresses. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_LO = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_32BIT_MACHINE = 0x0100, /**< Machine is based on a 32bit word architecture. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_DEBUG_STRIPPED = 0x0200, /**< Debugging info has been removed. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_REMOVABLE_RUN_FROM_SWAP = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_NET_RUN_FROM_SWAP = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_SYSTEM = 0x1000, /**< The image file is a system file, not a user program.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_DLL = 0x2000, /**< The image file is a DLL. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_UP_SYSTEM_ONLY = 0x4000, /**< This file should only be run on a uniprocessor machine. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_HI = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
|
||||
};
|
||||
|
||||
struct Pe_Header_t {
|
||||
uint8_t signature[4];
|
||||
enum LIEF_PE_MACHINE_TYPES machine;
|
||||
@@ -85,11 +44,10 @@ struct Pe_Header_t {
|
||||
|
||||
typedef struct Pe_Header_t Pe_Header_t;
|
||||
|
||||
LIEF_API const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e);
|
||||
LIEF_API const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,14 @@
|
||||
#include "LIEF/PE/enums.h"
|
||||
#include "LIEF/PE/ImportEntry.h"
|
||||
|
||||
/** @defgroup pe_import_c_api Import
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_import_c_api
|
||||
* @brief Import C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -41,4 +49,5 @@ typedef struct Pe_Import_t Pe_Import_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,14 @@
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
|
||||
/** @defgroup pe_import_entry_c_api Import Entry
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_import_entry_c_api
|
||||
* @brief Import Entry C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -44,4 +52,5 @@ typedef struct Pe_ImportEntry_t Pe_ImportEntry_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,48 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H
|
||||
#define C_LIEF_PE_OPTIONAL_HEADER_H
|
||||
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H_
|
||||
#define C_LIEF_PE_OPTIONAL_HEADER_H_
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
#include "LIEF/visibility.h"
|
||||
/** @defgroup pe_optional_header_c_api OptionalHeader
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_optional_header_c_api
|
||||
* @brief OptionalHeader C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_DLL_CHARACTERISTICS {
|
||||
LIEF_PE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020, /**< ASLR with 64 bit address space. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, /**< DLL can be relocated at load time. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, /**< Code integrity checks are enforced. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, /**< Image is NX compatible. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200, /**< Isolation aware, but do not isolate the image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_SEH = 0x0400, /**< Does not use structured exception handling (SEH). No SEH handler may be called in this image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_BIND = 0x0800, /**< Do not bind the image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000, /**< Image should execute in an AppContainer. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000, /**< A WDM driver. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000, /**< Image supports Control Flow Guard. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000 /**< Terminal Server aware. */
|
||||
};
|
||||
|
||||
enum LIEF_PE_SUBSYSTEM {
|
||||
LIEF_PE_SUBSYSTEM_UNKNOWN = 0, /**< An unknown subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_NATIVE = 1, /**< Device drivers and native Windows processes */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_GUI = 2, /**< The Windows GUI subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_CUI = 3, /**< The Windows character subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_OS2_CUI = 5, /**< The OS/2 character subsytem. */
|
||||
LIEF_PE_SUBSYSTEM_POSIX_CUI = 7, /**< The POSIX character subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_NATIVE_WINDOWS = 8, /**< Native Windows 9x driver. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_CE_GUI = 9, /**< Windows CE. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_APPLICATION = 10, /**< An EFI application. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, /**< An EFI driver with boot services. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, /**< An EFI driver with run-time services. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_ROM = 13, /**< An EFI ROM image. */
|
||||
LIEF_PE_SUBSYSTEM_XBOX = 14, /**< XBOX. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 /**< A BCD application. */
|
||||
};
|
||||
|
||||
struct Pe_OptionalHeader_t {
|
||||
enum LIEF_PE_PE_TYPES magic;
|
||||
uint8_t major_linker_version;
|
||||
@@ -90,10 +65,10 @@ struct Pe_OptionalHeader_t {
|
||||
|
||||
typedef struct Pe_OptionalHeader_t Pe_OptionalHeader_t;
|
||||
|
||||
LIEF_API const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2017 - 2024 R. Thomas
|
||||
* Copyright 2017 - 2024 Quarkslab
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,50 +19,18 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
/** @defgroup pe_section_c_api Section
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_section_c_api
|
||||
* @brief Section C API
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_SECTION_CHARACTERISTICS {
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_TYPE_NO_PAD = 0x00000008,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_CODE = 0x00000020,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_INITIALIZED_DATA = 0x00000040,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_UNINITIALIZED_DATA = 0x00000080,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_OTHER = 0x00000100,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_INFO = 0x00000200,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_REMOVE = 0x00000800,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_COMDAT = 0x00001000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_GPREL = 0x00008000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PURGEABLE = 0x00010000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_16BIT = 0x00020000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_LOCKED = 0x00040000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PRELOAD = 0x00080000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1BYTES = 0x00100000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2BYTES = 0x00200000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4BYTES = 0x00300000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8BYTES = 0x00400000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_16BYTES = 0x00500000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_32BYTES = 0x00600000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_64BYTES = 0x00700000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_128BYTES = 0x00800000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_256BYTES = 0x00900000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_512BYTES = 0x00A00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1024BYTES = 0x00B00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2048BYTES = 0x00C00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4096BYTES = 0x00D00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8192BYTES = 0x00E00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_NRELOC_OVFL = 0x01000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_DISCARDABLE = 0x02000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_CACHED = 0x04000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_PAGED = 0x08000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_SHARED = 0x10000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_EXECUTE = 0x20000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_READ = 0x40000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_WRITE = 0x80000000
|
||||
};
|
||||
|
||||
|
||||
struct Pe_Section_t {
|
||||
const char* name;
|
||||
uint64_t virtual_address;
|
||||
@@ -82,8 +50,10 @@ struct Pe_Section_t {
|
||||
|
||||
typedef struct Pe_Section_t Pe_Section_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,6 @@ extern "C" {
|
||||
#undef _LIEF_EN_2
|
||||
#undef _LIEF_EI
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user