Skip to content

Commit 33ef57c

Browse files
authored
Project: replace libelf with libelfin (#169)
2 parents 91d041d + 79d9caa commit 33ef57c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+225
-12087
lines changed

.github/workflows/debug.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ jobs:
207207
}
208208
steps:
209209
- uses: actions/checkout@v4
210+
with:
211+
submodules: recursive
210212

211213
- name: Ccache
212214
uses: hendrikmuhs/ccache-action@v1.2.11 # https://github.com/hendrikmuhs/ccache-action/issues/181

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "riscv-tests"]
22
path = tests/riscv-official/riscv-tests
33
url = https://github.com/riscv-software-src/riscv-tests.git
4+
[submodule "external/libelfin"]
5+
path = external/libelfin
6+
url = https://github.com/mortbopet/libelfin

CMakeLists.txt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -226,30 +226,11 @@ if ("${WASM}")
226226
else ()
227227
# Not available for WASM
228228
enable_testing()
229-
230-
if (NOT "${FORCE_ELFLIB_STATIC}")
231-
find_package(LibElf)
232-
if ("${LibElf_FOUND}")
233-
include(CheckSymbolExists)
234-
check_symbol_exists(EM_RISCV "gelf.h" LIBELF_HAS_RISCV)
235-
if ("${LIBELF_HAS_RISCV}")
236-
# Turn non-cmake library into a cmake target
237-
add_library(libelf INTERFACE)
238-
target_link_libraries(libelf INTERFACE ${LIBELF_LIBRARY})
239-
target_include_directories(libelf INTERFACE ${LIBELF_INCLUDE_DIR})
240-
message(STATUS "Using system libelf")
241-
else ()
242-
message(STATUS "System libelf does not support RISC-V")
243-
set(LibElf_FOUND FALSE) # Force fallback
244-
endif ()
245-
endif ()
246-
endif ()
247229
endif ()
248230

249-
if ("${WASM}" OR "${FORCE_ELFLIB_STATIC}" OR NOT "${LibElf_FOUND}")
250-
message(STATUS "Using local libelf fallback.")
251-
add_subdirectory("external/libelf")
252-
endif ()
231+
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
232+
set(CMAKE_PROJECT_libelfin_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibElfinSettings.cmake")
233+
add_subdirectory("external/libelfin")
253234

254235
# Detect Qt used qt version
255236
# Based on article https://www.steinzone.de/wordpress/how-to-support-both-qt5-and-qt6-using-cmake/

cmake/FindPythonInterp.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Compatibility wrapper for CMake > 3.12 where FindPythonInterp is deprecated/removed
2+
# This allows external projects using the old module to work with newer CMake and Python3
3+
4+
find_package(Python3 COMPONENTS Interpreter QUIET)
5+
6+
if(Python3_Interpreter_FOUND)
7+
set(PYTHONINTERP_FOUND TRUE)
8+
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
9+
set(PYTHON_VERSION_STRING ${Python3_VERSION})
10+
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
11+
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
12+
set(PYTHON_VERSION_PATCH ${Python3_VERSION_PATCH})
13+
14+
if(NOT PythonInterp_FIND_QUIETLY)
15+
message(STATUS "Found PythonInterp (via Python3): ${PYTHON_EXECUTABLE} (found version \"${PYTHON_VERSION_STRING}\")")
16+
endif()
17+
else()
18+
if(PythonInterp_FIND_REQUIRED)
19+
message(FATAL_ERROR "Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)")
20+
endif()
21+
endif()

cmake/LibElfinSettings.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if(POLICY CMP0148)
2+
cmake_policy(SET CMP0148 OLD)
3+
endif()
4+
5+
# Libelfin requires Threads for dwarf++ library
6+
find_package(Threads REQUIRED)
7+

external/libelf/32.fsize.c

Lines changed: 0 additions & 141 deletions
This file was deleted.

external/libelf/32.getehdr.c

Lines changed: 0 additions & 52 deletions
This file was deleted.

external/libelf/32.getphdr.c

Lines changed: 0 additions & 52 deletions
This file was deleted.

external/libelf/32.getshdr.c

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)