-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lief] add new port LIEF-0.16.0 (#42374)
Co-authored-by: WangWeiLin-MV <[email protected]>
- Loading branch information
1 parent
78030b6
commit 7bac262
Showing
11 changed files
with
352 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index fc2b679..4ec92b9 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -113,19 +113,7 @@ message(STATUS "CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: ${CMAKE_CXX_IMPLICIT_LINK_LIB | ||
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 | ||
# ====================== | ||
@@ -318,7 +306,9 @@ else() | ||
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp) | ||
endif() | ||
|
||
-target_link_libraries(LIB_LIEF PRIVATE lief_spdlog) | ||
+find_package(fmt CONFIG REQUIRED) | ||
+find_package(spdlog CONFIG REQUIRED) | ||
+target_link_libraries(LIB_LIEF PRIVATE fmt::fmt spdlog::spdlog) | ||
|
||
if(ANDROID AND LIEF_LOGGING) | ||
target_link_libraries(LIB_LIEF PUBLIC log) | ||
@@ -507,11 +497,11 @@ if(LIEF_INSTALL) | ||
endif() | ||
|
||
install( | ||
- TARGETS LIB_LIEF lief_spdlog | ||
+ TARGETS LIB_LIEF | ||
EXPORT LIEFExport | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
install( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/cmake/LIEFConfig.cmake.in b/cmake/LIEFConfig.cmake.in | ||
index dba7363..7f88f98 100644 | ||
--- a/cmake/LIEFConfig.cmake.in | ||
+++ b/cmake/LIEFConfig.cmake.in | ||
@@ -69,7 +69,7 @@ macro(LIEF_load_targets lib_type) | ||
return() | ||
endif () | ||
|
||
- if("${lib_type}" STREQUAL "static") | ||
+ if(1) | ||
# Need to find all dependencies even if they're private when LIEF is | ||
# compiled statically | ||
include(CMakeFindDependencyMacro) | ||
@@ -93,6 +93,10 @@ macro(LIEF_load_targets lib_type) | ||
if(NOT @LIEF_DISABLE_FROZEN@ AND @LIEF_OPT_FROZEN_EXTERNAL@) | ||
find_dependency(frozen) | ||
endif() | ||
+ | ||
+ find_dependency(tl-expected) | ||
+ find_dependency(fmt) | ||
+ check_required_components(lief) | ||
endif() | ||
|
||
# Include the respective targets file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
diff --git a/src/BinaryStream/BinaryStream.cpp b/src/BinaryStream/BinaryStream.cpp | ||
index 83e618c..6447b7b 100644 | ||
--- a/src/BinaryStream/BinaryStream.cpp | ||
+++ b/src/BinaryStream/BinaryStream.cpp | ||
@@ -15,7 +15,7 @@ | ||
*/ | ||
#include "LIEF/BinaryStream/BinaryStream.hpp" | ||
#include "LIEF/DWARF/enums.hpp" | ||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
#include <mbedtls/x509.h> | ||
#include <mbedtls/x509_crt.h> | ||
diff --git a/src/PE/Builder.cpp b/src/PE/Builder.cpp | ||
index 8cbe7b2..994e9bf 100644 | ||
--- a/src/PE/Builder.cpp | ||
+++ b/src/PE/Builder.cpp | ||
@@ -21,7 +21,7 @@ | ||
|
||
#include "logging.hpp" | ||
|
||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
|
||
#include "LIEF/PE/Builder.hpp" | ||
diff --git a/src/logging.cpp b/src/logging.cpp | ||
index 39936fe..f5e1345 100644 | ||
--- a/src/logging.cpp | ||
+++ b/src/logging.cpp | ||
@@ -20,7 +20,7 @@ | ||
#include "logging.hpp" | ||
|
||
#include "spdlog/spdlog.h" | ||
-#include "spdlog/fmt/bundled/args.h" | ||
+#include <fmt/args.h> | ||
#include "spdlog/sinks/stdout_color_sinks.h" | ||
#include "spdlog/sinks/basic_file_sink.h" | ||
#include "spdlog/sinks/android_sink.h" | ||
diff --git a/src/utils.cpp b/src/utils.cpp | ||
index 0acbba1..b624a1d 100644 | ||
--- a/src/utils.cpp | ||
+++ b/src/utils.cpp | ||
@@ -22,7 +22,7 @@ | ||
#include "LIEF/utils.hpp" | ||
#include "LIEF/errors.hpp" | ||
|
||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
#include "LIEF/config.h" | ||
#include "logging.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
vcpkg_download_distfile( | ||
FIX_FMT_V11_JOIN_LINUX_INCLUDE_MEMORY_PATCH | ||
URLS https://github.com/lief-project/LIEF/commit/41166332a2435fdb7d2bdc5c73f9ff9b442c5459.patch?full_index=1 | ||
FILENAME fix-fmt-v11-join-linux-include-memory-41166332a2435fdb7d2bdc5c73f9ff9b442c5459.patch | ||
SHA512 14d5f7380352bd340c16447905b8185dbd2d977c8ba245e01d982fe7fbbdffb71004b9d4fdd732bc13e71a11aa3f46a4822cdeb2277e2cec6b841492d0de5606 | ||
) | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO lief-project/LIEF | ||
REF ${VERSION} | ||
SHA512 7df75fab6c7023e37a6a4d27fac8dcb4200e0235625fc5952bb23cedb2e582a37fb67ee471c1ae953c0b205fd9cca5538a835f65ef80a771f72dc7ff68000ed9 | ||
HEAD_REF master | ||
PATCHES | ||
fix-cmakelists.patch | ||
fix-liefconfig-cmake-in.patch | ||
fix-vcpkg-includes.patch | ||
"${FIX_FMT_V11_JOIN_LINUX_INCLUDE_MEMORY_PATCH}" | ||
) | ||
|
||
file(REMOVE_RECURSE "${SOURCE_PATH}/third-party") | ||
|
||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
FEATURES | ||
"c-api" LIEF_C_API # C API | ||
"enable-json" LIEF_ENABLE_JSON # Enable JSON-related APIs | ||
"extra-warnings" LIEF_EXTRA_WARNINGS # Enable extra warning from the compiler | ||
"logging" LIEF_LOGGING # Enable logging | ||
"logging-debug" LIEF_LOGGING_DEBUG # Enable debug logging | ||
|
||
"use-ccache" LIEF_USE_CCACHE # Use ccache to speed up compilation | ||
|
||
"elf" LIEF_ELF # Build LIEF with ELF module | ||
"pe" LIEF_PE # Build LIEF with PE module | ||
"macho" LIEF_MACHO # Build LIEF with MachO module | ||
|
||
"oat" LIEF_OAT # Build LIEF with OAT module | ||
"dex" LIEF_DEX # Build LIEF with DEX module | ||
"vdex" LIEF_VDEX # Build LIEF with VDEX module | ||
"art" LIEF_ART # Build LIEF with ART module | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
${FEATURE_OPTIONS} | ||
-DLIEF_EXAMPLES=OFF | ||
|
||
# Build with external vcpkg dependencies | ||
-DLIEF_OPT_MBEDTLS_EXTERNAL=ON | ||
-DLIEF_EXTERNAL_SPDLOG=ON | ||
-DLIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON | ||
-DLIEF_OPT_FROZEN_EXTERNAL=ON | ||
-DLIEF_OPT_EXTERNAL_SPAN=ON | ||
-DLIEF_OPT_UTFCPP_EXTERNAL=ON | ||
-DLIEF_OPT_EXTERNAL_EXPECTED=ON | ||
-DLIEF_DISABLE_FROZEN=OFF | ||
-DLIEF_DISABLE_EXCEPTIONS=OFF | ||
|
||
"-DLIEF_EXTERNAL_SPAN_DIR=${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET}/include/tcb" | ||
) | ||
|
||
vcpkg_cmake_install() | ||
|
||
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/LIEF") | ||
|
||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/lief/LIEFConfig.cmake" | ||
[[include("${LIEF_${lib_type}_export}")]] | ||
[[include("${CMAKE_CURRENT_LIST_DIR}/LIEFExport-${lib_type}.cmake")]] | ||
) | ||
|
||
vcpkg_fixup_pkgconfig() | ||
|
||
file(REMOVE_RECURSE | ||
"${CURRENT_PACKAGES_DIR}/debug/include" | ||
"${CURRENT_PACKAGES_DIR}/debug/share" | ||
) | ||
|
||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "lief", | ||
"version-semver": "0.16.0", | ||
"description": "LIEF - Library to Instrument Executable Formats", | ||
"homepage": "https://lief.quarkslab.com", | ||
"license": "Apache-2.0", | ||
"dependencies": [ | ||
"fmt", | ||
"frozen", | ||
"mbedtls", | ||
"spdlog", | ||
"tcb-span", | ||
"tl-expected", | ||
"utfcpp", | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
} | ||
], | ||
"default-features": [ | ||
"art", | ||
"dex", | ||
"elf", | ||
"enable-json", | ||
"logging", | ||
"macho", | ||
"oat", | ||
"pe", | ||
"vdex" | ||
], | ||
"features": { | ||
"art": { | ||
"description": "Build LIEF with ART module" | ||
}, | ||
"c-api": { | ||
"description": "C API" | ||
}, | ||
"dex": { | ||
"description": "Build LIEF with DEX module" | ||
}, | ||
"elf": { | ||
"description": "Build LIEF with ELF module" | ||
}, | ||
"enable-json": { | ||
"description": "Enable JSON-related APIs", | ||
"dependencies": [ | ||
"nlohmann-json" | ||
] | ||
}, | ||
"extra-warnings": { | ||
"description": "Enable extra warning from the compiler" | ||
}, | ||
"logging": { | ||
"description": "Enable logging" | ||
}, | ||
"logging-debug": { | ||
"description": "Enable debug logging" | ||
}, | ||
"macho": { | ||
"description": "Build LIEF with MachO module" | ||
}, | ||
"oat": { | ||
"description": "Build LIEF with OAT module" | ||
}, | ||
"pe": { | ||
"description": "Build LIEF with PE module" | ||
}, | ||
"use-ccache": { | ||
"description": "Use ccache to speed up compilation" | ||
}, | ||
"vdex": { | ||
"description": "Build LIEF with VDEX module" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${CURRENT_PORT_DIR}/project" | ||
) | ||
|
||
vcpkg_cmake_build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
project(vcpkg-ci-lief LANGUAGES C CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
find_package(LIEF CONFIG REQUIRED) | ||
add_executable(main main.cpp) | ||
target_link_libraries(main PRIVATE LIEF::LIEF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
#include <LIEF/LIEF.hpp> | ||
#include <LIEF/version.h> | ||
|
||
int main() | ||
{ | ||
std::cout << "access flags public = " << LIEF::DEX::to_string(LIEF::DEX::access_flags_list[1]) << std::endl; | ||
std::cout << "Version = " << LIEF_VERSION << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "vcpkg-ci-lief", | ||
"version-string": "ci", | ||
"description": "Testing packages which provide lief", | ||
"license": null, | ||
"dependencies": [ | ||
{ | ||
"name": "lief", | ||
"features": [ | ||
"c-api", | ||
"enable-json", | ||
"extra-warnings", | ||
"logging", | ||
"logging-debug", | ||
"use-ccache", | ||
"elf", | ||
"pe", | ||
"macho", | ||
"oat", | ||
"dex", | ||
"vdex", | ||
"art" | ||
] | ||
}, | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "fafe51c4db1abe4b79e44013592db1c89945740d", | ||
"version-semver": "0.16.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |