Compare commits

...
13 Commits
Author SHA1 Message Date
Romain Thomas 2169578d46 Update date 2022-10-01 06:34:17 +02:00
Romain Thomas d21af83876 Fix missing copy_file (related to #770) 2022-10-01 06:33:24 +02:00
Romain Thomas fad1db9e8b Bump version 2022-09-11 16:23:49 +02:00
Romain Thomas 27cada7e0b Resolve #770 2022-09-11 16:16:40 +02:00
Romain Thomas c7b3ce3b2c Disable tests 2022-04-08 05:26:06 +02:00
Romain Thomas cf439c1bea Bump version 2022-04-08 05:20:15 +02:00
Romain Thomas b3ec2c6f9d Fix memory issues 2022-04-03 19:54:36 +02:00
Romain Thomas 39c15ae56b Update changelog 2022-04-02 20:05:27 +02:00
Romain Thomas b13b2d7c3d Fix #693 2022-04-02 20:03:23 +02:00
Romain Thomas 3fb587c291 Update changelog 2022-04-02 16:04:29 +02:00
Krzysztof Jackiewicz 2671daac4e Fix section inclusion calculations 2022-04-02 16:02:33 +02:00
Romain Thomas ebe4990acd Update changelog 2022-04-01 07:28:24 +02:00
Romain Thomas 677632baa9 Enable release branch 2022-04-01 07:27:27 +02:00
17 changed files with 113 additions and 58 deletions
+5
View File
@@ -248,9 +248,14 @@ dir_name = "latest"
if BRANCH_NAME != "master":
dir_name = "{}".format(BRANCH_NAME.replace("/", "-").replace("_", "-"))
if BRANCH_NAME.startswith("release-"):
_, dir_name = BRANCH_NAME.split("release-")
if IS_TAGGED:
dir_name = str(TAG_NAME)
logger.info("Destination directory: %s", dir_name)
for file in DIST_DIR.glob("*.whl"):
logger.info("[WHEEL] Uploading '%s'", file.as_posix())
push_wheel(file.as_posix(), dir_name)
+1 -1
View File
@@ -50,7 +50,7 @@ jobs:
-e PYTHON_BINARY=/opt/python/cp37-cp37m/bin/python3.7 \
-v $GITHUB_WORKSPACE:/src \
-v $HOME/.ccache:/ccache \
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux_test.sh
liefproject/manylinux_2_24_x86_64 bash /src/scripts/docker/run_linux.sh
- name: Build Python 3.8 wheel
shell: bash
env:
+1 -1
View File
@@ -45,7 +45,7 @@ jobs:
CCACHE_CPP2: 1
CCACHE_COMPRESS: 1
run: |
python ./setup.py --ninja --lief-test build bdist_wheel --skip-build --plat-name=macosx_${MACOSX_DEPLOYMENT_TARGET}_x86_64
python ./setup.py --ninja build bdist_wheel --skip-build --plat-name=macosx_${MACOSX_DEPLOYMENT_TARGET}_x86_64
- name: Build Python ${{ matrix.python-version }} wheel
shell: bash
if: matrix.python-version != '3.6'
+1 -1
View File
@@ -55,7 +55,7 @@ jobs:
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
if: matrix.python-version == 3.6
run: |
python ./setup.py --ninja --lief-test bdist_wheel
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: ❱ Build Python ${{ matrix.python-version }}
if: matrix.python-version != 3.6
+1 -1
View File
@@ -54,7 +54,7 @@ jobs:
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
run: |
python ./setup.py --ninja --lief-test bdist_wheel
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: 📊 Print sccache stats
run: sccache --show-stats
+1 -1
View File
@@ -55,7 +55,7 @@ jobs:
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
if: matrix.python-version == 3.6
run: |
python ./setup.py --ninja --lief-test bdist_wheel --plat-name=win32
python ./setup.py --ninja bdist_wheel --plat-name=win32
shell: cmd
- name: ❱ Build Python ${{ matrix.python-version }}
if: matrix.python-version != 3.6
+1 -1
View File
@@ -54,7 +54,7 @@ jobs:
run: sccache --start-server
- name: ⛓ Build Python ${{ matrix.python-version }} & Test
run: |
python ./setup.py --ninja --lief-test bdist_wheel
python ./setup.py --ninja bdist_wheel
shell: cmd
- name: 📊 Print sccache stats
run: sccache --show-stats
+2 -2
View File
@@ -28,8 +28,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git"
include(LIEFGit)
else()
set(LIEF_VERSION_MAJOR "0")
set(LIEF_VERSION_MINOR "13")
set(LIEF_VERSION_PATCH "0")
set(LIEF_VERSION_MINOR "12")
set(LIEF_VERSION_PATCH "2")
endif()
# LIEF Project
+12 -3
View File
@@ -41,11 +41,16 @@ execute_process(
string(COMPARE NOTEQUAL "${LIEF_GIT_COMMIT_TAGGED}" "" LIEF_IS_TAGGED)
STRING(REGEX MATCHALL "([0-9]+)" VERSION_STRING "${LIEF_GIT_TAG}")
string(REGEX MATCHALL "([0-9]+)" VERSION_STRING "${LIEF_GIT_TAG}")
message(STATUS "Tagged: ${LIEF_IS_TAGGED}")
if (${LIEF_IS_TAGGED})
message(STATUS "Tag: ${LIEF_GIT_TAG}")
else()
if(LIEF_GIT_BRANCH MATCHES "^release-")
string(REGEX MATCHALL "([0-9]+)" VERSION_STRING "${LIEF_GIT_BRANCH}")
message(STATUS "${VERSION_STRING}")
endif()
endif()
message(STATUS "Current branch: ${LIEF_GIT_BRANCH}")
@@ -56,8 +61,12 @@ if (VERSION_STRING)
list(GET VERSION_STRING 2 LIEF_VERSION_PATCH)
if (NOT ${LIEF_IS_TAGGED})
MATH(EXPR LIEF_VERSION_MINOR "${LIEF_VERSION_MINOR}+1")
set(LIEF_VERSION_PATCH 0)
if(LIEF_GIT_BRANCH MATCHES "^release-")
message(STATUS "Release branch")
else()
MATH(EXPR LIEF_VERSION_MINOR "${LIEF_VERSION_MINOR}+1")
set(LIEF_VERSION_PATCH 0)
endif()
endif()
else()
set(LIEF_VERSION_MAJOR 0)
+12 -3
View File
@@ -1,11 +1,20 @@
Changelog
=========
0.12.1 - Not Released Yet
-------------------------
0.12.2 - October 1, 2022
------------------------
* Fix setuptools issue (:issue:`770`)
0.12.1 - April 08, 2022
------------------------
:ELF:
* Fix section inclusion calculations (:pr:`692`)
:PE:
* Fix parsing regressions (:issue:`6889`, :issue:`687`, :issue:`686`, :issue:`685`)
* Fix parsing regressions (:issue:`689`, :issue:`687`, :issue:`686`, :issue:`685`, :issue:`691`, :issue:`693`)
:Compilation:
* Nightly builds are now upload to Saleway's S3 server:
+11 -8
View File
@@ -1,9 +1,10 @@
#!/usr/bin/sh
set -ex
shopt -s globstar
set -e
BUILD_DIR=/tmp/build_asan
SRC_DIR=/src
LOG_DIR=/tmp/sanitize_log
SAMPLE_DIR=/tmp/samples
ASAN_OPT="log_path=${LOG_DIR}"
mkdir -p ${LOG_DIR}
@@ -15,10 +16,12 @@ cmake -B ${BUILD_DIR} -S ${SRC_DIR} -GNinja \
ninja -C ${BUILD_DIR} sanitize_checks
cd ${BUILD_DIR}
curl -LO https://github.com/lief-project/samples/raw/master/ELF/ELF64_x86-64_binary_all.bin
curl -LO https://github.com/lief-project/samples/raw/master/PE/PE64_x86-64_binary_mfc-application.exe
curl -LO https://github.com/lief-project/samples/raw/master/MachO/9edfb04c55289c6c682a25211a4b30b927a86fe50b014610d04d6055bd4ac23d_crypt_and_hash.macho
${BUILD_DIR}/tests/sanitizer/sanitize_checks ELF64_x86-64_binary_all.bin
${BUILD_DIR}/tests/sanitizer/sanitize_checks PE64_x86-64_binary_mfc-application.exe
${BUILD_DIR}/tests/sanitizer/sanitize_checks 9edfb04c55289c6c682a25211a4b30b927a86fe50b014610d04d6055bd4ac23d_crypt_and_hash.macho
mkdir -p ${SAMPLE_DIR}
pushd ${SAMPLE_DIR}
curl -LO https://data.romainthomas.fr/lief_tests.zip
unzip lief_tests.zip
popd
for x in ${SAMPLE_DIR}/**; do echo $x && ${BUILD_DIR}/tests/sanitizer/sanitize_checks $x; done
+20 -10
View File
@@ -9,8 +9,9 @@ import copy
import distutils
from pkg_resources import get_distribution
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext, copy_file
from setuptools.command.build_ext import build_ext
from distutils import log
from shutil import copy2
from distutils.version import LooseVersion
@@ -329,10 +330,9 @@ class BuildLibrary(build_ext):
if not os.path.exists(self.build_lib):
os.makedirs(self.build_lib)
log.info("Copying {} into {}".format(pylief_path, pylief_dst))
copy_file(
pylief_path, pylief_dst, verbose=self.verbose,
dry_run=self.dry_run)
log.info(f"Copying {pylief_path} into {pylief_dst}")
if not self.dry_run:
copy2(pylief_path, pylief_dst)
# SDK
@@ -345,10 +345,8 @@ class BuildLibrary(build_ext):
sdk_path = str(sdk_path.pop())
sdk_output = str(pathlib.Path(CURRENT_DIR) / "build")
copy_file(
sdk_path, sdk_output, verbose=self.verbose,
dry_run=self.dry_run)
if not self.dry_run:
copy2(sdk_path, sdk_output)
def get_platform():
out = get_platform_backup()
@@ -410,11 +408,23 @@ distutils.sysconfig.get_config_vars = distutils_get_config_vars
# From setuptools-git-version
command = 'git describe --tags --long --dirty'
git_branch = 'git rev-parse --abbrev-ref HEAD'
is_tagged_cmd = 'git tag --list --points-at=HEAD'
fmt_dev = '{tag}.dev0'
fmt_tagged = '{tag}'
def get_branch():
try:
return subprocess.check_output(git_branch.split()).decode('utf-8').strip()
except Exception:
return None
def format_version(version: str, fmt: str = fmt_dev, is_dev: bool = False):
branch = get_branch()
if branch is not None and branch.startswith("release-"):
_, version = branch.split("release-")
return version
parts = version.split('-')
assert len(parts) in (3, 4)
dirty = len(parts) == 4
@@ -445,7 +455,7 @@ def get_pkg_info_version(pkg_info_file):
def get_version() -> str:
version = "0.13.0"
version = "0.12.2"
pkg_info = os.path.join(CURRENT_DIR, "{}.egg-info".format(PACKAGE_NAME), "PKG-INFO")
git_dir = os.path.join(CURRENT_DIR, ".git")
if os.path.isdir(git_dir):
+18 -10
View File
@@ -1208,11 +1208,18 @@ ok_error_t Builder::build_symbol_hash() {
return make_error_code(lief_errors::not_found);
}
uint32_t nbucket = sysv->nbucket();
uint32_t nchain = static_cast<ExeLayout*>(layout_.get())->sysv_nchain();
std::vector<uint8_t> new_hash_table((nbucket + nchain + 2) * sizeof(uint32_t), 0);
auto *const new_hash_table_ptr = reinterpret_cast<uint32_t*>(new_hash_table.data());
if (nbucket == 0) {
LIEF_ERR("sysv.nbucket is 0");
return make_error_code(lief_errors::build_error);
}
const size_t buckets_limits = nbucket + nchain + 2;
std::vector<uint8_t> new_hash_table(buckets_limits * sizeof(uint32_t), 0);
auto* new_hash_table_ptr = reinterpret_cast<uint32_t*>(new_hash_table.data());
new_hash_table_ptr[0] = nbucket;
new_hash_table_ptr[1] = nchain;
@@ -1221,15 +1228,16 @@ ok_error_t Builder::build_symbol_hash() {
uint32_t* chain = &new_hash_table_ptr[2 + nbucket];
uint32_t idx = 0;
for (const std::unique_ptr<Symbol>& symbol : binary_->dynamic_symbols_) {
uint32_t hash = 0;
uint32_t hash = binary_->type_ == ELF_CLASS::ELFCLASS32 ?
hash32(symbol->name().c_str()) :
hash64(symbol->name().c_str());
if (binary_->type_ == ELF_CLASS::ELFCLASS32) {
hash = hash32(symbol->name().c_str());
} else {
hash = hash64(symbol->name().c_str());
const size_t bucket_idx = hash % nbucket;
if (bucket_idx >= buckets_limits) {
LIEF_WARN("Bucket {} is out of range", bucket_idx);
continue;
}
if (bucket[hash % nbucket] == 0) {
if (bucket[bucket_idx] == 0) {
bucket[hash % nbucket] = idx;
} else {
uint32_t value = bucket[hash % nbucket];
@@ -1247,7 +1255,7 @@ ok_error_t Builder::build_symbol_hash() {
// to be improved...?
if (should_swap()) {
for (size_t i = 0; i < nbucket + nchain + 2; i++) {
for (size_t i = 0; i < buckets_limits; i++) {
Convert::swap_endian(&new_hash_table_ptr[i]);
}
}
+2 -4
View File
@@ -609,18 +609,16 @@ ok_error_t Parser::parse_overlay() {
}
bool Parser::check_section_in_segment(const Section& section, const Segment& segment) {
const uint64_t sec_end = section.virtual_address() + section.size();
if (section.virtual_address() > 0) {
const uint64_t seg_vend = segment.virtual_address() + segment.virtual_size();
return segment.virtual_address() <= section.virtual_address() &&
sec_end <= seg_vend;
section.virtual_address() + section.size() <= seg_vend;
}
if (section.file_offset() > 0) {
const uint64_t seg_end = segment.file_offset() + segment.physical_size();
return segment.file_offset() <= section.file_offset() &&
sec_end < seg_end;
section.file_offset() + section.size() <= seg_end;
}
return false;
}
+2 -1
View File
@@ -78,7 +78,8 @@ ok_error_t Builder::build_segments() {
const auto& content = segment.content();
if (content.size() != segment.file_size()) {
LIEF_ERR("content.size() != segment.file_size()");
LIEF_ERR("{} content size and file_size are differents: 0x{:x} vs 0x{:x}",
segment.name(), content.size(), segment.file_size());
return make_error_code(lief_errors::build_error);
}
+8 -1
View File
@@ -412,7 +412,14 @@ void SegmentCommand::content_resize(size_t size) {
void SegmentCommand::content_insert(size_t where, size_t size) {
update_data([] (std::vector<uint8_t>& inner_data, size_t w, size_t s) {
inner_data.insert(std::begin(inner_data) + w, s, 0);
if (s == 0) {
return;
}
if (w < inner_data.size()) {
inner_data.insert(std::begin(inner_data) + w, s, 0);
} else {
inner_data.resize(inner_data.size() + w + s, 0);
}
}, where, size);
}
+15 -10
View File
@@ -472,17 +472,22 @@ ok_error_t ResourcesParser::parse_string(LangCodeItem& lci, BinaryStream& stream
/*
* Read the value
*/
LIEF_DEBUG("String.Value @0x{:x}", stream.pos());
if (auto res = stream.read_u16string()) {
if (res->size() + /* null char */ 1 != wValueLength) {
LIEF_INFO("String.Value.size() is different from wValueLength ({} / {})",
wValueLength, res->size() + 1);
if (wValueLength > 0) {
LIEF_DEBUG("String.Value @0x{:x}", stream.pos());
if (auto res = stream.read_u16string()) {
if (res->size() + /* null char */ 1 != wValueLength) {
LIEF_INFO("String.Value.size() is different from wValueLength ({} / {})",
wValueLength, res->size() + 1);
}
value = res->c_str(); // To remove trailling \0
std::string u8value = u16tou8(value);
LIEF_DEBUG("{}: {}", u8szKey, u8value);
lci.items_.emplace(szKey, value);
stream.align(sizeof(uint32_t));
}
value = res->c_str(); // To remove trailling \0
std::string u8value = u16tou8(value);
LIEF_DEBUG("{}: {}", u8szKey, u8value);
lci.items_.emplace(szKey, value);
stream.align(sizeof(uint32_t));
} else {
lci.items_.emplace(szKey, std::u16string());
}
} else {
LIEF_ERR("Can't read String.szKey");